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.

This also means that we are installing a pinned numpy in the venv for
installations. This was already the case for source builds, but means we
now no longer have any reason to install numpy from Homebrew, so remove
it from there.
  • Loading branch information
mwoehlke-kitware committed Jan 20, 2025
1 parent 19da925 commit baea07a
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 20 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
1 change: 0 additions & 1 deletion setup/mac/binary_distribution/Brewfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ brew 'fmt'
brew 'glib'
brew 'graphviz'
brew 'ipopt'
brew 'numpy'
brew 'pkg-config'
brew '[email protected]'
brew 'spdlog'
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.

2 changes: 1 addition & 1 deletion setup/python/pdm.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions setup/python/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,11 @@ 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",
"notebook",
"numpy",
"Pillow",
"pydot",
"PyYAML",
Expand Down

0 comments on commit baea07a

Please sign in to comment.