-
Notifications
You must be signed in to change notification settings - Fork 512
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
feat(pip): provide pypi -> whl target mapping in requirements.bzl #1532
Conversation
…ackage that installed them This is needed in custom rules that want to locate the wheel file for a given package name. Demo: ``` $ head -15 $(bazel info output_base)/external/pypi/requirements.bzl """Starlark representation of locked requirements. @generated by rules_python pip_parse repository rule from @//:requirements_lock.txt """ load("@rules_python//python/pip_install:pip_repository.bzl", "whl_library") all_requirements = ["@pypi//certifi:pkg", "@pypi//chardet:pkg", "@pypi//idna:pkg", "@pypi//pathspec:pkg", "@pypi//python_dateutil:pkg", "@pypi//python_magic:pkg", "@pypi//pyyaml:pkg", "@pypi//requests:pkg", "@pypi//s3cmd:pkg", "@pypi//setuptools:pkg", "@pypi//six:pkg", "@pypi//urllib3:pkg", "@pypi//yamllint:pkg"] all_whl_requirements_by_package = {"certifi": "@pypi//certifi:whl", "chardet": "@pypi//chardet:whl", "idna": "@pypi//idna:whl", "pathspec": "@pypi//pathspec:whl", "python_dateutil": "@pypi//python_dateutil:whl", "python_magic": "@pypi//python_magic:whl", "pyyaml": "@pypi//pyyaml:whl", "requests": "@pypi//requests:whl", "s3cmd": "@pypi//s3cmd:whl", "setuptools": "@pypi//setuptools:whl", "six": "@pypi//six:whl", "urllib3": "@pypi//urllib3:whl", "yamllint": "@pypi//yamllint:whl"} all_whl_requirements = all_whl_requirements_by_package.values() all_data_requirements = ["@pypi//certifi:data", "@pypi//chardet:data", "@pypi//idna:data", "@pypi//pathspec:data", "@pypi//python_dateutil:data", "@pypi//python_magic:data", "@pypi//pyyaml:data", "@pypi//requests:data", "@pypi//s3cmd:data", "@pypi//setuptools:data", "@pypi//six:data", "@pypi//urllib3:data", "@pypi//yamllint:data"] ```
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please also update the bzlmod implementation:
- python/private/bzlmod/pip_repository.bzl
- python/private/bzlmod/requirements.bzl.tmpl
Can you also update the changelog, please? |
@rickeylev attempting to update the bzlmod implementation, but I'm not seeing the code used. Even in |
Yes, it's wired up. The dependency goes: python/extension/pip.bzl -> python/private/bzlmod/pip.bzl -> python/private/bzlmod/pip_repository.bzl -> python/private/bzlmod/requirements.bzl.tmpl |
a2da594
to
406a180
Compare
Thanks, updated. I found one issue that I don't think I want to try to solve here: in this code As a consequence, under the bzlmod implementation, my feature has the normalized names appearing as the keys in |
Currently a BUILD file can load
all_whl_requirements
but then can't determine which one is associated with a given package installed by the user.This makes it impossible to build rules where the user can choose a given package and then override the wheel used, for example. @mattem and I are working at a client where we need this ability.
This PR makes a small, non-breaking refactoring to the generated
requirements.bzl
file so that this information is available in a newall_whl_requirements_by_package
symbol.Users can then do something like this: