feat: add package metadata for wheel libraries by stevebarrau · Pull Request #3531 · bazel-contrib/rules_python

@stevebarrau

Add package_metadata rule to generated BUILD files for wheel
libraries to track package provenance using PURL (Package URL)
format.

aignas

@stevebarrau

aiuto

TheGrizzlyDev

aignas added a commit to aignas/rules_python that referenced this pull request

Mar 7, 2026
With this PR we move the processing of the `index_url` to the
`whl_library` as a preparatory step for easier `facts` implementation.
The motivation is many-fold:
1. Do not have too much duplication in the facts file by potentially
   naturally eliminating the `index_url` prefix from the `whls` if it
   appears like so on the index contents.
2. Avoid doing `envsubst` too early and have logic that has to deal with
   it.
3. Make the cache just return fact values from the lock file in the
   future instead of needing to change to an absolute URL and do
   envsubst on it.
4. We should have a better performance because we should be doing way
   fewer calls to make the URL absolute during parsing of the index.
5. With the `index_url` passed to the `whl_library`, we can help out the
   `purl` construction as what has been discussed in bazel-contrib#3531 about wheels
   from non-public indexes.

Summary:
- Attempt to put the `index_url` in the fewest structs possible.
- Extract the `urllib` utilities file for manipulation of the URLs.
- Simplify tests testing the `absolute_url` logic.

Work towards bazel-contrib#2731

github-merge-queue bot pushed a commit that referenced this pull request

Mar 8, 2026
With this PR we move the processing of the `index_url` to the
`whl_library` as a preparatory step for easier `facts` implementation.
The motivation is many-fold:
1. Do not have too much duplication in the facts file by potentially
   naturally eliminating the `index_url` prefix from the `whls` if it
   appears like so on the index contents.
2. Avoid doing `envsubst` too early and have logic that has to deal with
   it.
3. Make the cache just return fact values from the lock file in the
   future instead of needing to change to an absolute URL and do
   envsubst on it.
4. We should have a better performance because we should be doing way
   fewer calls to make the URL absolute during parsing of the index.
5. With the `index_url` passed to the `whl_library`, we can help out the
   `purl` construction as what has been discussed in #3531 about wheels
   from non-public indexes.

Summary:
- Attempt to put the `index_url` in the fewest structs possible.
- Extract the `urllib` utilities file for manipulation of the URLs.
- Simplify tests testing the `absolute_url` logic.

Work towards #2731