Skip to content

Commit b30da58

Browse files
committed
ENH: Forward CMake arguments for MacOS builds
1 parent 265fd1e commit b30da58

File tree

3 files changed

+46
-3
lines changed

3 files changed

+46
-3
lines changed

scripts/macpython-build-common.sh

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,53 @@ SCRIPT_DIR=$(cd $(dirname $0) || exit 1; pwd)
77

88
MACPYTHON_PY_PREFIX=/Library/Frameworks/Python.framework/Versions
99

10+
# -----------------------------------------------------------------------
11+
# Script argument parsing
12+
#
13+
usage()
14+
{
15+
echo "Usage:
16+
macpython-build-common
17+
[ -h | --help ] show usage
18+
[ -c | --cmake_options ] space-separated string of CMake options to forward to the module (e.g. \"-DBUILD_TESTING=OFF\")
19+
[ -- python_versions ] build wheel for a specific python version(s). (e.g. -- cp39 cp310)"
20+
exit 2
21+
}
22+
23+
PYTHON_VERSIONS=""
24+
CMAKE_OPTIONS=""
25+
26+
while (( "$#" )); do
27+
case "$1" in
28+
-c|--cmake_options)
29+
CMAKE_OPTIONS="$2";
30+
shift 2;;
31+
-h|--help)
32+
usage;
33+
break;;
34+
--)
35+
shift;
36+
break;;
37+
*)
38+
# Parse any unrecognized arguments as python versions
39+
PYTHON_VERSIONS="${PYTHON_VERSIONS} $1";
40+
shift;;
41+
esac
42+
done
43+
44+
# Parse all arguments after "--" as python versions
45+
PYTHON_VERSIONS="${PYTHON_VERSIONS} $@"
46+
# Trim whitespace
47+
PYTHON_VERSIONS=$(xargs <<< "${PYTHON_VERSIONS}")
48+
1049
# Versions can be restricted by passing them in as arguments to the script
1150
# For example,
1251
# macpython-build-wheels.sh 3.9
13-
if [[ $# -eq 0 ]]; then
52+
if [[ -n "${PYTHON_VERSIONS}" ]]; then
1453
PYBINARIES=(${MACPYTHON_PY_PREFIX}/*)
1554
else
1655
PYBINARIES=()
17-
for version in "$@"; do
56+
for version in "$PYTHON_VERSIONS"; do
1857
PYBINARIES+=(${MACPYTHON_PY_PREFIX}/*${version}*)
1958
done
2059
fi

scripts/macpython-build-module-wheels.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ for VENV in "${VENVS[@]}"; do
7272
-DBUILD_TESTING:BOOL=OFF \
7373
-DPython3_EXECUTABLE:FILEPATH=${Python3_EXECUTABLE} \
7474
-DPython3_INCLUDE_DIR:PATH=${Python3_INCLUDE_DIR} \
75+
${CMAKE_OPTIONS} \
7576
|| exit 1
7677
# ${Python3_EXECUTABLE} setup.py clean # Permission denied
7778
done

scripts/macpython-build-wheels.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,8 @@ for VENV in "${VENVS[@]}"; do
118118
-DPython3_INCLUDE_DIR:PATH=${Python3_INCLUDE_DIR} \
119119
-DModule_ITKTBB:BOOL=ON \
120120
-DTBB_DIR:PATH=${tbb_dir} \
121-
-DITK_WRAP_DOC:BOOL=ON
121+
-DITK_WRAP_DOC:BOOL=ON \
122+
${CMAKE_OPTIONS}
122123
# Cleanup
123124
${Python3_EXECUTABLE} setup.py clean
124125

@@ -153,6 +154,7 @@ for VENV in "${VENVS[@]}"; do
153154
-DITK_WRAP_DOC:BOOL=ON \
154155
-DModule_ITKTBB:BOOL=ON \
155156
-DTBB_DIR:PATH=${tbb_dir} \
157+
${CMAKE_OPTIONS} \
156158
-G Ninja \
157159
${source_path} \
158160
&& ninja\
@@ -178,6 +180,7 @@ for VENV in "${VENVS[@]}"; do
178180
-DPython3_EXECUTABLE:FILEPATH=${Python3_EXECUTABLE} \
179181
-DPython3_INCLUDE_DIR:PATH=${Python3_INCLUDE_DIR} \
180182
-DITK_WRAP_DOC:BOOL=ON \
183+
${CMAKE_OPTIONS} \
181184
|| exit 1
182185
# Cleanup
183186
${Python3_EXECUTABLE} setup.py clean

0 commit comments

Comments
 (0)