Skip to content
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

fix(pypi): pass requirements without env markers to the whl_library #2488

Merged

Conversation

aignas
Copy link
Collaborator

@aignas aignas commented Dec 9, 2024

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 sha256 values and added
logic to extract the marker at that point. This means that the change is
also trivial to backport to the WORKSPACE and the logic in the extension
becomes simpler and we don't rely only on integration tests.

Expected changes to the users:

  • If they have vendored pip requirements in WORKSPACE, those will be
    reformatted and the env markers will be removed.
  • The MODULE.bazel.lock file will be likewise reformatted if users are
    not using --experimental_index_url. Also, the env markers will not be
    passed in the requirement.
  • bazel query 'deps("@pypi//foo")' should start working in more cases.

Fixes #2450.

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.
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).
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

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.

Copy link
Member

Choose a reason for hiding this comment

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

looks like it does! 🎉

@aignas aignas changed the title fix(pip.parse): pass requirements without env markers to the whl_library fix(pypi): pass requirements without env markers to the whl_library Dec 9, 2024
CHANGELOG.md Outdated Show resolved Hide resolved
python/private/pypi/index_sources.bzl Outdated Show resolved Hide resolved
python/private/pypi/parse_requirements.bzl Outdated Show resolved Hide resolved
python/private/pypi/parse_requirements.bzl Show resolved Hide resolved
@aignas aignas enabled auto-merge December 12, 2024 00:15
@aignas aignas added this pull request to the merge queue Dec 12, 2024
Merged via the queue into bazelbuild:main with commit bda710c Dec 12, 2024
4 checks passed
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.

pip.parse parsing all requirements files fails on platform specific wheel downloads
3 participants