Skip to content

Commit ab6169a

Browse files
committed
linux: refactor ITK and module scripts to avoid duplicate code
Suggested-by: Jean-Christophe Fillion-Robin <[email protected]>
1 parent 2c56118 commit ab6169a

File tree

3 files changed

+52
-86
lines changed

3 files changed

+52
-86
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Content common to manylinux-build-wheels.sh and
2+
# manylinux-build-module-wheels.sh
3+
4+
set -e -x
5+
6+
# Versions can be restricted by passing them in as arguments to the script
7+
# For example,
8+
# manylinux-build-wheels.sh cp27mu cp35
9+
if [[ $# -eq 0 ]]; then
10+
PYBINARIES=(/opt/python/*/bin)
11+
else
12+
PYBINARIES=()
13+
for version in "$@"; do
14+
PYBINARIES+=(/opt/python/*${version}*/bin)
15+
done
16+
fi
17+
18+
# i686 or x86_64 ?
19+
case $(uname -p) in
20+
i686)
21+
arch=x86
22+
;;
23+
x86_64)
24+
arch=x64
25+
;;
26+
*)
27+
die "Unknown architecture $(uname -p)"
28+
;;
29+
esac
30+
31+
echo "Building wheels for $arch"
32+
33+
# Since the python interpreter exports its symbol (see [1]), python
34+
# modules should not link against any python libraries.
35+
# To ensure it is not the case, we configure the project using an empty
36+
# file as python library.
37+
#
38+
# [1] "Note that libpythonX.Y.so.1 is not on the list of libraries that
39+
# a manylinux1 extension is allowed to link to. Explicitly linking to
40+
# libpythonX.Y.so.1 is unnecessary in almost all cases: the way ELF linking
41+
# works, extension modules that are loaded into the interpreter automatically
42+
# get access to all of the interpreter's symbols, regardless of whether or
43+
# not the extension itself is explicitly linked against libpython. [...]"
44+
#
45+
# Source: https://www.python.org/dev/peps/pep-0513/#libpythonx-y-so-1
46+
PYTHON_LIBRARY=$(cd $(dirname $0); pwd)/manylinux-libpython-not-needed-symbols-exported-by-interpreter
47+
touch ${PYTHON_LIBRARY}
48+

scripts/internal/manylinux-build-module-wheels.sh

Lines changed: 2 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,7 @@
11
#!/usr/bin/env bash
2-
set -e -x
32

4-
# Versions can be restricted by passing them in as arguments to the script
5-
# For example,
6-
# manylinux-build-wheels.sh cp27mu cp35
7-
if [[ $# -eq 0 ]]; then
8-
PYBINARIES=(/opt/python/*/bin)
9-
else
10-
PYBINARIES=()
11-
for version in "$@"; do
12-
PYBINARIES+=(/opt/python/*${version}*/bin)
13-
done
14-
fi
15-
16-
# i686 or x86_64 ?
17-
case $(uname -p) in
18-
i686)
19-
arch=x86
20-
;;
21-
x86_64)
22-
arch=x64
23-
;;
24-
*)
25-
die "Unknown architecture $(uname -p)"
26-
;;
27-
esac
28-
29-
echo "Building wheels for $arch"
30-
31-
# Since the python interpreter exports its symbol (see [1]), python
32-
# modules should not link against any python libraries.
33-
# To ensure it is not the case, we configure the project using an empty
34-
# file as python library.
35-
#
36-
# [1] "Note that libpythonX.Y.so.1 is not on the list of libraries that
37-
# a manylinux1 extension is allowed to link to. Explicitly linking to
38-
# libpythonX.Y.so.1 is unnecessary in almost all cases: the way ELF linking
39-
# works, extension modules that are loaded into the interpreter automatically
40-
# get access to all of the interpreter's symbols, regardless of whether or
41-
# not the extension itself is explicitly linked against libpython. [...]"
42-
#
43-
# Source: https://www.python.org/dev/peps/pep-0513/#libpythonx-y-so-1
44-
PYTHON_LIBRARY=/ITKPythonPackage/scripts/internal/manylinux-libpython-not-needed-symbols-exported-by-interpreter
45-
touch ${PYTHON_LIBRARY}
3+
script_dir="`cd $(dirname $0); pwd`"
4+
source "${script_dir}/manylinux-build-common.sh"
465

476
# Compile wheels re-using standalone project and archive cache
487
for PYBIN in "${PYBINARIES[@]}"; do

scripts/internal/manylinux-build-wheels.sh

Lines changed: 2 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,7 @@
11
#!/usr/bin/env bash
2-
set -e -x
32

4-
# Versions can be restricted by passing them in as arguments to the script
5-
# For example,
6-
# manylinux-build-wheels.sh cp27mu cp35
7-
if [[ $# -eq 0 ]]; then
8-
PYBINARIES=(/opt/python/*/bin)
9-
else
10-
PYBINARIES=()
11-
for version in "$@"; do
12-
PYBINARIES+=(/opt/python/*${version}*/bin)
13-
done
14-
fi
15-
16-
# i686 or x86_64 ?
17-
case $(uname -p) in
18-
i686)
19-
arch=x86
20-
;;
21-
x86_64)
22-
arch=x64
23-
;;
24-
*)
25-
die "Unknown architecture $(uname -p)"
26-
;;
27-
esac
28-
29-
echo "Building wheels for $arch"
3+
script_dir="`cd $(dirname $0); pwd`"
4+
source "${script_dir}/manylinux-build-common.sh"
305

316
# Build standalone project and populate archive cache
327
mkdir -p /work/standalone-${arch}-build
@@ -35,22 +10,6 @@ pushd /work/standalone-${arch}-build > /dev/null 2>&1
3510
ninja
3611
popd > /dev/null 2>&1
3712

38-
# Since the python interpreter exports its symbol (see [1]), python
39-
# modules should not link against any python libraries.
40-
# To ensure it is not the case, we configure the project using an empty
41-
# file as python library.
42-
#
43-
# [1] "Note that libpythonX.Y.so.1 is not on the list of libraries that
44-
# a manylinux1 extension is allowed to link to. Explicitly linking to
45-
# libpythonX.Y.so.1 is unnecessary in almost all cases: the way ELF linking
46-
# works, extension modules that are loaded into the interpreter automatically
47-
# get access to all of the interpreter's symbols, regardless of whether or
48-
# not the extension itself is explicitly linked against libpython. [...]"
49-
#
50-
# Source: https://www.python.org/dev/peps/pep-0513/#libpythonx-y-so-1
51-
PYTHON_LIBRARY=/work/scripts/internal/manylinux-libpython-not-needed-symbols-exported-by-interpreter
52-
touch ${PYTHON_LIBRARY}
53-
5413
# Compile wheels re-using standalone project and archive cache
5514
for PYBIN in "${PYBINARIES[@]}"; do
5615
if [[ ${PYBIN} == *"cp26"* || ${PYBIN} == *"cp33"* ]]; then

0 commit comments

Comments
 (0)