Skip to content

Commit 6693afb

Browse files
author
cjh26
committed
Merge github.com:rammie/machine-stack
2 parents 59d528c + 7f81481 commit 6693afb

File tree

3 files changed

+234
-142
lines changed

3 files changed

+234
-142
lines changed

requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
flake8==2.0
22
Imaging==1.1.7
3-
ipython==0.13.1
43
matplotlib==1.2.0
54
mccabe==0.2
65
mpmath==0.17

waftools/modules.py

Lines changed: 213 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,213 @@
1+
#! /usr/bin/env python
2+
# encoding: utf-8
3+
import os
4+
import shutil
5+
import tarfile
6+
7+
from waflib.Configure import conf
8+
9+
10+
@conf
11+
def module_builder(ctx, module, configure="", numthreads=4):
12+
srcpath = ctx.env.SRCPATH
13+
return """
14+
base="%(module)s"
15+
pushd %(srcpath)s/3rdparty
16+
rm -fr "$base"
17+
tar xzf "$base.tar.gz"
18+
pushd "$base"
19+
./configure --prefix=$VIRTUAL_ENV %(configure)s
20+
make -j%(numthreads)d
21+
make install
22+
popd
23+
rm -fr "$base"
24+
popd
25+
""" % locals()
26+
27+
28+
@conf
29+
def module(ctx, module, configure="", numthreads=4, **kwargs):
30+
srcscript = ctx.module_builder(module, configure, numthreads)
31+
return ctx(rule=lambda target: ctx.venv_exec(srcscript), **kwargs)
32+
33+
34+
@conf
35+
def build_freetype2(ctx, target):
36+
srcscript = ctx.module_builder("freetype-2.1.10")
37+
ctx.venv_exec(srcscript)
38+
39+
includepath = os.path.join(ctx.out_dir, "include")
40+
srcpath = os.path.join(includepath, "ft2build.h")
41+
dstpath = os.path.join(includepath, "freetype2", "ft2build.h")
42+
os.symlink(srcpath, dstpath)
43+
44+
45+
@conf
46+
def build_gfortran(ctx, target):
47+
binpath = os.path.join(ctx.out_dir, "bin")
48+
manpath = os.path.join(ctx.out_dir, "share", "man", "man1")
49+
includepath = os.path.join(ctx.out_dir, "include")
50+
51+
binfiles = os.listdir(binpath)
52+
manfiles = os.listdir(manpath)
53+
srcpath = ctx.env.SRCPATH
54+
55+
ctx.venv_exec("""
56+
base="gcc-42-5666.3-darwin11"
57+
pushd %(srcpath)s/3rdparty
58+
rm -fr "$base"
59+
mkdir -p "$base"
60+
pushd "$base"
61+
xar -xf "../$base.pkg"
62+
mv *.pkg/Payload Payload.gz
63+
pax --insecure -rz -f Payload.gz -s ",./usr,$VIRTUAL_ENV,"
64+
ln -sf "$VIRTUAL_ENV/bin/gfortran-4.2" "$VIRTUAL_ENV/bin/gfortran"
65+
popd
66+
rm -fr "$base"
67+
popd
68+
""" % locals())
69+
70+
# Delete other files installed
71+
shutil.rmtree(os.path.join(includepath, "gcc"))
72+
73+
for f in os.listdir(binpath):
74+
if f not in binfiles and not "gfortran" in f:
75+
os.unlink(os.path.join(binpath, f))
76+
77+
for f in os.listdir(manpath):
78+
if f not in manfiles and not "gfortran" in f:
79+
os.unlink(os.path.join(manpath, f))
80+
81+
82+
@conf
83+
def build_mathjax(ctx, target):
84+
cmd = "from IPython.frontend.html import notebook; print notebook.__file__"
85+
nbfile = ctx.venv_exec("echo \"%s\" | python" % cmd, log=True)
86+
static = os.path.join(os.path.dirname(nbfile), "static")
87+
tarpath = os.path.join(ctx.env.SRCPATH, "3rdparty", "mathjax-1.1.0.tar.gz")
88+
tar = tarfile.open(name=tarpath, mode="r:gz")
89+
topdir = tar.firstmember.path
90+
tar.extractall(static)
91+
ctx.cmd_and_log("mv -f %s %s && touch %s" % (
92+
os.path.join(static, topdir),
93+
os.path.join(static, "mathjax"),
94+
os.path.join(ctx.out_dir, ".mathjax-done")))
95+
96+
97+
@conf
98+
def build_blas(ctx, target):
99+
srcpath = ctx.env.SRCPATH
100+
libpath = os.path.join(ctx.out_dir, "lib")
101+
srcscript = """
102+
set -e
103+
base="blas"
104+
pushd %(srcpath)s/3rdparty
105+
rm -fr BLAS
106+
tar -xzf "$base.tgz"
107+
pushd BLAS
108+
gfortran -shared -O2 *.f -o libblas.so -fPIC
109+
gfortran -O2 -c *.f
110+
ar cr libblas.a *.o
111+
cp libblas.a libblas.so %(libpath)s
112+
popd
113+
rm -fr BLAS
114+
popd
115+
""" % locals()
116+
ctx.venv_exec(srcscript)
117+
118+
119+
@conf
120+
def build_scons(ctx, target):
121+
module = "scons-2.3.0"
122+
srcpath = ctx.env.SRCPATH
123+
srcscript = """
124+
set -e
125+
base="%(module)s"
126+
pushd %(srcpath)s/3rdparty/site-packages
127+
rm -fr "$base"
128+
tar -xzf "$base.tar.gz"
129+
pushd "$base"
130+
python setup.py install
131+
popd
132+
rm -fr "$base"
133+
popd
134+
""" % locals()
135+
ctx.venv_exec(srcscript)
136+
137+
138+
@conf
139+
def build_mongo(ctx, target):
140+
module = "mongodb-src-r2.4.2"
141+
srcpath = ctx.env.SRCPATH
142+
srcscript = """
143+
set -e
144+
base="%(module)s"
145+
pushd %(srcpath)s/3rdparty
146+
rm -fr "$base"
147+
tar -xzf "$base.tar.gz"
148+
pushd "$base"
149+
scons --prefix="$VIRTUAL_ENV" install
150+
popd
151+
rm -fr "$base"
152+
popd
153+
""" % locals()
154+
ctx.venv_exec(srcscript)
155+
156+
157+
@conf
158+
def build_hbase(ctx, target):
159+
module = "hbase-0.94.6.1"
160+
srcpath = ctx.env.SRCPATH
161+
srcscript = """
162+
set -e
163+
base="%(module)s"
164+
pushd %(srcpath)s/3rdparty
165+
rm -fr "$base"
166+
tar -xzf "$base.tar.gz"
167+
rm -fr "$VIRTUAL_ENV/hbase"
168+
mv "$base" "$VIRTUAL_ENV/hbase"
169+
rm -fr "$VIRTUAL_ENV/hbase/conf/hbase-site.xml"
170+
(cat <<EOF
171+
<?xml version="1.0"?>
172+
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
173+
<configuration>
174+
<property>
175+
<name>hbase.rootdir</name>
176+
<value>file://$VIRTUAL_ENV/hbase-data</value>
177+
</property>
178+
<property>
179+
<name>hbase.zookeeper.property.dataDir</name>
180+
<value>$VIRTUAL_ENV/zookeeper-data</value>
181+
</property>
182+
</configuration>
183+
EOF
184+
) > "$VIRTUAL_ENV/hbase/conf/hbase-site.xml"
185+
popd
186+
""" % locals()
187+
ctx.venv_exec(srcscript)
188+
189+
190+
@conf
191+
def build_cvxopt(ctx, target):
192+
srcpath = ctx.env.SRCPATH
193+
module = "cvxopt-1.1.5"
194+
195+
# setup file is in the "src"
196+
srcscript = """
197+
base="%(module)s"
198+
pushd %(srcpath)s/3rdparty/site-packages
199+
rm -fr "$base"
200+
tar xzf "$base.tar.gz"
201+
pushd "$base/src"
202+
python setup.py install
203+
popd
204+
rm -fr "$base"
205+
popd
206+
""" % locals()
207+
ctx.venv_exec(srcscript)
208+
209+
210+
@conf
211+
def pip_install(ctx, target):
212+
pkg = os.path.join(ctx.path.abspath(), "3rdparty", "site-packages")
213+
return ctx.venv("pip install %s --no-index -f file://%s" % (target, pkg))

0 commit comments

Comments
 (0)