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

[build] Use py_cc_toolchain for configuring pybind11 #22346

Merged
merged 1 commit into from
Jan 7, 2025

Conversation

jwnimmer-tri
Copy link
Collaborator

@jwnimmer-tri jwnimmer-tri commented Dec 22, 2024

The py_cc_toolchain is a rules_python concept that bridges the Python and C++ toolchains by providing cc_library targets for the headers and libraries that allow compiling C code against the Python interpreter selected by the Python toolchain.

This commit changes our MODULE and WORKSPACE to add that new kind of toolchain and our pydrake bindings to use it.

Towards #20731.


This change is Reviewable

Copy link
Contributor

@rpoyner-tri rpoyner-tri left a comment

Choose a reason for hiding this comment

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

+@rpoyner-tri :lgtm: feature

Reviewed 12 of 19 files at r6, 3 of 4 files at r7, 17 of 17 files at r8, all commit messages.
Reviewable status: 1 unresolved discussion, needs at least two assigned reviewers


tools/workspace/python/defs.bzl line 32 at r9 (raw file):

    toolchains = [_PY_CC_TOOLCHAIN_TYPE],
    provides = [CcInfo],
    doc = """Provides the linker flags for how to link a C/C++ exectuable

typo

Suggestion:

executable

The py_cc_toolchain is a rules_python concept that bridges the Python
and C++ toolchains by providing cc_library targets for the headers and
libraries for compiling C code against the Python interpreter selected
by the Python toolchain.

This commit changes our python repository to define that new kind of
toolchain and our pydrake bindings to use it. The toolchains are now
encapsulated as `@python//:all`, moved from `//tools/py_toolchain`.

Important note for future bzlmod users: because our python repository
rule can fail when run on a system without our default interpreter,
our MODULE.bazel will no longer register our default python toolchain
automatically. Downstream Bazel projects using Drake as a module will
need to opt-in to the local toolchain.

We provide new labels in //tools/workspace/python as a single point of
control for depending on Python. The comments in python/repository.bzl
provide an overview of how the pieces all fit together.

The legacy libraries `@python` and `@python//:python_direct_link` are
deprecated.
Copy link
Collaborator Author

@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 7 of 7 files at r1, 13 of 19 files at r3, 1 of 3 files at r4, 7 of 7 files at r5, 19 of 19 files at r6, 4 of 4 files at r7, 17 of 17 files at r8, 7 of 7 files at r10, all commit messages.
Reviewable status: needs at least two assigned reviewers

Copy link
Contributor

@rpoyner-tri rpoyner-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 7 of 7 files at r10, all commit messages.
Reviewable status: needs at least two assigned reviewers

@jwnimmer-tri
Copy link
Collaborator Author

+@ggould-tri for platform review per schedule, please.

Copy link
Contributor

@ggould-tri ggould-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:

Reviewed 12 of 19 files at r6, 3 of 4 files at r7, 17 of 17 files at r8, 7 of 7 files at r10, all commit messages.
Reviewable status: 1 unresolved discussion


tools/workspace/python/repository.bzl line 13 at r9 (raw file):

Anywhere in Drake that needs to *consume* the python toolchain information
should use the aliases provided by //tools/workspace/python which always cite
the current toolchain (which might not be Drake's toolchain in case a user

nit: this phrasing reads oddly to me. Reword?

Suggestion:

if

Copy link
Collaborator Author

@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: :shipit: complete! all discussions resolved, LGTM from assignees rpoyner-tri(platform),ggould-tri(platform)


tools/workspace/python/repository.bzl line 13 at r9 (raw file):

Previously, ggould-tri wrote…

nit: this phrasing reads oddly to me. Reword?

Meh. I like my phrasing slightly better.

@jwnimmer-tri jwnimmer-tri added the release notes: fix This pull request contains fixes (no new features) label Jan 7, 2025
@jwnimmer-tri jwnimmer-tri merged commit a1dec15 into RobotLocomotion:master Jan 7, 2025
10 checks passed
@jwnimmer-tri jwnimmer-tri deleted the repo-python branch January 7, 2025 21:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: medium release notes: fix This pull request contains fixes (no new features) release notes: newly deprecated This pull request contains new deprecations
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants