-
Notifications
You must be signed in to change notification settings - Fork 105
Expand file tree
/
Copy pathnumpy.rb
More file actions
142 lines (117 loc) · 4.01 KB
/
numpy.rb
File metadata and controls
142 lines (117 loc) · 4.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
require 'formula'
class GfortranAvailable < Requirement
def satisfied?
which 'gfortran' or which 'gfortran-4.7'
end
def fatal?
true
end
def message; <<-EOS.undent
No gfortran found! You may use gfortran provided by homebrew:
- `brew install gfortran`
EOS
end
end
class NoUserConfig < Requirement
def satisfied?
not File.exist? "#{ENV['HOME']}/.numpy-site.cfg"
end
def message; <<-EOS.undent
A ~/.numpy-site.cfg has been detected, which may interfere with our business.
EOS
end
end
class Numpy < Formula
url 'http://sourceforge.net/projects/numpy/files/NumPy/1.6.2/numpy-1.6.2.tar.gz'
homepage 'http://numpy.scipy.org'
sha1 'c36c471f44cf914abdf37137d158bf3ffa460141'
head 'https://github.com/numpy/numpy.git'
devel do
url 'http://sourceforge.net/projects/numpy/files/NumPy/1.7.0b2/numpy-1.7.0b2.tar.gz'
sha1 '1c40bfeda1754365bfc3da024ea5afd32adfafb4'
end
depends_on 'nose' => :python
depends_on GfortranAvailable.new
depends_on NoUserConfig.new
depends_on 'suite-sparse' # for libamd and libumfpack
option 'with-openblas', "Use openBLAS instead of Apple's Accelerate Framework"
depends_on "openblas" if build.include? 'with-openblas'
def patches
# Help numpy/distutils find homebrew's versioned gfortran-4.7 executable,
# if `brew install gcc --enable-fortran` was used.
DATA
end
def install
# Numpy ignores FC and FCFLAGS, but we declare fortran so Homebrew knows
ENV.fortran
# Numpy is configured via a site.cfg and we want to use some libs
# For maintainers:
# Check which BLAS/LAPACK numpy actually uses via:
# xcrun otool -L /usr/local/Cellar/numpy/1.6.2/lib/python2.7/site-packages/numpy/linalg/lapack_lite.so
config = <<-EOS.undent
[DEFAULT]
library_dirs = #{HOMEBREW_PREFIX}/lib
include_dirs = #{HOMEBREW_PREFIX}/include
[amd]
amd_libs = amd
[umfpack]
umfpack_libs = umfpack
EOS
if build.include? 'with-openblas'
openblas_dir = Formula.factory('openblas').opt_prefix
# Setting ATLAS to None is important to prevent numpy from always
# linking against Accelerate.framework.
ENV['ATLAS'] = "None"
ENV['BLAS'] = ENV['LAPACK'] = "#{openblas_dir}/lib/libopenblas.dylib"
config << <<-EOS.undent
[blas_opt]
libraries = openblas
library_dirs = #{openblas_dir}/lib
include_dirs = #{openblas_dir}/include
[lapack_opt]
libraries = openblas
library_dirs = #{openblas_dir}/lib
include_dirs = #{openblas_dir}/include
EOS
end
Pathname('site.cfg').write config
# In order to install into the Cellar, the dir must exist and be in the
# PYTHONPATH.
temp_site_packages = lib/which_python/'site-packages'
mkdir_p temp_site_packages
ENV['PYTHONPATH'] = temp_site_packages
args = [
"--no-user-cfg",
"--verbose",
"build",
"--fcompiler=gnu95", # gfortran is gnu95
"install",
"--force",
"--install-scripts=#{share}/python",
"--install-lib=#{temp_site_packages}",
"--install-data=#{share}",
"--install-headers=#{include}",
"--record=installed-files.txt"
]
system "python", "-s", "setup.py", *args
end
def test
system "python", "-c", "import numpy; numpy.test()"
end
def which_python
"python" + `python -c 'import sys;print(sys.version[:3])'`.strip
end
end
__END__
diff --git a/numpy/distutils/fcompiler/gnu.py b/numpy/distutils/fcompiler/gnu.py
index e80a417..15d164b 100644
--- a/numpy/distutils/fcompiler/gnu.py
+++ b/numpy/distutils/fcompiler/gnu.py
@@ -247,7 +247,7 @@ class Gnu95FCompiler(GnuFCompiler):
# GNU Fortran 95 (GCC) 4.2.0 20060218 (experimental)
# GNU Fortran (GCC) 4.3.0 20070316 (experimental)
- possible_executables = ['gfortran', 'f95']
+ possible_executables = ['gfortran-4.7', 'f95', 'gfortran']
executables = {
'version_cmd' : ["<F90>", "--version"],
'compiler_f77' : [None, "-Wall", "-ffixed-form",