run_build.sh 7.39 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/bash

#############################
# CONFIGURATION
#############################

if [ ! $1 ]; then
    BUILD_TARGET="win-amd64"
else
    BUILD_TARGET=$1
fi

if [ "$BUILD_TARGET" = "win32" ]; then
	PYTHON_SUFFIX=""
	MSVC_BUILD_TARGET="/x86"
elif [ "$BUILD_TARGET" = "win-amd64" ]; then
	PYTHON_SUFFIX=".amd64"
	MSVC_BUILD_TARGET="/x64"
else
	echo "Unrecognized build target ! [ win32 | win-amd64]"
	exit 1 # signal error
fi

24
# Which versions of external programs to use
25
26
27
28
29
30
31
PYTHON_VERSION=2.7.6

CI_PROJECT_DIR_WIN=$(cygpath -a -w ${CI_PROJECT_DIR})

# Change working directory to the directory the script is in
# http://stackoverflow.com/a/246128
SCRIPT_DIR="${CI_PROJECT_DIR}/BuildServer/Windows"
eric pellegrini's avatar
eric pellegrini committed
32
<<<<<<< a2772996ba490836dae52f4b332b9c66e8d74aa6
eric pellegrini's avatar
eric pellegrini committed
33
SCRIPT_DIR_WIN=$(cygpath -a -w $SCRIPT_DIR)
eric pellegrini's avatar
eric pellegrini committed
34
35
36
=======
SCRIPT_DIR_WIN=$(cygpath -u $SCRIPT_DIR)
>>>>>>> debug windows build script
37
38
39

# This is the directory that will contain the temporary installation
TARGET_DIR="${CI_PROJECT_DIR_WIN}\\BuildServer\\Windows\\Build"
eric pellegrini's avatar
eric pellegrini committed
40
TARGET_DIR_WIN=$(cygpath -u $TARGET_DIR)
41
42
43
44
45
46
47
48
49
50
51
52
53
54

function extract
{
	echo "Extracting $*"
	echo "7z x -y $*" >> log.txt
	7z x -y $* >> log.txt
}

#############################
# Build the packages
#############################

cd "${SCRIPT_DIR}"

eric pellegrini's avatar
eric pellegrini committed
55
56
57
if [ -e "$TARGET_DIR_WIN" ]; then
	echo "Removing previous target dir : $TARGET_DIR_WIN"
	rm -rf ${TARGET_DIR_WIN}
58
59
fi

eric pellegrini's avatar
eric pellegrini committed
60
61
CI_WINDOWS_DEPENDENCIES_PATH=$(cygpath -a -w ${CI_WINDOWS_DEPENDENCIES_PATH_UNIX})

62
DEPENDENCIES_DIR=${CI_WINDOWS_DEPENDENCIES_PATH_UNIX}/${BUILD_TARGET}
eric pellegrini's avatar
eric pellegrini committed
63
DEPENDENCIES_DIR_WIN=$(cygpath -a -w ${DEPENDENCIES_DIR})
64
65
66
67
68
69
70
71

PYTHON_MSI=python-${PYTHON_VERSION}${PYTHON_SUFFIX}.msi
PYTHON_MSI_WIN=${CI_WINDOWS_DEPENDENCIES_PATH}\\${BUILD_TARGET}\\${PYTHON_MSI}

echo "Extracting python ${PYTHON_MSI_WIN} in ${TARGET_DIR}"
cmd /c "msiexec  /L* pythonlog.txt /qn /a ${PYTHON_MSI_WIN} TARGETDIR=${TARGET_DIR}"

# Exit now if something goes wrong
Remi Perenon's avatar
Remi Perenon committed
72
status=$?
Remi Perenon's avatar
Remi Perenon committed
73
if [ $status -ne 0 ]; then
74
	echo "Failed to extract python"
Remi Perenon's avatar
Remi Perenon committed
75
	exit $status
76
77
78
79
fi

#Clean up python a bit, to keep the package size down
echo "Cleaning up Python"
eric pellegrini's avatar
eric pellegrini committed
80
81
82
83
84
85
86
rm -rf ${TARGET_DIR_WIN}/Doc
rm -rf ${TARGET_DIR_WIN}/Lib/site-packages
rm -rf ${TARGET_DIR_WIN}/Lib/test
rm -rf ${TARGET_DIR_WIN}/Tools/Scripts
rm -rf ${TARGET_DIR_WIN}/tcl
rm -f ${TARGET_DIR_WIN}/NEWS.txt
rm -f ${TARGET_DIR_WIN}/${PYTHON_MSI}
87

eric pellegrini's avatar
eric pellegrini committed
88
89
mkdir -p ${TARGET_DIR_WIN}/Lib/site-packages
mkdir -p ${TARGET_DIR_WIN}/Scripts
90
91
92
93
94

cd ${DEPENDENCIES_DIR}

echo "Extracting dependencies"

eric pellegrini's avatar
eric pellegrini committed
95
96
97
# extract setuptools
extract setuptools-28.7.1.${BUILD_TARGET}.exe PURELIB

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
# extract numpy
extract numpy-MKL-1.8.0.${BUILD_TARGET}-py2.7.exe PLATLIB

# extract matplotlib and its dependencies
extract pyparsing-2.0.1.${BUILD_TARGET}-py2.7.exe PURELIB
extract python-dateutil-2.2.${BUILD_TARGET}-py2.7.exe PURELIB
extract pytz-2013.9.${BUILD_TARGET}-py2.7.exe PURELIB
extract six-1.5.2.${BUILD_TARGET}-py2.7.exe PURELIB
extract matplotlib-1.3.1.${BUILD_TARGET}-py2.7.exe PLATLIB

#extract Cython
extract Cython-0.19.2.${BUILD_TARGET}-py2.7.exe PLATLIB
extract Cython-0.19.2.${BUILD_TARGET}-py2.7.exe SCRIPTS

# extract Pyro
extract Pyro-3.16.${BUILD_TARGET}.exe PURELIB

# extract Sphinx and its dependencies
extract alabaster-0.7.5.${BUILD_TARGET}.exe PURELIB
extract Pygments-2.0.2.${BUILD_TARGET}.exe PURELIB
extract Pygments-2.0.2.${BUILD_TARGET}.exe SCRIPTS
extract Babel-1.3.${BUILD_TARGET}.exe PURELIB
extract Babel-1.3.${BUILD_TARGET}.exe SCRIPTS
extract MarkupSafe-0.23.${BUILD_TARGET}-py2.7.exe PLATLIB
extract Jinja2-2.7.3.${BUILD_TARGET}.exe PURELIB
extract docutils-0.12.${BUILD_TARGET}.exe PURELIB
extract docutils-0.12.${BUILD_TARGET}.exe SCRIPTS
extract Sphinx-1.3.1.${BUILD_TARGET}.exe PURELIB
extract sphinx_rtd_theme-0.1.8.${BUILD_TARGET}.exe PURELIB

extract nose-1.3.7.${BUILD_TARGET}.exe PURELIB
extract nose-1.3.7.${BUILD_TARGET}.exe SCRIPTS

# extract VTK
extract VTK-5.10.1.${BUILD_TARGET}-py2.7.exe PURELIB

# extract wxPython and its dependencies
extract wxPython-common-2.8.12.1.${BUILD_TARGET}-py2.7.exe PURELIB
extract wxPython-2.8.12.1.${BUILD_TARGET}-py2.7.exe PLATLIB

138
# extract netcdf
eric pellegrini's avatar
eric pellegrini committed
139
extract netCDF4.6.0.${BUILD_TARGET}.exe \$_OUTDIR
140
141
142

# move the packages to the target directory
echo "Moving dependencies to ${BUILD_TARGET}"
eric pellegrini's avatar
eric pellegrini committed
143

eric pellegrini's avatar
eric pellegrini committed
144
mv PURELIB/pkg_resources ${TARGET_DIR_WIN}/Lib/site-packages/pkg_resources
eric pellegrini's avatar
eric pellegrini committed
145

eric pellegrini's avatar
eric pellegrini committed
146
mv PLATLIB/numpy ${TARGET_DIR_WIN}/Lib/site-packages/numpy
147

eric pellegrini's avatar
eric pellegrini committed
148
149
150
151
152
mv PURELIB/dateutil ${TARGET_DIR_WIN}/Lib/site-packages/dateutil
mv PURELIB/pyparsing.py ${TARGET_DIR_WIN}/Lib/site-packages/pyparsing.py
mv PURELIB/pytz ${TARGET_DIR_WIN}/Lib/site-packages/pytz
mv PURELIB/six.py ${TARGET_DIR_WIN}/Lib/site-packages/six.py
mv PLATLIB/matplotlib ${TARGET_DIR_WIN}/Lib/site-packages/matplotlib
153

eric pellegrini's avatar
eric pellegrini committed
154
155
156
157
mv PLATLIB/Cython ${TARGET_DIR_WIN}/Lib/site-packages/Cython
mv SCRIPTS/cython.py ${TARGET_DIR_WIN}/Scripts/cython.py
cp ${TARGET_DIR}/Scripts/cython.py ${TARGET_DIR_WIN}/Lib/site-packages/
mv PURELIB/Pyro ${TARGET_DIR_WIN}/Lib/site-packages/Pyro
158

eric pellegrini's avatar
eric pellegrini committed
159
160
161
162
163
164
165
166
167
168
169
mv PURELIB/alabaster ${TARGET_DIR_WIN}/Lib/site-packages/alabaster
mv PURELIB/pygments ${TARGET_DIR_WIN}/Lib/site-packages/pygments
mv SCRIPTS/pygment* ${TARGET_DIR_WIN}/Scripts/
mv PURELIB/babel ${TARGET_DIR_WIN}/Lib/site-packages/babel
mv SCRIPTS/pybabel* ${TARGET_DIR_WIN}/Scripts/
mv PLATLIB/markupsafe ${TARGET_DIR_WIN}/Lib/site-packages/markupsafe
mv PURELIB/jinja2 ${TARGET_DIR_WIN}/Lib/site-packages/jinja2
mv PURELIB/docutils ${TARGET_DIR_WIN}/Lib/site-packages/docutils
mv SCRIPTS/rst* ${TARGET_DIR_WIN}/Scripts/
mv PURELIB/sphinx ${TARGET_DIR_WIN}/Lib/site-packages/sphinx
mv PURELIB/sphinx_rtd_theme ${TARGET_DIR_WIN}/Lib/site-packages/sphinx_rtd_theme
170

eric pellegrini's avatar
eric pellegrini committed
171
172
mv PURELIB/nose ${TARGET_DIR_WIN}/Lib/site-packages/nose
mv SCRIPTS/nosetests ${TARGET_DIR_WIN}/Scripts/
173

eric pellegrini's avatar
eric pellegrini committed
174
mv PURELIB/vtk ${TARGET_DIR_WIN}/Lib/site-packages/vtk
175

eric pellegrini's avatar
eric pellegrini committed
176
177
178
mv PURELIB/wx.pth ${TARGET_DIR_WIN}/Lib/site-packages/
mv PURELIB/wxversion.py ${TARGET_DIR_WIN}/Lib/site-packages/
mv PLATLIB/wx-2.8-msw-unicode ${TARGET_DIR_WIN}/Lib/site-packages/wx-2.8-msw-unicode
179

180
181
182
183
mv \$_OUTDIR/bin/netcdf.dll .
mv \$_OUTDIR/include/netcdf.h .
mv \$_OUTDIR/lib/netcdf.lib .

eric pellegrini's avatar
eric pellegrini committed
184
rm -rf \$_OUTDIR
eric pellegrini's avatar
eric pellegrini committed
185

186
187
git clone https://code.ill.fr/scientific-software/scientific-python.git
cd scientific-python
eric pellegrini's avatar
eric pellegrini committed
188
git checkout master
eric pellegrini's avatar
eric pellegrini committed
189
cmd /V:ON /E:ON /C "${SCRIPT_DIR_WIN}/setup_and_build.bat" "${DEPENDENCIES_DIR_WIN}/scientific-python" "${TARGET_DIR}" "${MSVC_BUILD_TARGET}" "--netcdf_prefix=${DEPENDENCIES_DIR_WIN} --netcdf_dll=${DEPENDENCIES_DIR_WIN}"
190
191
192
cd ..
rm -rf scientific-python

eric pellegrini's avatar
eric pellegrini committed
193
194
mv netcdf.h ${TARGET_DIR_WIN}/include/Scientific
mv netcdf.dll ${TARGET_DIR_WIN}/Lib/site-packages/Scientific
195
196
197
198
rm netcdf.lib

git clone https://code.ill.fr/scientific-software/mmtk.git
cd mmtk
eric pellegrini's avatar
eric pellegrini committed
199
git checkout master
eric pellegrini's avatar
eric pellegrini committed
200
cmd /V:ON /E:ON /C "${SCRIPT_DIR_WIN}/setup_and_build.bat" "${DEPENDENCIES_DIR_WIN}/mmtk" "${TARGET_DIR}" "${MSVC_BUILD_TARGET}"
201
202
cd ..
rm -rf mmtk
203
204
205
206
207
208
209
210
211
212
213
214

rm -rf DATA
rm -rf PLATLIB
rm -rf PURELIB
rm -rf SCRIPTS

cd ${SCRIPT_DIR}

rm pythonlog.txt

cd ${CI_PROJECT_DIR}

215
# Update the __pkginfo__ file with the current commit 
216
COMMIT_ID=$(git rev-parse --short HEAD)
217
218
219
sed -i "s/.*__commit__.*/__commit__ = \"${COMMIT_ID}\"/" MDANSE/__pkginfo__.py

# Get revision number from GIT
220
echo "Commit id ${COMMIT_ID}"
221
222
223
224
225
226
227
228
229
230

# setup the environment for a visual studio build of MDANSE using microsoft SDK 7.0 and build MDANSE
echo "MDANSE setup and build"

# go back to the installation base directory
cd ${SCRIPT_DIR}

cmd /V:ON /E:ON /C "setup_and_build.bat" "${CI_PROJECT_DIR_WIN}" "${TARGET_DIR}" ${MSVC_BUILD_TARGET}

# Exit now if unable to build
Remi Perenon's avatar
Remi Perenon committed
231
status=$?
Remi Perenon's avatar
Remi Perenon committed
232
if [ $status -ne 0 ]; then
233
	echo "Failed to build MDANSE"
234
	exit $status
235
fi
Remi Perenon's avatar
Remi Perenon committed
236
237

exit 0