-
Notifications
You must be signed in to change notification settings - Fork 115
/
numpy.rb
113 lines (92 loc) · 3.44 KB
/
numpy.rb
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
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 have to assure a gfortran is in your PATH. You can:
- `brew install gfortran` or
- `brew tap homebrew/dupes && brew install gcc --enable-fortran`.
The latter builds the latest gcc release from source (takes some time).
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.0b1/numpy-1.7.0b1.tar.gz'
sha1 '0a6f1455d45ab8c4c6cc07ebd80e7d3ca89ee036'
end
depends_on 'nose' => :python
depends_on GfortranAvailable.new
depends_on NoUserConfig.new
depends_on 'suite-sparse' # for libamd and libumfpack
# temporary use staticfloat's openblas until it has been pulled into homebrew/science
# depends_on 'openblas' if build.include? 'use-openblas'
depends_on "staticfloat/julia/openblas" if build.include? 'use-openblas'
option 'use-openblas', "Use openBLAS instead of Apple's Accelerate Framework"
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 therefore we don't need ENV.fortran here :-(
# Allow numpy to find brewed python
env :userpaths
if build.include? 'use-openblas'
# For maintainers:
# Check which BLAS/LAPACK numpy actually uses via:
# xcrun otool -L Cellar/numpy/1.6.2/lib/python2.7/site-packages/numpy/linalg/lapack_lite.so
ENV['ATLAS'] = "None"
ENV['BLAS'] = "#{Formula.factory('staticfloat/julia/openblas').lib}/libopenblas.dylib"
ENV['LAPACK'] = "#{Formula.factory('staticfloat/julia/openblas').lib}/libopenblas.dylib"
end
# Numpy is configured via a site.cfg and we want to use some libs
config = <<-EOS.undent
[DEFAULT]
library_dirs = #{HOMEBREW_PREFIX}/lib
include_dirs = #{HOMEBREW_PREFIX}/include
[amd]
amd_libs = amd
[umfpack]
umfpack_libs = umfpack
EOS
Pathname('site.cfg').write config
# gfortran is gnu95
system "python", "setup.py", "build", "--fcompiler=gnu95"
system "python", "setup.py", "install", "--prefix=#{prefix}"
end
def test
system "python", "-c", "import numpy; numpy.test()"
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",