feat(whl_library): generate platform-specific dependency closures#1593
Merged
rickeylev merged 20 commits intobazel-contrib:mainfrom Dec 13, 2023
Merged
feat(whl_library): generate platform-specific dependency closures#1593rickeylev merged 20 commits intobazel-contrib:mainfrom
rickeylev merged 20 commits intobazel-contrib:mainfrom
Conversation
960ad4c to
e85bd8b
Compare
rickeylev
reviewed
Dec 5, 2023
python/pip_install/private/generate_whl_library_build_bazel.bzl
Outdated
Show resolved
Hide resolved
| continue | ||
|
|
||
| if not platforms: | ||
| # old behaviour, where we target the host platform |
Collaborator
There was a problem hiding this comment.
Something I learned last week: Bazel has a builtin repository that tells you the host system's constraints.
load("@local_config_platform//:constraints.bzl", "HOST_CONSTRAINTS")
(Not sure where we could use this, just passing along a TIL)
Collaborator
Author
|
I think the resultant BUILD.bazel files are good enough for it to be considered for merging. @arrdem, cc-ing you as you've spent quite some time on this topic recently and would love to hear your opinion/feedback on the change. |
37cfde3 to
f1d187c
Compare
This is to ensure that we can represent select of lists in a better way
Before this change, the dependency closures would be influenced by the host-python interpreter, this removes the influence by detecting the platforms against which the `Requires-Dist` wheel metadata is evaluated. This functionality can be enabled via `target_platforms` attribute to the `pip.parse` extension and is showcased in the `bzlmod` example. The same attribute is also supported on the legacy `pip_parse` repository rule. The detection works in the following way: - Check if the python wheel is platform specific or cross-platform (i.e., ends with `any.whl`), if it is then platform-specific dependencies are generated, which will go through a `select` statement. - If it is platform specific, then parse the platform_tag and evaluate the `Requires-Dist` markers assuming the target platform rather than the host platform. NOTE: The `whl` `METADATA` is now being parsed using the `packaging` Python package instead of `pkg_resources` from `setuptools`. Fixes bazel-contrib#1591
f1d187c to
38b3dfe
Compare
rickeylev
reviewed
Dec 12, 2023
Co-authored-by: Richard Levasseur <[email protected]>
rickeylev
reviewed
Dec 13, 2023
rickeylev
approved these changes
Dec 13, 2023
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
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.
Before this change, the dependency closures would be influenced by the
host-python interpreter, this removes the influence by detecting the
platforms against which the
Requires-Distwheel metadata is evaluated.This functionality can be enabled via
experimental_target_platformsattribute to the
pip.parseextension and is showcased in thebzlmodexample. The same attribute is also supported on the legacy
pip_parserepository rule.
The detection works in the following way:
(i.e., ends with
any.whl), if it is then platform-specificdependencies are generated, which will go through a
selectstatement.
the
Requires-Distmarkers assuming the target platform rather thanthe host platform.
NOTE: The
whlMETADATAis now being parsed using thepackagingPython package instead of
pkg_resourcesfromsetuptools.Fixes #1591