-
Notifications
You must be signed in to change notification settings - Fork 541
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
Consider removing duplicate code in PyPI package name normalization #1330
Comments
aignas
added a commit
to aignas/rules_python
that referenced
this issue
Jul 22, 2023
Before this PR, the `wheel_installer` was doing three things: 1. Downloading the right wheel. 2. Extracting it into the output directory. 3. Generating BUILD.bazel files based on the extracted contents. This PR is moving the third part into the `whl_library` repository rule and it has the following benefits: * We can reduce code duplication and label sanitization functions in rules_python. * There are many things that the `wheel_installer` does not care anymore and we don't need to change less code when extending `whl_library` as we can now do many things in starlark directly. * It becomes easier to change the API of how we expose the generated BUILD.bazel patching because we only need to change the Starlark functions. Work towards bazelbuild#1330.
This was referenced Jul 22, 2023
aignas
added a commit
to aignas/rules_python
that referenced
this issue
Aug 1, 2023
Before this PR, the `wheel_installer` was doing three things: 1. Downloading the right wheel. 2. Extracting it into the output directory. 3. Generating BUILD.bazel files based on the extracted contents. This PR is moving the third part into the `whl_library` repository rule and it has the following benefits: * We can reduce code duplication and label sanitization functions in rules_python. * There are many things that the `wheel_installer` does not care anymore and we don't need to change less code when extending `whl_library` as we can now do many things in starlark directly. * It becomes easier to change the API of how we expose the generated BUILD.bazel patching because we only need to change the Starlark functions. Work towards bazelbuild#1330.
github-merge-queue bot
pushed a commit
that referenced
this issue
Aug 2, 2023
Before this PR, the `wheel_installer` was doing three things: 1. Downloading the right wheel. 2. Extracting it into the output directory. 3. Generating BUILD.bazel files based on the extracted contents. This PR is moving the third part into the `whl_library` repository rule and it has the following benefits: * We can reduce code duplication and label sanitization functions in rules_python. * There are many things that the `wheel_installer` does not care anymore and we don't need to change less code when extending `whl_library` as we can now do many things in starlark directly. * It becomes easier to change the API of how we expose the generated BUILD.bazel patching because we only need to change the Starlark functions. Work towards #1330.
The only remaining part for this is to use the |
Completed via #1542 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is a followup to @chrislovecnm comment in #1329.
If #1329 lands, then there are the following parts where we have name sanitisation and normalization.
First are the
requirement
,whl_requirement
,data_requirement
,dist_info_requirement
andentry_point
macros are using a vendored copy of the function named_clean_name
. We could just use the function introduced in #1329 most of the time, but we have to expose it either in//python/pip_install:normalize_name.bzl
or somewhere else because as it is right now, it's invisible from thepip_parse
hub repos.Second is the Python implementation in
//python/pip_install/tools/lib:bazel.py
has a copy and we cannot remove it that easily. The only (semi) sensible way would be to change the implementation of thewhl_library
:metadata.json
output file that gets written by thewheel_installer.py
script.metadata.json
file as opposed to creating aBUILD.bazel
file.metadata.json
file and then constructs theBUILD.bazel
file.The benefit of the
whl_library
refactor would be that it would make the wheel installer a single purpose tool and we could pass the extraBUILD.bazel
content or do patching within the starlark context and it would make annotation handling easier. The whole argument parsing for thewheel_installer.py
is likely to also become simpler.The text was updated successfully, but these errors were encountered: