Skip to content

Commit d160830

Browse files
committed
manylinux-build-wheels: Configure project with correct options
* To avoid re-downloading the source, pass SimpleITK_SOURCE_DIR * Specify correct include_dir/library/interpreter. * Finally, since the python interpreter exports its symbol (see [1]), SimpleITK python modules should not link against any python libraries. To ensure it is not the case, we configure the project using an empty file as python library. [1] "Note that libpythonX.Y.so.1 is not on the list of libraries that a manylinux1 extension is allowed to link to. Explicitly linking to libpythonX.Y.so.1 is unnecessary in almost all cases: the way ELF linking works, extension modules that are loaded into the interpreter automatically get access to all of the interpreter's symbols, regardless of whether or not the extension itself is explicitly linked against libpython. [...]" Source: https://www.python.org/dev/peps/pep-0513/#libpythonx-y-so-1
1 parent fcced6c commit d160830

2 files changed

Lines changed: 37 additions & 2 deletions

File tree

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# This project
2+
scripts/manylinux-libpython-not-needed-symbols-exported-by-interpreter
3+
skbuild
4+
standalone-build
5+
6+
# Python
17
*.py[cod]
28

39
# C extensions

scripts/manylinux-build-wheels.sh

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,45 @@ pushd /work/standalone-build > /dev/null 2>&1
88
ninja
99
popd > /dev/null 2>&1
1010

11+
# Since the python interpreter exports its symbol (see [1]), SimpleITK python
12+
# modules should not link against any python libraries.
13+
# To ensure it is not the case, we configure the project using an empty
14+
# file as python library.
15+
#
16+
# [1] "Note that libpythonX.Y.so.1 is not on the list of libraries that
17+
# a manylinux1 extension is allowed to link to. Explicitly linking to
18+
# libpythonX.Y.so.1 is unnecessary in almost all cases: the way ELF linking
19+
# works, extension modules that are loaded into the interpreter automatically
20+
# get access to all of the interpreter's symbols, regardless of whether or
21+
# not the extension itself is explicitly linked against libpython. [...]"
22+
#
23+
# Source: https://www.python.org/dev/peps/pep-0513/#libpythonx-y-so-1
24+
PYTHON_LIBRARY=/work/scripts/manylinux-libpython-not-needed-symbols-exported-by-interpreter
25+
touch ${PYTHON_LIBRARY}
26+
1127
# Compile wheels re-using standalone project and archive cache
1228
for PYBIN in /opt/python/*/bin; do
1329
if [[ ${PYBIN} == *"cp26"* ]]; then
1430
echo "Skipping ${PYBIN}"
1531
continue
1632
fi
33+
34+
PYTHON_EXECUTABLE=${PYBIN}/python
35+
PYTHON_INCLUDE_DIR=$( find -L ${PYBIN}/../include/ -name Python.h -exec dirname {} \; )
36+
37+
echo ""
38+
echo "PYTHON_EXECUTABLE:${PYTHON_EXECUTABLE}"
39+
echo "PYTHON_INCLUDE_DIR:${PYTHON_INCLUDE_DIR}"
40+
echo "PYTHON_LIBRARY:${PYTHON_LIBRARY}"
41+
1742
${PYBIN}/pip install --user -r /work/requirements-dev.txt
18-
${PYBIN}/python setup.py bdist_wheel -- \
43+
${PYBIN}/python setup.py bdist_wheel -G Ninja -- \
1944
-DSimpleITK_DIR:PATH=/work/standalone-build/SimpleITK-superbuild/SimpleITK-build \
20-
-DSWIG_EXECUTABLE:PATH=/work/standalone-build/SimpleITK-superbuild/Swig/bin/swig
45+
-DSimpleITK_SOURCE_DIR:PATH=/work/standalone-build/SimpleITK \
46+
-DSWIG_EXECUTABLE:FILEPATH=/work/standalone-build/SimpleITK-superbuild/Swig/bin/swig \
47+
-DPYTHON_EXECUTABLE:FILEPATH=${PYTHON_EXECUTABLE} \
48+
-DPYTHON_INCLUDE_DIR:PATH=${PYTHON_INCLUDE_DIR} \
49+
-DPYTHON_LIBRARY:FILEPATH=${PYTHON_LIBRARY}
2150
${PYBIN}/python setup.py clean
2251
done
2352

0 commit comments

Comments
 (0)