Repository navigation
Expand file tree
/
Copy pathmanylinux-build-wheels.sh
More file actions
executable file
·146 lines (125 loc) · 5.15 KB
/
Copy pathmanylinux-build-wheels.sh
File metadata and controls
executable file
·146 lines (125 loc) · 5.15 KB
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
#!/usr/bin/env bash
# -----------------------------------------------------------------------
# These variables are set in common script:
#
ARCH=""
PYBINARIES=""
PYTHON_LIBRARY=""
script_dir=$(cd $(dirname $0) || exit 1; pwd)
source "${script_dir}/manylinux-build-common.sh"
# -----------------------------------------------------------------------
# Build standalone project and populate archive cache
mkdir -p /work/standalone-${ARCH}-build
pushd /work/standalone-${ARCH}-build > /dev/null 2>&1
cmake -DITKPythonPackage_BUILD_PYTHON:PATH=0 -G Ninja ../
ninja
popd > /dev/null 2>&1
SINGLE_WHEEL=0
# Compile wheels re-using standalone project and archive cache
for PYBIN in "${PYBINARIES[@]}"; do
if [[ ${PYBIN} == *"cp26"* || ${PYBIN} == *"cp33"* ]]; then
echo "Skipping ${PYBIN}"
continue
fi
PYTHON_EXECUTABLE=${PYBIN}/python
PYTHON_INCLUDE_DIR=$( find -L ${PYBIN}/../include/ -name Python.h -exec dirname {} \; )
echo ""
echo "PYTHON_EXECUTABLE:${PYTHON_EXECUTABLE}"
echo "PYTHON_INCLUDE_DIR:${PYTHON_INCLUDE_DIR}"
echo "PYTHON_LIBRARY:${PYTHON_LIBRARY}"
# Install dependencies
${PYBIN}/pip install --upgrade -r /work/requirements-dev.txt
build_type=MinSizeRel
source_path=/work/standalone-${ARCH}-build/ITK-source
build_path=/work/ITK-$(basename $(dirname ${PYBIN}))-manylinux1_${ARCH}
SETUP_PY_CONFIGURE="${script_dir}/../setup_py_configure.py"
# Clean up previous invocations
rm -rf ${build_path}
if [[ ${SINGLE_WHEEL} == 1 ]]; then
echo "#"
echo "# Build single ITK wheel"
echo "#"
# Configure setup.py
${PYBIN}/python ${SETUP_PY_CONFIGURE} "itk"
# Generate wheel
${PYBIN}/python setup.py bdist_wheel --build-type ${build_type} -G Ninja -- \
-DITK_SOURCE_DIR:PATH=${source_path} \
-DITK_BINARY_DIR:PATH=${build_path} \
-DITKPythonPackage_ITK_BINARY_REUSE:BOOL=OFF \
-DITKPythonPackage_WHEEL_NAME:STRING="itk" \
-DCMAKE_CXX_COMPILER_TARGET:STRING=$(uname -p)-linux-gnu \
-DPYTHON_EXECUTABLE:FILEPATH=${PYTHON_EXECUTABLE} \
-DPYTHON_INCLUDE_DIR:PATH=${PYTHON_INCLUDE_DIR} \
-DPYTHON_LIBRARY:FILEPATH=${PYTHON_LIBRARY}
# Cleanup
${PYBIN}/python setup.py clean
else
echo "#"
echo "# Build multiple ITK wheels"
echo "#"
# Build ITK python
(
mkdir -p ${build_path} \
&& cd ${build_path} \
&& cmake \
-DCMAKE_BUILD_TYPE:STRING=${build_type} \
-DITK_SOURCE_DIR:PATH=${source_path} \
-DITK_BINARY_DIR:PATH=${build_path} \
-DBUILD_TESTING:BOOL=OFF \
-DPYTHON_EXECUTABLE:FILEPATH=${PYTHON_EXECUTABLE} \
-DPYTHON_INCLUDE_DIR:PATH=${PYTHON_INCLUDE_DIR} \
-DPYTHON_LIBRARY:FILEPATH=${PYTHON_LIBRARY} \
-DCMAKE_CXX_COMPILER_TARGET:STRING=$(uname -p)-linux-gnu \
-DWRAP_ITK_INSTALL_COMPONENT_IDENTIFIER:STRING=PythonWheel \
-DWRAP_ITK_INSTALL_COMPONENT_PER_MODULE:BOOL=ON \
-DPY_SITE_PACKAGES_PATH:PATH=${script_dir}/../../_skbuild/cmake-install \
-DITK_LEGACY_SILENT:BOOL=ON \
-DITK_WRAP_PYTHON:BOOL=ON \
-DITK_WRAP_PYTHON_LEGACY:BOOL=OFF \
-G Ninja \
${source_path} \
&& ninja \
|| exit 1
)
wheel_names=$(cat ${script_dir}/../WHEEL_NAMES.txt)
for wheel_name in ${wheel_names}; do
# Configure setup.py
${PYBIN}/python ${SETUP_PY_CONFIGURE} ${wheel_name}
# Generate wheel
${PYBIN}/python setup.py bdist_wheel --build-type ${build_type} -G Ninja -- \
-DITK_SOURCE_DIR:PATH=${source_path} \
-DITK_BINARY_DIR:PATH=${build_path} \
-DITKPythonPackage_ITK_BINARY_REUSE:BOOL=ON \
-DITKPythonPackage_WHEEL_NAME:STRING=${wheel_name} \
-DPYTHON_EXECUTABLE:FILEPATH=${PYTHON_EXECUTABLE} \
-DPYTHON_INCLUDE_DIR:PATH=${PYTHON_INCLUDE_DIR} \
-DPYTHON_LIBRARY:FILEPATH=${PYTHON_LIBRARY} \
|| exit 1
# Cleanup
${PYBIN}/python setup.py clean
done
fi
# Remove unnecessary files for building against ITK
find ${build_path} -name '*.cpp' -delete -o -name '*.xml' -delete
rm -rf ${build_path}/Wrapping/Generators/castxml*
find ${build_path} -name '*.o' -delete
done
# Since there are no external shared libraries to bundle into the wheels
# this step will fixup the wheel switching from 'linux' to 'manylinux1' tag
for whl in dist/*linux_$(uname -p).whl; do
auditwheel repair ${whl} -w /work/dist/
rm ${whl}
done
# Install packages and test
for PYBIN in "${PYBINARIES[@]}"; do
if [[ ${PYBIN} == *"cp26"* || ${PYBIN} == *"cp33"* ]]; then
echo "Skipping ${PYBIN}"
continue
fi
${PYBIN}/pip install numpy
${PYBIN}/pip install itk --no-cache-dir --no-index -f /work/dist
(cd $HOME && ${PYBIN}/python -c 'from itk import ITKCommon;')
(cd $HOME && ${PYBIN}/python -c 'import itk; image = itk.Image[itk.UC, 2].New()')
(cd $HOME && ${PYBIN}/python -c 'import itkConfig; itkConfig.LazyLoading = False; import itk;')
(cd $HOME && ${PYBIN}/python ${script_dir}/../../docs/code/testDriver.py )
done