Skip to content

feat(pypi): add pip.dep to declare abstract pypi dependencies#3850

Open
rickeylev wants to merge 1 commit into
bazel-contrib:mainfrom
rickeylev:add-pip-dep-tag-class
Open

feat(pypi): add pip.dep to declare abstract pypi dependencies#3850
rickeylev wants to merge 1 commit into
bazel-contrib:mainfrom
rickeylev:add-pip-dep-tag-class

Conversation

@rickeylev

Copy link
Copy Markdown
Collaborator

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 *.bzl files to help guide it
in creating better bzl files.

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.
@rickeylev rickeylev requested a review from aignas as a code owner June 26, 2026 06:54

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +505 to +506
for dep_name, extra_targets in mods.declared_deps.items():
norm_pkg = normalize_name(dep_name)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.

Suggested change
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():

Comment on lines +453 to +456
_dep(
name = "declared-pkg",
extra_targets = ["declared-alias"],
),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants