Skip to content

fix: Use purl.bzl for a better api, add module package_metadata - #4276

Open
darkrift wants to merge 9 commits into
bazel-contrib:mainfrom
darkrift:use_purl_builder
Open

darkrift wants to merge 9 commits into
bazel-contrib:mainfrom
darkrift:use_purl_builder

Conversation

@darkrift

@darkrift darkrift commented Oct 17, 2026 •

Copy link
Copy Markdown

Following the bazelcon talk on supply chain to track every bytes, this declares the module package metadata and switch to the purl builder which also takes care of encoding the various fields of the purl.

Copilot AI balanced review requested due to automatic review settings October 17, 2026 03:50

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

WORKSPACE compatibility regressions and the outdated integration lockfile need to be fixed.

3 open issues
What changed in this PR

Adds module-wide package metadata to rules_python and uses the PURL builder to encode wheel package URLs correctly.

Changes:

  • Declares module identity and Apache-2.0 license metadata.
  • Replaces manual wheel PURL formatting with the builder API.
  • Upgrades package_metadata and adds the builder dependency.
File Description
REPO.bazel Applies package metadata module-wide.
python/​private/​pypi/​patch_and_extract_whl.bzl Builds wheel PURLs with encoded fields.
python/​private/​pypi/​BUILD.bazel Declares the PURL library dependency.
MODULE.bazel Upgrades package_metadata to 0.0.13.
BUILD.bazel Defines module and license metadata.

Review effort: Balanced

Comment thread BUILD.bazel Outdated
":license",
],
purl = purl.bazel(
module_name(),
name = normalize_name(metadata.name).replace("_", "-")

qualifiers = {}
builder = purl.builder().type("pypi").name(name).version(metadata.version)
Comment thread MODULE.bazel Resolved
@darkrift
darkrift force-pushed the use_purl_builder branch 2 times, most recently from 5c2446a to 687c853 Compare October 17, 2026 12:14

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Integration fixtures omit the new repository configuration and license file, leaving the metadata defaults untested.

4 open issues

Review effort: Balanced

Comment thread REPO.bazel Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@aignas aignas left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I love the new additions here, but I am concerned that this may break builds for every workspace user. Whilst I don't want this to be always a blocking concern, I'd like to think twice before merging this.

Comment thread WORKSPACE Outdated
# Everything below this line is used only for developing rules_python. Users
# should not copy it to their WORKSPACE.

# REPO.bazel's default_package_metadata makes every package in this repo depend

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This is somewhat alarming, that means that WORKSPACE users will face a breaking change.

@darkrift darkrift Oct 29, 2026 •

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

We could split it in 2 PRs then, update package_metadata for the PURL builder, and another for the rules_python itself package_metadata tagging (which is the one breaking WORKSPACE)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

That said, many ruleset has already decided to drop support for Bazel 7 and WORKSPACE altogether.

How long is rules_python expected to keep WORKSPACE support ?

@aignas aignas Oct 30, 2026 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@rickeylev, I think dropping WORKSPACE will happen when the protobuf ruleset drops it? I remember him saying that it is going to be another year?. I personally think that we could do the change separately as a breaking change to WORKSPACE users with migration instructions.

As I said in the main comment, a breaking change to WORKSPACE is not a reason to block this PR merge, but we should have instructions in the CHANGELOG for users to migrate.

If I understood correctly previous change would not have dropped WORKSPACE entirely, right?

darkrift and others added 3 commits October 29, 2026 13:37
Move the REPO.bazel default package metadata and the rules_python
package_metadata/license targets out of this change.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@darkrift

Copy link
Copy Markdown
Author

@aignas I removed the change that would drop WORKSPACE support, I'll add it in another PR

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues are reported for the package URL builder migration and related dependency updates.

2 open issues
2 resolved since last review

Review effort: Balanced

Comment thread WORKSPACE
Comment on lines +20 to +21
# Loaded by Starlark files (e.g. purl.bzl) that the loads below pull in, so it
# must be defined before them.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

do we still need this comment and change?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Yes, otherwise it still breaks WORKSPACE based tests because of the wrong order of loads

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

If that is the case it may still be a breaking change, let's bring back the other change that got reverted and just mark this as breaking for workspace users and add a snippet for WORKSPACE user that they would need to unbreak their setups.

WORKSPACE setup is best effort afterall.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants