- Analyzed
python/extensions/pip.bzl,python/private/pypi/hub_builder.bzl,python/private/pypi/uv_lock.bzl. - Confirmed
uv.lockstructure contains wheel URLs and resolution markers. - Identified need to modify
pip_repository_attrs.bzlandhub_builder.bzl.
-
Modify
python/private/pypi/pip_repository_attrs.bzl:- Add
uv_lockattribute (label, allow_single_file=True). - Add
_toml2jsonattribute (label, default pointing to a tool). Note: Need to verify if_toml2jsonis already available or needs to be added. Theuv_lock.bzlhelper usesattr._toml2json, so it must be present on the calling rule/tag.
- Add
-
Modify
python/private/pypi/hub_builder.bzl:- In
_pip_parse:- Check if
pip_attr.uv_lockis set. - If set, call
convert_uv_lock_to_json. - Parse the JSON result.
- Iterate over packages in the JSON.
- Group packages by name.
- For this step, select the highest version for each package name.
- Select the first wheel URL for that version.
- Create
whl_libraryrepositories for these wheels. - Ensure these
whl_librarycalls are integrated intoself._whl_libraries.
- Check if
- In
-
Verify:
- Run
bazel run //tests/uv_pypi:bin.
- Run
-
Handle Resolution Markers:
- Parse
resolution-markersfromuv.lockpackages. - Instead of picking one version, keep all versions that have distinct resolution markers.
- Parse
-
Use
wheel_tags_settings:- In
hub_builder.bzl, when constructing the hub repository content (viahub_repository), we need to pass information about these multiple versions. - The
hub_repositoryrule (or the macros creating it) needs to generatedefine_wheel_tag_settingsin theBUILD.bazelof the hub. - Generate
aliastargets usingselect()based on the defined settings.
- In
-
Refactor Hub Generation:
- Update
hub_repository.bzl(or the template it uses) to support this new "multi-version via select" pattern, if it doesn't already. The prompt suggests modifying the "hub build file for a package".
- Update
-
Verify:
- Run the test again. It should correctly pick
absl-py2.3.1 or 2.4.0 based on the environment/platform.
- Run the test again. It should correctly pick