-
-
Notifications
You must be signed in to change notification settings - Fork 574
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
refactor(pypi): implement PEP508 compliant marker evaluation #2692
Merged
aignas
merged 10 commits into
bazel-contrib:main
from
aignas:feat/extension-eval-without-python
Mar 30, 2025
Merged
refactor(pypi): implement PEP508 compliant marker evaluation #2692
aignas
merged 10 commits into
bazel-contrib:main
from
aignas:feat/extension-eval-without-python
Mar 30, 2025
Conversation
This file contains 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 implements the PEP508 compliant marker evaluation in starlark and removes the need for the Python interpreter when evaluating requirements files passed to `pip.parse`. This makes the evaluation faster and allows us to fix a few known issues (bazel-contrib#2690). In the future the intent is to move the `METADATA` parsing to pure starlark so that the `RequiresDist` could be parsed in starlark at the macro evaluation or analysis phases. This should make it possible to more easily solve the design problem that more and more things need to be passed to `whl_library` as args to have a robust dependency parsing: * bazel-contrib#2319 needs the full Python version to have correct cross-platform compatible METADATA parsing and passing it to `Python` and back makes it difficult/annoying to implement. * Parsing the `METADATA` file requires the precise list of target platform or the list of available packages in the `requirements.txt`. This means that without it we cannot trim the dependency tree in the `whl_library`. Doing this at macro loading phase allows us to depend on `.bzl` files in the `hub_repository` and more effectively pass information. Fixes bazel-contrib#2423
rickeylev
approved these changes
Mar 29, 2025
aignas
commented
Mar 29, 2025
Refreshed the lockfile before and after the change:
And saw no difference in entries except for the expected:
|
OK, I think this is ready to be merged. This is probably already higher fidelity/more robust than the Python impl of |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This implements the PEP508 compliant marker evaluation in starlark and
removes the need for the Python interpreter when evaluating requirements
files passed to
pip.parse
. This makes the evaluation faster and allowsus to fix a few known issues (#2690).
In the future the intent is to move the
METADATA
parsing to purestarlark so that the
RequiresDist
could be parsed in starlark at themacro evaluation or analysis phases. This should make it possible to
more easily solve the design problem that more and more things need to
be passed to
whl_library
as args to have a robust dependency parsing:compatible
METADATA
parsing and passing it toPython
and back makesit difficult/annoying to implement.
METADATA
file requires the precise list of targetplatform or the list of available packages in the
requirements.txt
.This means that without it we cannot trim the dependency tree in the
whl_library
. Doing this at macro loading phase allows us to dependon
.bzl
files in thehub_repository
and more effectively passinformation.
I can remotely see that this could become useful in
py_wheel
or an buildingwheels from sdists as the environment markers may be present in various source
metadata as well. What is more
uv.lock
file has the env markers as part ofthe lock file information, so this might be useful there.
Work towards #2423
Work towards #260
Split from #2629