Skip to content

Commit ca8f53f

Browse files
committed
Keep the caller's numpy when setting up the Core ML backend
backends/apple/coreml/scripts/install_requirements.sh clones coremltools and installs its reqs/build.pip before building the mlmodel library. That file pins numpy==2.0.0 for Python 3.9 to 3.12, so running the script silently downgrades numpy in the caller's environment. pandas 3.1.0 (released October 22, 2026) requires numpy>=2.0.2, so after the downgrade `import pandas` fails, and anything that imports the ExecuTorch devtools (for example examples/apple/coreml/scripts/export.py) breaks with "Please upgrade numpy to >= 2.0.2". Most Core ML jobs in CI hit this. The coremltools 9.0 CMake build only needs numpy (it asks numpy for its include path) and setuptools (it builds the bundled kmeans1d helper with setup.py). Install just those, unpinned, so an existing numpy is left alone. This also fixes a plain Python 3.12 venv, which has no setuptools: there the old script stopped at the CMake configure step. The comment next to COREMLTOOLS_VERSION now points at setup.py, where the coremltools pin lives, and asks to re-check this package list on a bump. Test plan: - Python 3.12 venv with numpy 2.4.6, pandas 3.1.0 and setuptools, script before and after this change. Before: mlmodel builds, numpy drops to 2.0.0, `import pandas` fails. After: mlmodel builds, numpy stays 2.4.6, `import pandas` works. - Brand new Python 3.12 venv with only pip, CMake 3.31: the script installs numpy and setuptools, builds mlmodel and copies the protobuf sources. - Configuring coremltools with only numpy fails at kmeans1d, and with only setuptools fails at the numpy include path, so both are needed.
1 parent d533adf commit ca8f53f

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

‎backends/apple/coreml/scripts/install_requirements.sh‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ SCRIPT_DIR_PATH="$(
1313
)"
1414

1515
# TODO(jathu): remove the need to fetch coremltools to build deps for coreml_executor_runner.
16-
# Keep this version in sync with: pyproject.toml
16+
# Keep this version in sync with setup.py, and re-check the pip install below when bumping it.
1717
COREMLTOOLS_VERSION="9.0"
1818

1919
# Safe colors (no TERM noise in CI)
@@ -75,12 +75,14 @@ if [[ "$(uname)" == "Darwin" ]]; then
7575
fi
7676

7777
echo "${green}ExecuTorch: Installing coremltools dependencies.${reset}"
78+
# Not coremltools' reqs/build.pip, whose old numpy pin would downgrade the caller's numpy.
79+
# Its CMake build only needs numpy (for the include path) and setuptools (to build kmeans1d).
7880
SDKROOT="$HOST_SDKROOT" \
7981
CC="$HOST_CC" \
8082
CXX="$HOST_CXX" \
8183
CFLAGS="$HOST_CFLAGS" \
8284
CXXFLAGS="$HOST_CXXFLAGS" \
83-
python -m pip install -r "$COREMLTOOLS_DIR_PATH/reqs/build.pip"
85+
python -m pip install numpy setuptools
8486
STATUS=$?
8587
if [ $STATUS -ne 0 ]; then
8688
echo "${red}ExecuTorch: Failed to install coremltools dependencies.${reset}"

0 commit comments

Comments
 (0)