Skip to content

fix: load target_platforms through the hub #2781

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

Merged

Conversation

aignas
Copy link
Collaborator

@aignas aignas commented Apr 16, 2025

This PR moves the parsing of Requires-Dist to the loading phase
within the whl_library_targets_from_requires macro. The original
whl_library_targets macro has been left unchanged so that I don't have
to reinvent the unit tests - it is well covered under tests.

Before this PR we had to wire the target_platforms via the
experimental_target_platforms attr in the whl_library, which means
that whenever this would change (e.g. the minor Python version changes),
the wheel would be re-extracted even though the final result may be the
same.

This refactor uncovered that the dependency graph creation was incorrect
if we had multiple target Python versions due to various heuristics that
this had. In hindsight I had them to make the generated BUILD.bazel
files more readable when the unit test coverage was not great. Now this
is unnecessary and since everything is happening in Starlark I thought
that having a simpler algorithm that does the right thing always is the
best way.

This also cleans up the code by removing left over TODO notes or code
that no longer make sense.

Work towards #260, #2319

This PR moves the parsing of `Requires-Dist` to the analysis phase
within the `whl_library_targets_from_requires` macro. The original
`whl_library_targets` macro has been left unchanged so that I don't have
to reinvent the unit tests - it is well covered under tests.

Before this PR we had to wire the `target_platforms` via the
`experimental_target_platforms` attr in the `whl_library`, which means
that whenever this would change (e.g. the minor Python version changes),
the wheel would be re-extracted even though the final result may be the
same.

This also cleans up the code by removing left over TODO notes or code
that no longer make sense.

Work towards bazel-contrib#260, bazel-contrib#2319
@aignas aignas requested review from rickeylev and groodt as code owners April 16, 2025 09:40
@aignas
Copy link
Collaborator Author

aignas commented Apr 18, 2025

The implementation that handles the dep resolution for target_platforms when they span multiple Python versions is buggy. The plan is to probably bug-fix that before proceeding with this PR.

@aignas aignas marked this pull request as draft April 18, 2025 11:32
@aignas aignas marked this pull request as ready for review April 20, 2025 01:10
@aignas aignas changed the title refactor: load target_platforms through the hub refactor/fix: load target_platforms through the hub Apr 20, 2025
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.

This PR moves the parsing of Requires-Dist to the analysis phase

I don't see this part? I think I see it moving into the loading phase. Just update the description if so.

Analysis phase would be more like: a custom flag implementation that uses FeatureFlagInfo to affect select() resolutions.

refactor/fix ...

Since it's a fix, please give the title "fix" and update the changelog appropriately.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Stray file i think?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is now used in the hub_repository.bzl.

@aignas aignas changed the title refactor/fix: load target_platforms through the hub fix: load target_platforms through the hub Apr 20, 2025
@aignas aignas enabled auto-merge April 20, 2025 10:10
@aignas aignas added this pull request to the merge queue Apr 20, 2025
Merged via the queue into bazel-contrib:main with commit a19e1e4 Apr 20, 2025
3 checks passed
@aignas aignas deleted the refactor/target-platforms-through-hub branch April 20, 2025 10:40
aignas added a commit that referenced this pull request Apr 20, 2025
This PR moves the parsing of `Requires-Dist` to the loading phase
within the `whl_library_targets_from_requires` macro. The original
`whl_library_targets` macro has been left unchanged so that I don't have
to reinvent the unit tests - it is well covered under tests.

Before this PR we had to wire the `target_platforms` via the
`experimental_target_platforms` attr in the `whl_library`, which means
that whenever this would change (e.g. the minor Python version changes),
the wheel would be re-extracted even though the final result may be the
same.

This refactor uncovered that the dependency graph creation was incorrect
if we had multiple target Python versions due to various heuristics that
this had. In hindsight I had them to make the generated `BUILD.bazel`
files more readable when the unit test coverage was not great. Now this
is unnecessary and since everything is happening in Starlark I thought
that having a simpler algorithm that does the right thing always is the
best way.

This also cleans up the code by removing left over TODO notes or code
that no longer make sense.

Work towards #260, #2319

(cherry picked from commit a19e1e4)
aignas added a commit to aignas/rules_python that referenced this pull request Apr 27, 2025
This just adds the code back at the original state before the following
PRs have been made to remove them: bazel-contrib#2629, bazel-contrib#2781. This has not been
hooked up yet in `evaluate_markers` and `whl_library` yet and I'll need
extra PRs to do that.

No CHANGELOG entries for now, will be done once the integration is back.

Work towards bazel-contrib#2830
github-merge-queue bot pushed a commit that referenced this pull request Apr 27, 2025
This just adds the code back at the original state before the following
PRs have been made to remove them: #2629, #2781. This has not been
hooked up yet in `evaluate_markers` and `whl_library` yet and I'll need
extra PRs to do that.

No CHANGELOG entries for now, will be done once the integration is back.

Work towards #2830
aignas added a commit that referenced this pull request Apr 29, 2025
This just adds the code back at the original state before the following
PRs have been made to remove them: #2629, #2781. This has not been
hooked up yet in `evaluate_markers` and `whl_library` yet and I'll need
extra PRs to do that.

No CHANGELOG entries for now, will be done once the integration is back.

Work towards #2830

(cherry picked from commit 61c91fe)
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.

2 participants