From f0bfb8bb39ed68a717fc384bc1c54a64ed989651 Mon Sep 17 00:00:00 2001 From: Marcus Date: Fri, 5 Apr 2024 08:36:15 -0400 Subject: [PATCH] Create a virtual environment for Drake Python deps. --- setup/mac/binary_distribution/install_prereqs.sh | 7 ++++++- setup/mac/source_distribution/install_prereqs.sh | 9 +++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/setup/mac/binary_distribution/install_prereqs.sh b/setup/mac/binary_distribution/install_prereqs.sh index 0da4fe6ac1cb..19b0ac7ac562 100755 --- a/setup/mac/binary_distribution/install_prereqs.sh +++ b/setup/mac/binary_distribution/install_prereqs.sh @@ -67,4 +67,9 @@ if ! command -v pip3.12 &>/dev/null; then exit 2 fi -pip3.12 install --break-system-packages -r "${BASH_SOURCE%/*}/requirements.txt" +# Create a virtual environment to isolate the Drake Python depdendency tree +# from the system Python so we don't need to include --break-system-packages. +# For more info, read https://github.com/RobotLocomotion/drake/pull/21013#issuecomment-1970181733. +python3.12 -m venv "${HOME}/.drake_venv" +source "${HOME}/.drake_venv/bin/activate" +pip3.12 install -r "${BASH_SOURCE%/*}/requirements.txt" diff --git a/setup/mac/source_distribution/install_prereqs.sh b/setup/mac/source_distribution/install_prereqs.sh index b91f4845c40b..c401711b5326 100755 --- a/setup/mac/source_distribution/install_prereqs.sh +++ b/setup/mac/source_distribution/install_prereqs.sh @@ -54,8 +54,13 @@ if ! command -v pip3.12 &>/dev/null; then exit 2 fi -pip3.12 install --break-system-packages -r "${BASH_SOURCE%/*}/requirements.txt" +# Create a virtual environment to isolate the Drake Python depdendency tree +# from the system Python so we don't need to include --break-system-packages. +# For more info, https://github.com/RobotLocomotion/drake/pull/21013#issuecomment-1970181733. +python3.12 -m venv "${HOME}/.drake_venv" +source "${HOME}/.drake_venv/bin/activate" +pip3.12 install -r "${BASH_SOURCE%/*}/requirements.txt" if [[ "${with_test_only}" -eq 1 ]]; then - pip3.12 install --break-system-packages -r "${BASH_SOURCE%/*}/requirements-test-only.txt" + pip3.12 install -r "${BASH_SOURCE%/*}/requirements-test-only.txt" fi