forked from InsightSoftwareConsortium/ITKPythonPackage
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmacpython-build-common.sh
More file actions
79 lines (69 loc) · 2.11 KB
/
Copy pathmacpython-build-common.sh
File metadata and controls
79 lines (69 loc) · 2.11 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
# Content common to macpython-build-wheels.sh and
# macpython-build-module-wheels.sh
set -e -x
SCRIPT_DIR=$(cd $(dirname $0) || exit 1; pwd)
MACPYTHON_PY_PREFIX=/Library/Frameworks/Python.framework/Versions
# -----------------------------------------------------------------------
# Script argument parsing
#
usage()
{
echo "Usage:
macpython-build-common
[ -h | --help ] show usage
[ -c | --cmake_options ] space-separated string of CMake options to forward to the module (e.g. \"--config-setting=cmake.define.BUILD_TESTING=OFF\")
[ -- python_versions ] build wheel for a specific python version(s). (e.g. -- 3.10 3.11)"
exit 2
}
PYTHON_VERSIONS=""
CMAKE_OPTIONS=""
while (( "$#" )); do
case "$1" in
-c|--cmake_options)
CMAKE_OPTIONS="$2";
shift 2;;
-h|--help)
usage;
break;;
--)
shift;
break;;
*)
# Parse any unrecognized arguments as python versions
PYTHON_VERSIONS="${PYTHON_VERSIONS} $1";
shift;;
esac
done
# Parse all arguments after "--" as python versions
PYTHON_VERSIONS="${PYTHON_VERSIONS} $@"
# Trim whitespace
PYTHON_VERSIONS=$(xargs <<< "${PYTHON_VERSIONS}")
# Versions can be restricted by passing them in as arguments to the script
# For example,
# macpython-build-wheels.sh 3.10
if [[ -z "${PYTHON_VERSIONS}" ]]; then
PYBINARIES=(${MACPYTHON_PY_PREFIX}/*)
else
PYBINARIES=()
for version in "$PYTHON_VERSIONS"; do
PYBINARIES+=(${MACPYTHON_PY_PREFIX}/*${version}*)
done
fi
VENVS=()
mkdir -p ${SCRIPT_DIR}/../venvs
for PYBIN in "${PYBINARIES[@]}"; do
if [[ $(basename $PYBIN) = "Current" ]]; then
continue
fi
py_mm=$(basename ${PYBIN})
VENV=${SCRIPT_DIR}/../venvs/${py_mm}
VENVS+=(${VENV})
done
# -----------------------------------------------------------------------
# Ensure that requirements are met
brew update
brew info doxygen | grep --quiet 'Not installed' && brew install doxygen
brew info ninja | grep --quiet 'Not installed' && brew install ninja
NINJA_EXECUTABLE=$(which ninja)
brew info cmake | grep --quiet 'Not installed' && brew install cmake
CMAKE_EXECUTABLE=$(which cmake)