2
2
# encoding: utf-8
3
3
import os
4
4
import shutil
5
+ import sys
5
6
import tarfile
6
7
7
8
from waflib .Configure import conf
@@ -104,6 +105,28 @@ def build_mathjax(ctx, target):
104
105
os .path .join (ctx .out_dir , ".mathjax-done" )))
105
106
106
107
108
+ @conf
109
+ def build_blas (ctx , target ):
110
+ srcpath = ctx .env .SRCPATH
111
+ libpath = os .path .join (ctx .out_dir , "lib" )
112
+ srcscript = """
113
+ set -e
114
+ base="blas"
115
+ pushd %(srcpath)s/3rdparty
116
+ rm -fr BLAS
117
+ tar -xzf "$base.tgz"
118
+ pushd BLAS
119
+ gfortran -shared -O2 *.f -o libblas.so -fPIC
120
+ gfortran -O2 -c *.f
121
+ ar cr libblas.a *.o
122
+ cp libblas.a libblas.so %(libpath)s
123
+ popd
124
+ rm -fr BLAS
125
+ popd
126
+ """ % locals ()
127
+ ctx .venv_exec (srcscript )
128
+
129
+
107
130
@conf
108
131
def build_cvxopt (ctx , target ):
109
132
srcpath = ctx .env .SRCPATH
@@ -131,9 +154,22 @@ def build(ctx):
131
154
source = "../bin/activate" , target = "../bin/pkg-config" )
132
155
133
156
ctx .module ("libpng-1.5.13" , source = "../bin/pkg-config" , target = "../bin/libpng-config" )
134
- ctx .module ("zeromq-3.2.2" , source = "../bin/pkg-config" , target = "../lib/libzmq.dylib " )
157
+ ctx .module ("zeromq-3.2.2" , source = "../bin/pkg-config" , target = "../lib/libzmq.a " )
135
158
ctx (rule = ctx .build_freetype2 , source = "../bin/pkg-config" , target = "../bin/freetype-config" )
136
- ctx (rule = ctx .build_gfortran , source = "../bin/pkg-config" , target = "../bin/gfortran" )
159
+
160
+ pkg = os .path .join (ctx .path .abspath (), "3rdparty" , "site-packages" )
161
+ if sys .platform == "darwin" :
162
+ ctx (rule = ctx .build_gfortran , source = "../bin/pkg-config" , target = "../bin/gfortran" )
163
+ readlinetar = "%s/readline-6.2.4.1.tar.gz" % pkg
164
+ readlinecmd = ctx .venv ("easy_install --no-find-links %s && touch ${TGT}" % readlinetar )
165
+ ctx (rule = readlinecmd , source = "../bin/pkg-config" , target = "../.readline-done" )
166
+ platform_deps = ["../bin/gfortran" , "../.readline-done" ]
167
+ else :
168
+ # We assume that a fortran compiler with lapack is installed.
169
+ # It may be installed using:
170
+ # sudo apt-get install liblapack-dev gfortran
171
+ ctx (rule = ctx .build_blas , source = "../bin/pkg-config" , target = "../lib/libblas.a" )
172
+ platform_deps = ["../lib/libblas.a" ]
137
173
138
174
# qt_configure_flags = (
139
175
# "-opensource -fast -no-qt3support -no-phonon "
@@ -144,15 +180,11 @@ def build(ctx):
144
180
# "qt-everywhere-opensource-src-4.8.4", qt_configure_flags, 1,
145
181
# source="../bin/pkg-config", target="../bin/qmake")
146
182
147
- pkg = os .path .join (ctx .path .abspath (), "3rdparty" , "site-packages" )
148
- readlinetar = "%s/readline-6.2.4.1.tar.gz" % pkg
149
- readlinecmd = ctx .venv ("easy_install --no-find-links %s && touch ${TGT}" % readlinetar )
150
- ctx (rule = readlinecmd , source = "../bin/pkg-config" , target = "../.readline-done" )
151
-
152
183
# Install numpy separately due to bug in scipy install script.
153
184
site_packages = os .path .join (".." , "lib" , "python2.7" , "site-packages" )
154
185
numpy = os .path .join (site_packages , "numpy" , "__init__.py" )
155
- ctx (rule = ctx .venv ("pip install numpy==1.6.2" ), source = "../bin/pkg-config" , target = numpy )
186
+ ctx (rule = ctx .venv ("pip install numpy==1.6.2 --no-index -f file://%s" % pkg ),
187
+ source = "../bin/pkg-config" , target = numpy )
156
188
157
189
# Install cvxopt separately due to misplaced setup.py file.
158
190
cvxopt = os .path .join (site_packages , "cvxopt" , "__init__.py" )
@@ -163,13 +195,11 @@ def build(ctx):
163
195
rule = ctx .venv ("pip install --no-index -f file://%s -r %s && touch ${TGT}" % (pkg , reqs )),
164
196
source = [
165
197
numpy ,
166
- "../bin/gfortran" ,
167
198
"../bin/freetype-config" ,
168
199
"../bin/libpng-config" ,
169
200
# "../bin/qmake",
170
- "../lib/libzmq.dylib" ,
171
- "../.readline-done"
172
- ],
201
+ "../lib/libzmq.a" ,
202
+ ] + platform_deps ,
173
203
target = "../.requirements-done" )
174
204
175
205
ctx .add_manual_dependency ("../.requirements-done" , reqs )
0 commit comments