CMake: Python install fails on externally managed environment (macOS Homebrew)
elliottslaughter opened this issue · 0 comments
elliottslaughter commented
I'm not sure how broadly applicable this is, but I'm creating an issue in case it becomes a blocker for other users.
When we use CMake to install Python bindings, the build internally runs pip install
to install the bindings themselves. On certain versions of Python, this appears to fail with:
'.../.brew/Frameworks/Python.framework/Versions/3.12/bin/python3.12' '-m' 'pip' 'install' '--global-option=--cmake-build-dir' '--global-option=.../legion/build/runtime' '--global-option=--prefix' '--global-option=.../legion/install' '--ignore-installed' '.'
error: externally-managed-environment
× This environment is externally managed
╰─> To install Python packages system-wide, try brew install
xyz, where xyz is the package you are trying to
install.
If you wish to install a non-brew-packaged Python package,
create a virtual environment using python3 -m venv path/to/venv.
Then use path/to/venv/bin/python and path/to/venv/bin/pip.
If you wish to install a non-brew packaged Python application,
it may be easiest to use pipx install xyz, which will manage a
virtual environment for you. Make sure you have pipx installed.
note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
hint: See PEP 668 for the detailed specification.
Note: it looks like CMake auto-detected Python from Homebrew even though python3
on PATH
is the system installation. But that's something for another time.
The result is that Python files do not get installed at all, and therefore are unusable.
Repro steps:
mkdir build
cd build
cmake -DLegion_USE_Python=ON -DLegion_BUILD_BINDINGS=ON -DBUILD_SHARED_LIBS=ON -DCMAKE_CXX_STANDARD=11 -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=$PWD/../install ..
make install -j4
Running macOS 14 with Homebrew Python 3.12 (note: not first on PATH
!).