feat(pypi): add pip.dep to declare abstract pypi dependencies#3850
feat(pypi): add pip.dep to declare abstract pypi dependencies#3850rickeylev wants to merge 1 commit into
Conversation
Introduce the pip.dep tag class to allow modules to declare abstract PyPI dependencies. These dependencies are fed directly into the unified hub repository, ensuring their target structures exist and automatically routing any unimplemented declarations to analysis-time errors.
There was a problem hiding this comment.
Code Review
This pull request introduces a new dep tag class to the pip bzlmod extension, enabling modules to declare abstract PyPI dependencies. This ensures that target structures exist in the unified hub without forcing a specific version or lock file on consumers, with downstream modules providing the concrete implementation via pip.parse. The feedback suggests a minor optimization in python/private/pypi/extension.bzl to remove a redundant normalize_name call since the keys of declared_deps are already normalized.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| for dep_name, extra_targets in mods.declared_deps.items(): | ||
| norm_pkg = normalize_name(dep_name) |
There was a problem hiding this comment.
The keys of mods.declared_deps are already normalized when they are populated in parse_modules (using normalize_name(dep_attr.name)). Therefore, calling normalize_name(dep_name) here is redundant. We can simplify this loop by directly unpacking the normalized package name as norm_pkg.
| for dep_name, extra_targets in mods.declared_deps.items(): | |
| norm_pkg = normalize_name(dep_name) | |
| for norm_pkg, extra_targets in mods.declared_deps.items(): |
| _dep( | ||
| name = "declared-pkg", | ||
| extra_targets = ["declared-alias"], | ||
| ), |
There was a problem hiding this comment.
Please add a unit test to ensure that if we declare a dep and then it is provided by a pip.parse, that it works as expected.
Introduce the pip.dep tag class to allow modules to declare abstract
PyPI dependencies. These declarations ensure the target structure for
a PyPI package is created, but provide a no-op implementation that
passes analysis time, but fails at execution time.
Along the way, create an agent rule for
*.bzlfiles to help guide itin creating better bzl files.