forked from numpy/numpy-vendor
-
Notifications
You must be signed in to change notification settings - Fork 1
/
fabfile.py
219 lines (187 loc) · 7.15 KB
/
fabfile.py
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
from fabric.api import env, local, run, sudo, cd
from fabric.context_managers import shell_env, prefix
from fabric.operations import put, get
env.use_ssh_config = True
def all():
prepare()
numpy_release()
def prepare():
prepare_apt()
prepare_userspace()
def prepare_userspace():
"""
This can be reverted by executing 'remove_userspace'.
"""
copy()
setup_wine()
setup_paver()
run("pip install cython=='0.23.4' --user")
gitrepos()
numpy_cpucaps()
def prepare_apt():
#sudo("add-apt-repository -y ppa:ubuntu-wine/ppa") required for > precise install wine1.6
sudo("apt-get -qq update")
# This is needed to avoid the EULA dialog
# (http://askubuntu.com/questions/16225/how-can-i-accept-the-agreement-in-a-terminal-like-for-ttf-mscorefonts-installer)
sudo("echo ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true | debconf-set-selections")
sudo("apt-get -y install git wine patch python-virtualenv "
"texlive-latex-recommended texlive-latex-extra "
"texlive-fonts-recommended make python-dev g++ libfreetype6-dev "
"libpng-dev python-matplotlib python-setuptools python-jinja2 "
"python-pygments python-docutils python-pip "
"python-sphinx --no-install-recommends")
sudo("apt-get install -f")
def remove_userspace():
"""
Deletes (!) the NumPy and Wine changes. Use with great care.
"""
run("rm -rf repos")
run("rm -rf .wine")
def copy():
run("mkdir -p repos/numpy-vendor")
run("cp -r /vagrant/* repos/numpy-vendor/")
def gitrepos():
run("mkdir -p repos")
with cd("repos"):
run("git clone https://github.com/numpy/numpy")
with cd("numpy"):
run("git submodule init")
run("git checkout -t origin/maintenance/1.10.x")
run("git submodule update")
def prepare_scipy(fork='scipy'):
"""
Use a custom repo with: ``$ fab vagrant prepare_scipy:username``.
"""
run("mkdir -p repos")
with cd("repos"):
run("git clone https://github.com/%s/scipy" % fork)
with cd("scipy"):
run("git submodule init")
run("git submodule update")
sudo("apt-get -y install libatlas-base-dev")
install_numpy_for_scipy()
def install_numpy_for_scipy():
install_cmd = "setup.py config --compiler=mingw32 build --compiler=mingw32 install"
with cd("repos/numpy"):
for pyver, npver in (('27', '1.6.2'), ('33', '1.7.2'), ('34', '1.7.2')):
run("git clean -xdf")
run("rm -rf doc/sphinxext") # otherwise cannot checkout old tags
run("git checkout v" + npver)
run("wine 'C:\Python%s\python' %s" % (pyver, install_cmd))
def setup_wine():
with cd("repos/numpy-vendor"):
run("./setup-wine.sh")
def setup_paver():
with cd("repos/numpy-vendor"):
run("tar xzf Paver-1.2.2.tar.gz")
with cd("Paver-1.2.2"):
run("python setup.py build")
sudo("python setup.py install")
def numpy_cpucaps():
with cd("repos/numpy/tools/win32build"):
run('wine "C:\Python27\python" build-cpucaps.py')
run(r"cp cpucaps.dll $HOME/.wine/drive_c/Program\ Files\ \(x86\)/NSIS/Plugins")
def numpy_release():
with cd("repos/numpy"), shell_env(PYTHONPATH='/home/vagrant/repos/local/lib/python2.7/site-packages',
NPY_SEPARATE_COMPILATION='1',
OSTYPE='msys'):
run("rm -rf ../local")
run("paver sdist")
run("python setup.py install --prefix ../local")
run("paver pdf")
run("paver bdist_superpack -p 3.4")
run("paver bdist_superpack -p 3.3")
run("paver bdist_superpack -p 2.7")
run("paver write_release_and_log")
run("paver bdist_wininst_simple -p 2.7")
run("paver bdist_wininst_simple -p 3.3")
run("paver bdist_wininst_simple -p 3.4")
numpy_copy_release_files()
def numpy_copy_release_files():
with cd("repos/numpy"):
run("cp -r release/ /vagrant/")
run("cp build_doc/pdf/*.pdf /vagrant/release/")
run("mkdir /vagrant/release/pypi")
run("cp dist/*.exe /vagrant/release/pypi/")
with cd("/vagrant/release"):
run("mv installers/* .")
run("rm -r installers")
run("mv NOTES.txt README.txt")
mac_tmp = "numpy_tmp" # NumPy and dependencies will be built in $HOME/"mac_tmp"
#FIXME: the Python path is hardwired here...
#TODO: just remove this hack:
mac_prefix = 'export PYTHONPATH="$HOME/%s/usr/lib/python2.7/site-packages/" PATH="$HOME/%s/usr/bin:$PATH"' % (mac_tmp, mac_tmp)
def mac_setup():
run("mkdir %s" % mac_tmp)
mac_setup_numpy()
#mac_setup_paver()
#mac_setup_virtualenv()
#mac_setup_bdist_mpkg()
mac_copy_pdf()
def mac_copy_pdf():
with cd(mac_tmp + "/numpy"):
run("mkdir -p build_doc/pdf")
put("release/reference.pdf", "build_doc/pdf/")
put("release/userguide.pdf", "build_doc/pdf/")
def mac_remove_userspace():
run("rm -rf %s" % mac_tmp)
def mac_setup_numpy():
with cd(mac_tmp):
run("git clone https://github.com/numpy/numpy")
with cd("numpy"):
run("git submodule init")
run("git checkout -t origin/maintenance/1.9.x")
run("git submodule update")
def mac_setup_bdist_mpkg():
with cd(mac_tmp):
run("git clone https://github.com/rgommers/bdist_mpkg.git")
with cd("bdist_mpkg"):
with prefix(mac_prefix):
run("python setup.py install --prefix=../usr")
def mac_setup_paver():
with cd(mac_tmp):
with prefix(mac_prefix):
put("Paver-1.2.2.tar.gz", ".")
run("tar xzf Paver-1.2.2.tar.gz")
with cd("Paver-1.2.2"):
run("python setup.py install --prefix=../usr")
def mac_setup_virtualenv():
with cd(mac_tmp):
with prefix(mac_prefix):
put("virtualenv-1.8.4.tar.gz", ".")
run("tar xzf virtualenv-1.8.4.tar.gz")
with cd("virtualenv-1.8.4"):
run("python setup.py install --prefix=../usr")
def mac_numpy_release():
with cd(mac_tmp + "/numpy"):
run("paver sdist")
run("paver dmg -p 2.6")
run("paver dmg -p 2.7")
get("release/installers/*.dmg", "release/")
# ------------------------------------------------
# Vagrant related configuration
def vagrant():
vc = _get_vagrant_config()
# change from the default user to 'vagrant'
env.user = vc['User']
# connect to the port-forwarded ssh
env.hosts = ['%s:%s' % (vc['HostName'], vc['Port'])]
# use vagrant ssh key
env.key_filename = vc['IdentityFile'].strip('"')
# Forward the agent if specified:
env.forward_agent = vc.get('ForwardAgent', 'no') == 'yes'
def _get_vagrant_config():
"""
Parses vagrant configuration and returns it as dict of ssh parameters
and their values
"""
result = local('vagrant ssh-config', capture=True)
conf = {}
for line in iter(result.splitlines()):
parts = line.split()
conf[parts[0]] = ' '.join(parts[1:])
return conf
# ---------------------------------------
# Just a simple testing command:
def uname():
run('uname -a')