Skip to content

[workspace] Update macOS to python@3.12#21013

Merged
svenevs merged 1 commit into
RobotLocomotion:masterfrom
MarcusSorealheis:fix/brew-python-3.12
Mar 6, 2024
Merged

[workspace] Update macOS to python@3.12#21013
svenevs merged 1 commit into
RobotLocomotion:masterfrom
MarcusSorealheis:fix/brew-python-3.12

Conversation

@MarcusSorealheis
Copy link
Copy Markdown
Contributor

@MarcusSorealheis MarcusSorealheis commented Feb 22, 2024

This PR Addresses the first task in this #20294 (switch Drake's default to 3.12)

If it looks ok and it lands, I can take on the external examples task as well. My company needs it for our project. The hope is to contribute more and more to Drake's maintenance and innovation over time since we benefit from it.


This change is Reviewable

@jwnimmer-tri jwnimmer-tri added the release notes: feature This pull request contains a new feature label Feb 22, 2024
@jwnimmer-tri
Copy link
Copy Markdown
Collaborator

Thanks @MarcusSorealheis!

+@BetsyMcPhail or +@svenevs or +@mwoehlke-kitware whoever has time, please sign up for feature review here (and un-assign the others).

+@jwnimmer-tri self-assigning for platform review.

Most of the work for this upgrade will be refreshing our CI machines, which will take some days.

@jwnimmer-tri
Copy link
Copy Markdown
Collaborator

@drake-jenkins-bot ok to test

@svenevs svenevs changed the title Switch Drake's Python to 3.12 [workspace] Update macOS to python@3.12 Feb 22, 2024
@svenevs
Copy link
Copy Markdown
Contributor

svenevs commented Feb 22, 2024

@MarcusSorealheis I did not do anything other than a quick pass, nominally things are looking good here!

Please compare with the diff in #18262 (our last macOS upgrade). You're missing some things in the wheel build. For the wheel files in particular, that one is an "unprovisioned build" meaning that the setup/ scripts you are changing in this PR will run. When you have new code changes pushed up matching the additional files in there, post a GitHub (not reviewable) comment that says

@drake-jenkins-bot mac-arm-ventura-unprovisioned-clang-wheel-experimental-release please.

Most of the work for this upgrade will be refreshing our CI machines, which will take some days.

Specifically, once we get the dust settled here, I'll be rebaking our "provisioned images" on the backend. Until that is done, the pre-merge check mac-arm-ventura-clang-bazel-experimental-release will continue to fail on this PR (which is expected! just letting you know).

Thanks for getting this started!


Edit: whoops! apparently doing it in a code-block, the bot still picked it up! The first wheel build is here, expected to fail at least in the testing phase.

Copy link
Copy Markdown
Contributor

@svenevs svenevs left a comment

Choose a reason for hiding this comment

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

-@BetsyMcPhail -@mwoehlke-kitware

Reviewable status: LGTM missing from assignees jwnimmer-tri(platform),svenevs

@svenevs
Copy link
Copy Markdown
Contributor

svenevs commented Feb 22, 2024

Also, re: wheel changes

python_targets = (
PythonTarget(3, 11),
PythonTarget(3, 12),
)

when referring to #18262 you will not have instruction on this part. The wheel gets built for both 3.11 and 3.12 right now, your PR should be changing this to just have 3.12 now:

 python_targets = ( 
     PythonTarget(3, 12), 
 ) 

Down the road, when 3.13 is out, we'll add it to the list there (but the drake default will remain 3.12 until the next homebrew switch)

Edit: or make it a list python_targets = [ brackets not parentheses ], that trailing comma should keep it as a tuple in python land though

@jwnimmer-tri
Copy link
Copy Markdown
Collaborator

@svenevs Actually can we keep building wheels for both 3.11 and 3.12 on macOS? It seems like it would be possible, and of great value to our users.

@svenevs
Copy link
Copy Markdown
Contributor

svenevs commented Feb 22, 2024

@jwnimmer-tri Yes, I think we could do that, in which case the change to python_targets should not be done here. However, I think it means we need to add python 3.11 to drake-ci explicitly (only) until we are in a place where we want to drop that. I think this is the first switch like this where keeping the older macOS wheel is even possible.

@jwnimmer-tri
Copy link
Copy Markdown
Collaborator

The wheel builder does subprocess.check_call(['brew', 'install', f'python@{t.version}']) already on its own, which makes me think that drake-ci don't need any extra install steps itself.

@svenevs
Copy link
Copy Markdown
Contributor

svenevs commented Feb 22, 2024

Ok, sorry for the confusion, #20616 changed things a lot more than I realized. We should discuss in f2f later today

@jwnimmer-tri
Copy link
Copy Markdown
Collaborator

@drake-jenkins-bot mac-arm-ventura-unprovisioned-clang-bazel-experimental-release please

@svenevs
Copy link
Copy Markdown
Contributor

svenevs commented Feb 22, 2024

Hi @MarcusSorealheis, it looks like we're going to need to solve #8392 and possibly some other bits of CI changes before we're going to be able to make progress on this. High level overview is homebrew disabled using pip to install directly into site-packages for python 3.12+, so we're going to concoct some kind of drake-specific likely virtualenv related change first.

Thanks for helping get this started so quickly (and therefore helping us identify the need to fix some other parts)!

@MarcusSorealheis
Copy link
Copy Markdown
Contributor Author

High level overview is homebrew disabled using pip to install directly into site-packages for python 3.12+, so we're going to concoct some kind of drake-specific likely virtualenv related change first.

Ah, that's a bummer but positive overall. I am happy to help with this in any way if you want or need. This project's vitality is very important to me. At a minimum, tonight I will get up to speed on that issue from 2018 and then test a few options out. If I get interesting data, I will share it as well. Thanks for being helpful.

@jwnimmer-tri
Copy link
Copy Markdown
Collaborator

Maybe we're overthinking this. Using a venv is absolutely the right long-term plan, but I wonder if just tacking on --user to all of the pip commands in our setup/mac/... scripts would solve the problem?

@MarcusSorealheis
Copy link
Copy Markdown
Contributor Author

Maybe we're overthinking this. Using a venv is absolutely the right long-term plan, but I wonder if just tacking on --user to all of the pip commands in our setup/mac/... scripts would solve the problem?

I'm investigating now, but I made the change. I need to run it on my Mac.

@MarcusSorealheis
Copy link
Copy Markdown
Contributor Author

I'll need to schedule some time to dig into this issue tomorrow if someone doesn't beat me to it. A cursory look into the logs here shows a problem I am not seeing on my local Mac, as far as I can tell. I am on a different version than the CI.

@jwnimmer-tri
Copy link
Copy Markdown
Collaborator

jwnimmer-tri commented Feb 26, 2024

Note that the build labeled as mac-arm-ventura-clang-bazel-experimental-release is not relevant for this pull request. That's running Python 3.11 using a pre-created, frozen image. It does not run the setup scripts. Before this PR merges, we will need to re-flash that image to use Python 3.12.

The build that runs the setup scripts is:

@drake-jenkins-bot mac-arm-ventura-unprovisioned-clang-bazel-experimental-release please

@MarcusSorealheis
Copy link
Copy Markdown
Contributor Author

Is there anything else to do here @jwnimmer-tri besides reflashing the images?

@jwnimmer-tri
Copy link
Copy Markdown
Collaborator

The build that we do need to be passing right now (mac-arm-ventura-unprovisioned-clang-bazel-experimental-release) did not pass. It looks at first glance like the --user flag wasn't a simple fix.

The bottom line is this: CI is just running setup scripts that we have in git. Our users will run the same scripts. Presumably, since they are failing in CI they will also fail for you when you run them on your local computer. Until install_prereqs runs successfully locally (and you can do a full Drake bazel test //... afterwards), CI is just going to tell you the same things you already know -- the code is not working yet.

@MarcusSorealheis
Copy link
Copy Markdown
Contributor Author

@drake-jenkins-bot mac-arm-ventura-unprovisioned-clang-bazel-experimental-release please

@MarcusSorealheis
Copy link
Copy Markdown
Contributor Author

@jwnimmer-tri I read the related PEP (0668) and also the updated canonical spec and it seems that the latest update in this branch, provided it passes, should work. It also feels very clear that we should move off of it soon, and I will be happy to lend a hand with the migration to venv, pipx, or whatever environment isolation library is chosen. I could even write up an update to the situation in the existing issue 8392 from 2018. An excerpt from the spec makes the urgency clear.

Packaging pipx in the distro avoids the irony of instructing users to pip install --user --break-system-packages pipx to avoid breaking system packages.

However, I do consider this PR a step forward and something that should happen prior to virtualization.

Copy link
Copy Markdown
Contributor

@svenevs svenevs 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: 1 unresolved discussion, LGTM missing from assignee svenevs, commits need curation (https://drake.mit.edu/reviewable.html#curated-commits) (waiting on @MarcusSorealheis)


tools/workspace/styleguide/repository.bzl line 11 at r6 (raw file):

Previously, svenevs (Stephen McDowell) wrote…

working, new PR in bound

@MarcusSorealheis FYI I had to rebase and force-push here, your local branch will be out of sync with what's on your fork's branch

Step 1 is up: RobotLocomotion/styleguide#54

@jwnimmer-tri I cannot assign reviewers there, please assign yourself if you have bandwidth. Otherwise I'll request on slack.

@svenevs
Copy link
Copy Markdown
Contributor

svenevs commented Mar 1, 2024

@drake-jenkins-bot mac-arm-ventura-unprovisioned-clang-bazel-experimental-release please

this one may actually pass!

Copy link
Copy Markdown
Contributor

@svenevs svenevs 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 svenevs, commits need curation (https://drake.mit.edu/reviewable.html#curated-commits) (waiting on @MarcusSorealheis)


tools/jupyter/test/jupyter_notebook_test.py line 10 at r7 (raw file):

        """Ensures that `jupyter notebook` is installed (#12042)."""
        status = subprocess.call(
            args=[sys.executable, "-m", "notebook", "--help"])

working, waiting on test results, from commit message

  1. We appear to be installing the wrong PyPI package!

should be what we want now

Copy link
Copy Markdown
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 svenevs, commits need curation (https://drake.mit.edu/reviewable.html#curated-commits) (waiting on @MarcusSorealheis)


setup/mac/source_distribution/requirements-test-only.txt line 2 at r7 (raw file):

flask
notebook

nit This one is already in the binary prereqs requirements.txt. So if this is really the one we want, then we can just drop this line.

It's fine to just fix that in the separate, ahead-of-time PR where we land this patch on its own, on master.

Copy link
Copy Markdown
Contributor

@svenevs svenevs 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 svenevs, commits need curation (https://drake.mit.edu/reviewable.html#curated-commits) (waiting on @MarcusSorealheis)


setup/mac/source_distribution/requirements-test-only.txt line 2 at r7 (raw file):

Previously, jwnimmer-tri (Jeremy Nimmer) wrote…

nit This one is already in the binary prereqs requirements.txt. So if this is really the one we want, then we can just drop this line.

It's fine to just fix that in the separate, ahead-of-time PR where we land this patch on its own, on master.

gah! right you are... is there any reason that this PR cannot simply remove it?

Copy link
Copy Markdown
Contributor Author

@MarcusSorealheis MarcusSorealheis left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 6 of 8 files at r1, 1 of 2 files at r3, 1 of 1 files at r4.
Reviewable status: 3 unresolved discussions, LGTM missing from assignee svenevs, commits need curation (https://drake.mit.edu/reviewable.html#curated-commits)

Copy link
Copy Markdown
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 svenevs, commits need curation (https://drake.mit.edu/reviewable.html#curated-commits) (waiting on @MarcusSorealheis)


setup/mac/source_distribution/requirements-test-only.txt line 2 at r7 (raw file):

Previously, svenevs (Stephen McDowell) wrote…

gah! right you are... is there any reason that this PR cannot simply remove it?

I want to land all of the "be compatible with python 3.12" as separate PRs ahead of time. The "switch from 3.11 to 3.12" should only be switching, not any fixing. That keeps the concerns separated, and makes revert wars and git history easier to work with.

Copy link
Copy Markdown
Contributor

@svenevs svenevs 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 svenevs, commits need curation (https://drake.mit.edu/reviewable.html#curated-commits) (waiting on @MarcusSorealheis)


setup/mac/source_distribution/requirements-test-only.txt line 2 at r7 (raw file):

Previously, jwnimmer-tri (Jeremy Nimmer) wrote…

I want to land all of the "be compatible with python 3.12" as separate PRs ahead of time. The "switch from 3.11 to 3.12" should only be switching, not any fixing. That keeps the concerns separated, and makes revert wars and git history easier to work with.

Good plan, future us will be thankful 😉 => #21085

@svenevs svenevs force-pushed the fix/brew-python-3.12 branch from 28f2155 to a7537b9 Compare March 1, 2024 23:09
Copy link
Copy Markdown
Contributor

@svenevs svenevs left a comment

Choose a reason for hiding this comment

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

I went ahead and cancelled the CI here, looks like we're one rebase away 😎 (jupyter fix)

Reviewed 3 of 3 files at r8, all commit messages.
Reviewable status: 1 unresolved discussion, LGTM missing from assignee svenevs


tools/jupyter/test/jupyter_notebook_test.py line 10 at r7 (raw file):

Previously, svenevs (Stephen McDowell) wrote…

working, waiting on test results, from commit message

  1. We appear to be installing the wrong PyPI package!

should be what we want now

working, thread block until #21085 lands and can rebase here.


tools/workspace/styleguide/repository.bzl line 11 at r6 (raw file):

Previously, svenevs (Stephen McDowell) wrote…

Step 1 is up: RobotLocomotion/styleguide#54

@jwnimmer-tri I cannot assign reviewers there, please assign yourself if you have bandwidth. Otherwise I'll request on slack.

done, styleguide rebase is in here now

@svenevs svenevs force-pushed the fix/brew-python-3.12 branch from a7537b9 to 8080b24 Compare March 1, 2024 23:48
@svenevs
Copy link
Copy Markdown
Contributor

svenevs commented Mar 1, 2024

@drake-jenkins-bot linux-jammy-unprovisioned-clang-bazel-experimental-debug please
@drake-jenkins-bot linux-jammy-unprovisioned-clang-bazel-experimental-everything-debug please
@drake-jenkins-bot linux-jammy-unprovisioned-clang-bazel-experimental-everything-release please
@drake-jenkins-bot linux-jammy-unprovisioned-clang-bazel-experimental-release please
@drake-jenkins-bot linux-jammy-unprovisioned-gcc-bazel-experimental-debug please
@drake-jenkins-bot linux-jammy-unprovisioned-gcc-bazel-experimental-documentation please
@drake-jenkins-bot linux-jammy-unprovisioned-gcc-bazel-experimental-documentation please
@drake-jenkins-bot linux-jammy-unprovisioned-gcc-bazel-experimental-everything-debug please
@drake-jenkins-bot linux-jammy-unprovisioned-gcc-bazel-experimental-everything-release please
@drake-jenkins-bot linux-jammy-unprovisioned-gcc-bazel-experimental-mirror-to-s3 please
@drake-jenkins-bot linux-jammy-unprovisioned-gcc-bazel-experimental-packaging please
@drake-jenkins-bot linux-jammy-unprovisioned-gcc-bazel-experimental-packaging please
@drake-jenkins-bot linux-jammy-unprovisioned-gcc-bazel-experimental-release please
@drake-jenkins-bot linux-jammy-unprovisioned-gcc-bazel-experimental-release please
@drake-jenkins-bot linux-jammy-unprovisioned-gcc-cmake-experimental-debug please
@drake-jenkins-bot linux-jammy-unprovisioned-gcc-cmake-experimental-everything-debug please
@drake-jenkins-bot linux-jammy-unprovisioned-gcc-cmake-experimental-everything-release please
@drake-jenkins-bot linux-jammy-unprovisioned-gcc-cmake-experimental-release please
@drake-jenkins-bot linux-jammy-unprovisioned-gcc-wheel-experimental-release please
@drake-jenkins-bot mac-arm-sonoma-unprovisioned-clang-bazel-experimental-release please
@drake-jenkins-bot mac-arm-ventura-unprovisioned-clang-bazel-experimental-packaging please
@drake-jenkins-bot mac-arm-ventura-unprovisioned-clang-bazel-experimental-release please
@drake-jenkins-bot mac-arm-ventura-unprovisioned-clang-wheel-experimental-release please
@drake-jenkins-bot mac-x86-monterey-unprovisioned-clang-bazel-experimental-packaging please
@drake-jenkins-bot mac-x86-monterey-unprovisioned-clang-bazel-experimental-release please
@drake-jenkins-bot mac-x86-monterey-unprovisioned-clang-wheel-experimental-release please

Copy link
Copy Markdown
Contributor

@svenevs svenevs left a comment

Choose a reason for hiding this comment

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

:lgtm_strong: pending ci

Reviewed 3 of 3 files at r9, all commit messages.
Reviewable status: :shipit: complete! all discussions resolved, LGTM from assignees jwnimmer-tri(platform),svenevs


tools/jupyter/test/jupyter_notebook_test.py line 10 at r7 (raw file):

Previously, svenevs (Stephen McDowell) wrote…

working, thread block until #21085 lands and can rebase here.

done, after diagnosing, we realized the problem was pip install --user. Removing that, we have the jupyter command available and a small cruft removal of an unrelated jupyter python package 🙃

Copy link
Copy Markdown
Contributor

@svenevs svenevs left a comment

Choose a reason for hiding this comment

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

:lgtm_cancel: sorry, we don't want this to merge even if CI passes ... removing feature stamp 😉

Reviewable status: LGTM missing from assignee svenevs

Copy link
Copy Markdown
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 1 of 1 files at r5, 2 of 3 files at r8, 3 of 3 files at r9, all commit messages.
Reviewable status: LGTM missing from assignee svenevs

@MarcusSorealheis
Copy link
Copy Markdown
Contributor Author

Thanks everyone for all the help here. A lot of big projects lose the vitality that the cutting edge ecosystem offers because they do not upgrade Python regularly. What a journey.

@MarcusSorealheis
Copy link
Copy Markdown
Contributor Author

Is the next bit of work here @jwnimmer-tri to flash the images? In that case, I would assume the PR will be on pause until then.

@jwnimmer-tri
Copy link
Copy Markdown
Collaborator

Yup. The kitware folks need to prepare and deploy the Provisioned images, at which point we can concurrently merge this PR and switch Provisioned CI to use those image.

Copy link
Copy Markdown
Contributor

@svenevs svenevs left a comment

Choose a reason for hiding this comment

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

:lgtm_strong:

Reviewable status: :shipit: complete! all discussions resolved, LGTM from assignees jwnimmer-tri(platform),svenevs

@svenevs svenevs merged commit 4c8126c into RobotLocomotion:master Mar 6, 2024
@svenevs
Copy link
Copy Markdown
Contributor

svenevs commented Mar 6, 2024

A lot of big projects lose the vitality that the cutting edge ecosystem offers because they do not upgrade Python regularly. What a journey.

You'll have to blame @jwnimmer-tri 🙂 Drake evolves quickly, while at the same time maintaining stability. That's a hard balance!

jwnimmer-tri pushed a commit to jwnimmer-tri/drake that referenced this pull request Apr 1, 2024
@MarcusSorealheis
Copy link
Copy Markdown
Contributor Author

I've added a PR to stop breaking system Python packages, which was introduced by this PR: #21269

RussTedrake pushed a commit to RussTedrake/drake that referenced this pull request Dec 15, 2024
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

Development

Successfully merging this pull request may close these issues.

5 participants