Skip to content

Commit

Permalink
Modify install_prereqs to create a venv
Browse files Browse the repository at this point in the history
Modify the macOS install_prereqs script used for Drake tarball
installations to create a Python virtual environment in the location
where Drake has been extracted. Also use this to install Drake's Python
dependencies using PDM. Update user documentation accordingly.

This means we are now using the pinned versions of our dependencies and
are no longer keeping a duplicate copy of this list solely for
installations.
  • Loading branch information
mwoehlke-kitware committed Jan 20, 2025
1 parent 1025869 commit d6a5b74
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 18 deletions.
25 changes: 24 additions & 1 deletion doc/_pages/from_binary.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ Download the binary release ``*.tar.gz`` file, using one of the links above.
In the example below, we'll use ``drake.tar.gz`` to refer to it, but your
download will have a more version-specific filename.

#### Ubuntu

Create and activate the environment:

```bash
Expand All @@ -77,11 +79,32 @@ source env/bin/activate

Install dependencies within the environment:

```bash
sudo env/share/drake/setup/install_prereqs
````

Refer to [Quickstart](/installation.html#quickstart) for next steps.

#### macOS

Create the environment:

```bash
mkdir -p env
tar -xvzf drake.tar.gz -C env --strip-components=1
```

Install dependencies within the environment:

```bash
env/share/drake/setup/install_prereqs
````
(On Ubuntu, the script might ask to be run under ``sudo``.)
Activate the environment:
```bash
source env/bin/activate
```

Refer to [Quickstart](/installation.html#quickstart) for next steps.

Expand Down
6 changes: 4 additions & 2 deletions setup/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ package(default_visibility = ["//visibility:public"])
# downstream projects.
exports_files([
"mac/binary_distribution/Brewfile",
"mac/binary_distribution/requirements.txt",
"mac/source_distribution/Brewfile",
"mac/source_distribution/Brewfile-doc-only",
"mac/source_distribution/Brewfile-maintainer-only",
Expand Down Expand Up @@ -44,7 +43,9 @@ install_files(
"//tools/cc_toolchain:apple": [
"mac/binary_distribution/Brewfile",
"mac/binary_distribution/install_prereqs.sh",
"mac/binary_distribution/requirements.txt",
"python/pdm.lock",
"python/pyproject.toml",
"python/requirements.txt",
],
"//tools/cc_toolchain:linux": [
"deepnote/install_nginx",
Expand All @@ -58,6 +59,7 @@ install_files(
strip_prefix = [
"mac/binary_distribution",
"ubuntu/binary_distribution",
"python",
],
rename = {
"share/drake/setup/install_prereqs.sh": "install_prereqs",
Expand Down
7 changes: 6 additions & 1 deletion setup/mac/binary_distribution/install_prereqs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,10 @@ if ! command -v pip3.12 &>/dev/null; then
fi

if [[ "${with_python_dependencies}" -eq 1 ]]; then
pip3.12 install --break-system-packages -r "${BASH_SOURCE%/*}/requirements.txt"
readonly setup="${BASH_SOURCE%/*}"
readonly venv_root="$(cd "${setup}/../../.." && pwd)"
python3.12 -m venv "${venv_root}"
"${venv_root}/bin/pip3" install -U -r "${setup}/requirements.txt"
"${venv_root}/bin/pdm" use -p "${setup}" -f "${venv_root}"
"${venv_root}/bin/pdm" sync -p "${setup}" --prod
fi
11 changes: 0 additions & 11 deletions setup/mac/binary_distribution/requirements.txt

This file was deleted.

3 changes: 0 additions & 3 deletions setup/python/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ name = "drake"
requires-python = ">=3.10"

# Dependencies needed to build Drake.
#
# WARNING for Drake Developers: This list must be kept in sync with
# setup/mac/binary_distribution/requirements.txt.
dependencies = [
"ipywidgets",
"matplotlib",
Expand Down

0 comments on commit d6a5b74

Please sign in to comment.