As of now pip.parse has a requirement on being provided with a lockfile with the extras annotations in the file. This is not the default setting for pip-compile >=8.0 and uv pip compile. It also means that we are sometimes pulling unnecessary dependencies into the dependency closure. The way we could in theory remove this requirement is by changing the following parts.
[ ] In whl_library_targets macro generate py_library targets for each extra that the package provides. This could be done by asking the wheel_installer to return deps for each extra instead of only one when an extra argument is specified - this behaviour is better to be only enabled in bzlmod, but that is just a guiding note.
[ ] In the pip.parse, fetch the METADATA from PEP-658 compliant servers or by downloading the first whl in the selected distribution list and extracting the metadata in other cases.
[ ] Parsing the METADATA in the extension context to get the list of all of the extras that the wheel provides and passing that to the pip_hub repository_rule as the extra_hub_aliases field so that we can create extra aliases.
Lock files which have this information that we would need to retrieve from METADATA could be alternatively supported without fetching of the METADATA from the PyPI server (e.g. uv.lock has all of the info we need).
I am writing this idea down in case someone would like to contribute as I would be happy to mentor the contributor and help with finishing the design here.
As of now
pip.parse
has a requirement on being provided with a lockfile with theextras
annotations in the file. This is not the default setting forpip-compile >=8.0
anduv pip compile
. It also means that we are sometimes pulling unnecessary dependencies into the dependency closure. The way we could in theory remove this requirement is by changing the following parts.whl_library_targets
macro generatepy_library
targets for eachextra
that the package provides. This could be done by asking thewheel_installer
to return deps for each extra instead of only one when an extra argument is specified - this behaviour is better to be only enabled inbzlmod
, but that is just a guiding note.pip.parse
, fetch theMETADATA
from PEP-658 compliant servers or by downloading the firstwhl
in the selected distribution list and extracting the metadata in other cases.METADATA
in the extension context to get the list of all of the extras that the wheel provides and passing that to thepip_hub
repository_rule as theextra_hub_aliases
field so that we can create extra aliases.Lock files which have this information that we would need to retrieve from
METADATA
could be alternatively supported without fetching of theMETADATA
from the PyPI server (e.g.uv.lock
has all of the info we need).I am writing this idea down in case someone would like to contribute as I would be happy to mentor the contributor and help with finishing the design here.