-
-
Notifications
You must be signed in to change notification settings - Fork 678
Consider removing duplicate code in PyPI package name normalization #1330
Description
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 and entry_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 the pip_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 the whl_library:
- Starlark implementation declares a
metadata.jsonoutput file that gets written by thewheel_installer.pyscript. - The script extracts or builds the wheel and outputs the metadata to the
metadata.jsonfile as opposed to creating aBUILD.bazelfile. - Starlark implementation reads the
metadata.jsonfile and then constructs theBUILD.bazelfile.
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 extra BUILD.bazel content or do patching within the starlark context and it would make annotation handling easier. The whole argument parsing for the wheel_installer.py is likely to also become simpler.