Skip to content

Conversation

aignas
Copy link
Collaborator

@aignas aignas commented Aug 30, 2025

Before this PR we were using our python helpers to parse the whl METADATA for a
particular host (or experimentally - target) platform and the fixed dependency
list would be written to the BUILD.bazel files materialized by the
whl_library repository rule.

This PR adds extra plumbing to leverage the Starlark implementation of the
METADATA file parsing (a.k.a. pipstar) which moves the evaluation to analysis
phase as we will get the target platform details via the
env_marker_config_setting from the toolchain used for the dependencies.

Since users are normally working with a subset of platforms that the METADATA
would pull in, we are writing the list of packages from the requirements file to
a bzl file so that pipstar knows which packages to consider when parsing the
METADATA. This will ensure that bazel query continues to work.

Since just passing the list of packages to the whl_library would cause
refetches of all of the whl_library dependencies when we add or remove a
package, we pass a path where to load the symbol called packages from, which
means that only the analysis phase will be affected because the macros will be
re-evaluated if one adds or removes a package.

We still need to download the correct platform-specific wheels for the right
platform in order to fully resolve the referenced tickets. With this PR we are
deprecating the experimental_target_platforms attribute since it has no longer
any effect.

Fixes #2949
Work towards #260
Work towards #2241

@aignas aignas marked this pull request as ready for review August 30, 2025 16:00
@aignas
Copy link
Collaborator Author

aignas commented Sep 7, 2025

Need to wait for the #3247 so that I can finish fixing the tests

@aignas aignas force-pushed the aignas.exp.bzlmod.enable.pipstar branch from b697f55 to 790a508 Compare September 7, 2025 13:41
@aignas aignas marked this pull request as draft September 7, 2025 13:41
@aignas aignas changed the title exp(pypi): enable pipstar by default on bzlmod feat(pypi): enable pipstar by default on bzlmod Sep 7, 2025
@aignas aignas force-pushed the aignas.exp.bzlmod.enable.pipstar branch from 790a508 to 7b35e52 Compare September 8, 2025 12:28
Extra fixes:
- add more logging to the failure
- better METADATA files in tests
- fix tests
@aignas aignas force-pushed the aignas.exp.bzlmod.enable.pipstar branch from 7b35e52 to 10692ce Compare September 8, 2025 12:41
@aignas aignas marked this pull request as ready for review September 8, 2025 13:05
@aignas
Copy link
Collaborator Author

aignas commented Sep 8, 2025

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request enables pipstar by default for bzlmod builds, which is a significant step forward. The changes in internal_config_repo.bzl correctly implement this switch. The test updates, including modifications to hub_builder_tests.bzl and test data, align well with this new default, ensuring the test suite remains valid. The improved error logging in whl_metadata.bzl is also a nice addition for debuggability. I've found one potential issue regarding the use of dep_template in test dependencies which could cause problems in the future.

@aignas aignas changed the title feat(pypi): enable pipstar by default on bzlmod feat(pypi): enable pipstar by default Sep 28, 2025
@aignas aignas requested a review from rickeylev September 28, 2025 10:34
@aignas
Copy link
Collaborator Author

aignas commented Sep 30, 2025

OK, PTAL.

@aignas aignas force-pushed the aignas.exp.bzlmod.enable.pipstar branch from 3610512 to a61e676 Compare October 4, 2025 06:02
@aignas
Copy link
Collaborator Author

aignas commented Oct 4, 2025

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request enables the Starlark-based pipstar dependency resolver by default, a significant step towards moving dependency evaluation to the analysis phase. The changes include extensive plumbing to support this, such as introducing whl_config_repository to replace group_library, and passing package information via a config.bzl file. The experimental_target_platforms attribute is now deprecated. The implementation is robust, with considerations for backward compatibility, and the test suite has been thoroughly updated to reflect these substantial changes. My review found the changes to be well-executed, with only a minor suggestion to improve the clarity of the deprecation notice in the changelog.

Copy link
Collaborator Author

@aignas aignas left a comment

Choose a reason for hiding this comment

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

Self review.

@aignas aignas marked this pull request as ready for review October 4, 2025 13:45
@aignas
Copy link
Collaborator Author

aignas commented Oct 4, 2025

PTAL

@aignas aignas force-pushed the aignas.exp.bzlmod.enable.pipstar branch from 66ed60e to 42fef58 Compare October 4, 2025 13:55
Copy link
Collaborator

@rickeylev rickeylev left a comment

Choose a reason for hiding this comment

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

Any known compatibility issues we should document, or should this be a transparent drop in replacement?

@aignas
Copy link
Collaborator Author

aignas commented Oct 5, 2025

This should be a drop-in replacement, oh I think we need to point users to how they can configure the environment used for doing the evaluation.

@aignas aignas enabled auto-merge October 5, 2025 04:18
@aignas aignas added this pull request to the merge queue Oct 5, 2025
Merged via the queue into bazel-contrib:main with commit 1ebc93f Oct 5, 2025
4 checks passed
@aignas aignas deleted the aignas.exp.bzlmod.enable.pipstar branch October 5, 2025 04:36
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.

feat: enable pipstar by default
2 participants