fix(pypi): pass requirements without env markers to the whl_library#2488
Merged
aignas merged 12 commits intobazel-contrib:mainfrom Dec 12, 2024
Merged
Conversation
With this change the environment markers from the requirements.txt files no longer end up in the whl_library definitions. The alternative would be to fix this in the whl_library itself and do the string manipulation then. However, this means that we will be doing refetching of the repository when the markers change and the overall behaviour may be more complex. This solution also makes the MODULE.bazel.lock files simpler. That said, I am 50/50 on putting it in this way, so I can be easily convinced to put it in the whl_library if there is preference.
aignas
commented
Dec 9, 2024
aignas
commented
Dec 9, 2024
CHANGELOG.md
Outdated
| * (pip.parse) The requirement argument parsed to `whl_library` will now not have | ||
| env marker information allowing `bazel query` to work in cases where the `whl` | ||
| is available for all of the platforms and the sdist can be built. | ||
| Work towards [#2450](https://github.com/bazelbuild/rules_python/issues/2450). |
Collaborator
Author
There was a problem hiding this comment.
Suggested change
| Work towards [#2450](https://github.com/bazelbuild/rules_python/issues/2450). | |
| Fixes [#2450](https://github.com/bazelbuild/rules_python/issues/2450). |
Actually, @keith, I think that this PR might fix the issue you were having. Let me know if it does in something else than #2450 as with this PR the command bazel query deps(...) no longer fails.
rickeylev
approved these changes
Dec 11, 2024
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.
With this change the environment markers from the requirements.txt files
no longer end up in the whl_library definitions. I am reusing a function
that already is parsing each requirement line for
sha256values and addedlogic to extract the
markerat that point. This means that the change isalso trivial to backport to the
WORKSPACEand the logic in the extensionbecomes simpler and we don't rely only on integration tests.
Expected changes to the users:
WORKSPACE, those will bereformatted and the env markers will be removed.
MODULE.bazel.lockfile will be likewise reformatted if users arenot using
--experimental_index_url. Also, the env markers will not bepassed in the
requirement.bazel query 'deps("@pypi//foo")'should start working in more cases.Fixes #2450.