Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify install_prereqs to create a venv #22477

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mwoehlke-kitware
Copy link
Contributor

@mwoehlke-kitware mwoehlke-kitware commented Jan 16, 2025

Modify the install_prereqs script used for Drake tarball installations to create a Python virtual environment in the location where Drake has been extracted. On macOS, also use this to install Drake's Python dependencies using PDM. Update user documentation accordingly.

The changes for Ubuntu are mainly to preserve consistency. For macOS, this change 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.

Towards #22040.


This change is Reviewable

@mwoehlke-kitware
Copy link
Contributor Author

@drake-jenkins-bot mac-arm-sonoma-unprovisioned-clang-cmake-experimental-packaging please.

@mwoehlke-kitware
Copy link
Contributor Author

BTW, I'm not sure if this should get release notes or not. That Drake now expects to create its own venv might be a "gotcha" for existing users.

@jwnimmer-tri jwnimmer-tri added the release notes: feature This pull request contains a new feature label Jan 17, 2025
@mwoehlke-kitware
Copy link
Contributor Author

@drake-jenkins-bot mac-arm-sonoma-unprovisioned-clang-cmake-experimental-packaging please.

@mwoehlke-kitware
Copy link
Contributor Author

@drake-jenkins-bot mac-arm-sonoma-unprovisioned-clang-cmake-experimental-packaging please.

@mwoehlke-kitware
Copy link
Contributor Author

+@jwnimmer-tri for feature review, please

Copy link
Collaborator

@jwnimmer-tri jwnimmer-tri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM on paper -- just one question in a new top-level thread below ...

Reviewed 2 of 7 files at r1, 3 of 3 files at r2, 2 of 2 files at r3, all commit messages.
Reviewable status: 3 unresolved discussions, LGTM missing from assignee jwnimmer-tri(platform), needs at least two assigned reviewers


a discussion (no related file):
Has this been tested against DEE CI? I didn't see any.

It's probably worth opening a DEE PR that changes this line to point to the experimental tgz published from this pull request, and make sure everything is still happy.


setup/mac/binary_distribution/install_prereqs.sh line 64 at r3 (raw file):

brew bundle --file="${BASH_SOURCE%/*}/Brewfile" --no-lock

if ! command -v pip3.12 &>/dev/null; then

BTW Is this still the best condition to check for? Does PDM call pip3.12 under the hood, or just do its own thing?


setup/BUILD.bazel line 10 at r3 (raw file):

exports_files([
    "mac/binary_distribution/Brewfile",
    "mac/binary_distribution/requirements.txt",

nit This line seems stale now?

Copy link
Collaborator

@jwnimmer-tri jwnimmer-tri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 4 unresolved discussions, LGTM missing from assignee jwnimmer-tri(platform), needs at least two assigned reviewers


a discussion (no related file):
Note that #22040 task (2) is still unfinished in this PR. I find it slightly suspicious to mix a PDM lockfile with a Homebrew version of numpy. I would imagine that their versions are not always strictly compatible? Or maybe the homebrew numpy is dead code now, if the venv sys.patch excludes it?

Copy link
Collaborator

@jwnimmer-tri jwnimmer-tri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 5 unresolved discussions, LGTM missing from assignee jwnimmer-tri(platform), needs at least two assigned reviewers


a discussion (no related file):
I would like to land #22503 ahead of this PR. I don't trust our testing here when the PDM dependencies are unpinned but still installed into the same venv as Drake's dependencies.

Copy link
Contributor Author

@mwoehlke-kitware mwoehlke-kitware left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 4 unresolved discussions, LGTM missing from assignee jwnimmer-tri(platform), needs at least two assigned reviewers


setup/BUILD.bazel line 10 at r3 (raw file):

Previously, jwnimmer-tri (Jeremy Nimmer) wrote…

nit This line seems stale now?

Probably. Done.


setup/mac/binary_distribution/install_prereqs.sh line 64 at r3 (raw file):

Previously, jwnimmer-tri (Jeremy Nimmer) wrote…

BTW Is this still the best condition to check for? Does PDM call pip3.12 under the hood, or just do its own thing?

This is the check for "did brew correctly install Python?". I suppose we could just check for python3.12 instead, but since we need python3.12 -m venv to give us pip3, checking that pip already exists doesn't seem unreasonable. (But I'll entertain arguments either way.)

Checking for pdm at this point isn't right, because we haven't installed it yet! And, while I don't know if PDM uses pip under the hood, we do use pip to install pdm itself.

TL;DR: We're still about to call pip, we've just changed from <brew>/pip3.12 to <venv>/pip3.

Copy link
Collaborator

@jwnimmer-tri jwnimmer-tri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 3 of 3 files at r4, all commit messages.
Reviewable status: 3 unresolved discussions, LGTM missing from assignee jwnimmer-tri(platform), needs at least two assigned reviewers


setup/mac/binary_distribution/install_prereqs.sh line 64 at r3 (raw file):

... we do use pip to install pdm itself.

Aha, this is definitely a good reason. I hadn't connected those dots, but I probably should have. No changes necessary.

Copy link
Collaborator

@jwnimmer-tri jwnimmer-tri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 3 unresolved discussions, LGTM missing from assignee jwnimmer-tri(platform), needs at least two assigned reviewers


a discussion (no related file):

Previously, jwnimmer-tri (Jeremy Nimmer) wrote…

Note that #22040 task (2) is still unfinished in this PR. I find it slightly suspicious to mix a PDM lockfile with a Homebrew version of numpy. I would imagine that their versions are not always strictly compatible? Or maybe the homebrew numpy is dead code now, if the venv sys.patch excludes it?

(Oops, I meant to say "if the venv sys.path excludes it".)

Copy link
Contributor Author

@mwoehlke-kitware mwoehlke-kitware left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 3 unresolved discussions, LGTM missing from assignee jwnimmer-tri(platform), needs at least two assigned reviewers


a discussion (no related file):

Previously, jwnimmer-tri (Jeremy Nimmer) wrote…

(Oops, I meant to say "if the venv sys.path excludes it".)

That's an interesting question. pdm.lock pins numpy and it looks like it's being installed by the venv in practice. Do we still need numpy from Brew? Maybe we should PR its removal first?

I believe we've been installing it via the venv since pip-tools; at least, I see it was already in the pip-tools lock files. I didn't realize we were also installing it via brew.


a discussion (no related file):

Previously, jwnimmer-tri (Jeremy Nimmer) wrote…

I would like to land #22503 ahead of this PR. I don't trust our testing here when the PDM dependencies are unpinned but still installed into the same venv as Drake's dependencies.

WFM.

Copy link
Collaborator

@jwnimmer-tri jwnimmer-tri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 3 unresolved discussions, LGTM missing from assignee jwnimmer-tri(platform), needs at least two assigned reviewers


a discussion (no related file):
We definitely need a usable numpy, the only question is where it comes from.

Maybe we should PR its removal first?

We can't do it first, because then otherwise it would be missing for tgz users. (We can't install it system-wide under --break-system-packages.)

It seems to me like it would be safest to remove it in this PR, instead of a future one?

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.
Copy link
Collaborator

@jwnimmer-tri jwnimmer-tri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 2 unresolved discussions, LGTM missing from assignee jwnimmer-tri(platform), needs at least two assigned reviewers


a discussion (no related file):

Previously, mwoehlke-kitware (Matthew Woehlke) wrote…

WFM.

Done.

Copy link
Contributor Author

@mwoehlke-kitware mwoehlke-kitware left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 2 unresolved discussions, LGTM missing from assignee jwnimmer-tri(platform), needs at least two assigned reviewers


a discussion (no related file):

Previously, jwnimmer-tri (Jeremy Nimmer) wrote…

We definitely need a usable numpy, the only question is where it comes from.

Maybe we should PR its removal first?

We can't do it first, because then otherwise it would be missing for tgz users. (We can't install it system-wide under --break-system-packages.)

It seems to me like it would be safest to remove it in this PR, instead of a future one?

Makes sense. Done.

@mwoehlke-kitware
Copy link
Contributor Author

@drake-jenkins-bot mac-arm-sonoma-unprovisioned-clang-cmake-experimental-packaging please.

Copy link
Collaborator

@jwnimmer-tri jwnimmer-tri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 3 of 3 files at r5, all commit messages.
Reviewable status: 1 unresolved discussion, LGTM missing from assignee jwnimmer-tri(platform), needs at least two assigned reviewers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release notes: feature This pull request contains a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants