Repository navigation
fix: Use purl.bzl for a better api, add module package_metadata #4276
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
Open
darkrift
wants to merge
16
commits into
bazel-contrib:main
Choose a base branch
from
darkrift:use_purl_builder
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+206
−43
Open
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
b6111d1
Use purl.bzl for a better api, add module package_metadata
darkrift da86260
Address copilot review
darkrift 656063a
fix tests
darkrift 8cac3e5
Merge branch 'main' into use_purl_builder
darkrift 305de36
Merge upstream/main into use_purl_builder
darkrift 6e685d3
Merge remote-tracking branch 'origin/use_purl_builder' into use_purl_…
darkrift 2dc9eee
Limit PR to package_metadata bump and purl builder
darkrift e6b274c
Merge upstream/main into use_purl_builder
darkrift 56995fe
fix(workspace): define package_metadata before loads that need purl.bzl
darkrift 6d7d751
Restore package_metadata for rules_python and mark as breaking for WO…
darkrift 8c66414
Restore upstream changes dropped by previous commit
darkrift 2abbac2
refactor(pypi): build the whl purl in the generated BUILD file
aignas 24fbee2
Merge remote-tracking branch 'upstream/main' into HEAD
aignas 0282901
test(pypi): add tests for whl_package_metadata
aignas efe7f0c
Merge branch 'main' into use_purl_builder
darkrift 4b40dc4
Merge branch 'main' into use_purl_builder
aignas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| """File declaring metadata applying to all packages and targets in the Bazel module.""" | ||
|
|
||
| repo( | ||
| default_package_metadata = [ | ||
| "//:package_metadata", | ||
| ], | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| (workspace) **BREAKING** `rules_python` now requires `package_metadata` 0.0.13 | ||
| or newer. WORKSPACE users who define `@package_metadata` themselves (e.g. via | ||
| another dependency) must update it, e.g. with an `http_archive` of | ||
| `package_metadata-0.0.13` (`strip_prefix = "package_metadata-0.0.13/metadata"`). | ||
| ([#4276](https://github.com/bazel-contrib/rules_python/pull/4276)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| """The package metadata for the whl repositories. | ||
|
|
||
| This is loaded only by the generated `BUILD.bazel` files of the whl | ||
| repositories, so that the `@package_metadata` repository is not needed when | ||
| loading the repository rules, e.g. in `WORKSPACE`. | ||
| """ | ||
|
|
||
| load("@package_metadata//purl:purl.bzl", "purl") | ||
| load("@package_metadata//rules:package_metadata.bzl", "package_metadata") | ||
|
|
||
| def whl_package_metadata( | ||
| *, | ||
| distribution, | ||
| version, | ||
| repository_url = None, | ||
| file_name = None, | ||
| name = "package_metadata"): | ||
| """Create the `package_metadata` target with a PyPI PURL. | ||
|
|
||
| See https://github.com/package-url/purl-spec/blob/main/types-doc/pypi-definition.md | ||
|
|
||
| Args: | ||
| distribution: {type}`str` the normalized name of the distribution. | ||
| version: {type}`str` the version of the package. | ||
| repository_url: {type}`str | None` the index URL. | ||
| file_name: {type}`str | None` the name of the whl or sdist file. | ||
| name: {type}`str` the name of the target. | ||
| """ | ||
| builder = purl.builder().type("pypi").name(distribution).version(version) | ||
| if repository_url: | ||
| builder.add_qualifier("repository_url", repository_url) | ||
| if file_name: | ||
| builder.add_qualifier("file_name", file_name) | ||
|
|
||
| package_metadata( | ||
| name = name, | ||
| purl = builder.build(), | ||
| visibility = ["//:__subpackages__"], | ||
| ) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| load(":whl_package_metadata_tests.bzl", "whl_package_metadata_test_suite") | ||
|
|
||
| whl_package_metadata_test_suite( | ||
| name = "whl_package_metadata_tests", | ||
| ) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.