Skip to content

feat: Support tool.uv.extra-build-dependencies in annotation loading#1297

Open
konsti-openai wants to merge 17 commits into
aspect-build:mainfrom
konsti-openai:konsti/support-uv-extra-build-annotations
Open

feat: Support tool.uv.extra-build-dependencies in annotation loading#1297
konsti-openai wants to merge 17 commits into
aspect-build:mainfrom
konsti-openai:konsti/support-uv-extra-build-annotations

Conversation

@konsti-openai

@konsti-openai konsti-openai commented Jul 14, 2026

Copy link
Copy Markdown

Currently, annotations.toml supports declaring extra build dependencies in a format that runs parallel to tool.uv.extra-build-dependencies. This PR adds support for loading uv's tool.uv.extra-build-dependencies to rules_py's uv.project. This moves rules_py closer to uv's interface.

Unlike annotations.toml, tool.uv.extra-build-dependencies supports the full requirements syntax.


Changes are visible to end-users: yes/no

  • Searched for relevant documentation and updated as needed: yes
  • Breaking change (forces users to change their own code or config): no
  • Suggested release notes appear below: yes

Test plan

Extended the existing e2e snapshot test on top of uv-sdist-fallback to cover both the old and the new syntax for two different packages.

@CLAassistant

CLAassistant commented Jul 14, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@konsti-openai

Copy link
Copy Markdown
Author

I'm new to rules_py, so I'm interested in feedback in how to expose this best: Should we just load extra build dependencies by default? Should this be a separate command similar to unstable_annotate_packages?

@konsti-openai konsti-openai changed the title Support tool.uv.extra-build-dependencies in annotation loading feat: Support tool.uv.extra-build-dependencies in annotation loading Jul 14, 2026
@xangcastle
xangcastle self-requested a review July 16, 2026 19:35
@konsti-openai
konsti-openai force-pushed the konsti/support-uv-extra-build-annotations branch 2 times, most recently from 0e808b5 to 1518240 Compare July 16, 2026 21:06
Comment thread uv/private/extension/defs.bzl Outdated
"for sdists that build a wheel. Only demanded when an sbuild is " +
"guaranteed to be selected (forced builds or sdist-only packages).",
),
"load_annotations": attr.bool(

@jbedard jbedard Jul 17, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should we just load extra build dependencies by default?

I assume we should by default if that is what uv does.

Is there any known reason for disabling it? Can we just enable this 100% of the time and drop this attribute?

@konsti-openai konsti-openai Jul 20, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I'm not aware of any, dropped!

Comment thread annotations.toml
{ name = "build" },
{ name = "setuptools" },
]
# This format is supported, but

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should we still be testing both though? Or is this old/deprecated enough we can just delete it (instead of commenting it out like this)?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I kept it there to not confuse user who come across the old format. imho it's fine to keep both format around and avoid breaking users, the comment should help users to understand what they should use and why they may see something different in existing code.

@tamird tamird 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.

This currently accepts only a narrow subset of uv's extra-build-dependencies syntax and silently drops several valid cases. Please either preserve uv's semantics for requirement objects, markers, split versions, and build-only dependencies or explicitly reject unsupported forms, and add an e2e case whose build really depends on the annotation.

Comment thread uv/private/extension/defs.bzl Outdated
Comment thread uv/private/extension/defs.bzl Outdated
if project.load_annotations:
extra_build_dependencies = tool_uv.get("extra-build-dependencies", {})
for package, extra_deps in extra_build_dependencies.items():
target = _resolve(package, None)

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.

Resolving the annotated package only through default_versions silently skips every valid split-version lock: that map is populated only when a name has one version, while uv applies the annotation by package name across selected versions. The same issue affects build dependencies below. Please expand the target/dependency resolution over package_versions and add a conflicting-version or platform-fork regression.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I've added that, though it's important to note that build-system.requires extracts only the name (

requires = [
_extract_name(r)
for r in build_system.get("requires", [])
if _extract_name(r)
]
), so we have a divergence between how tool.uv.extra-build-dependencies and build-system.requires are parsed.

Comment thread uv/private/extension/defs.bzl Outdated
Comment thread uv/private/extension/defs.bzl
@konsti-openai

konsti-openai commented Jul 20, 2026

Copy link
Copy Markdown
Author

Codex also flagged two other problems. They are already present with annotations.toml, so I'm cutting scope here:

  • Dependency-group independence: build dependencies resolve through the active runtime group. If a required build package exists only in another group, Bazel analysis can fail.
  • Version preservation: although an annotation can resolve a specific build-dependency version, the generated package alias may select the version associated with the active runtime group instead.

@konsti-openai
konsti-openai force-pushed the konsti/support-uv-extra-build-annotations branch from 6bac123 to 7c53c7d Compare July 20, 2026 12:19
package_versions,
fail_if_missing = False,
)
if not resolved_deps:

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

It's arguable whether this should or shouldn't fail. Codex complains that this fails for wheel-only packages while annotations.toml skips, but OTOH annotating a wheel-only package with requirements missing in the lock sounds bogus.

@konsti-openai
konsti-openai marked this pull request as ready for review July 20, 2026 22:40
@konsti-openai

Copy link
Copy Markdown
Author

I'm having a hard time scoping this against preexisting gaps and making this too large for review, but I think the current state is ready for a review.

@konsti-openai
konsti-openai force-pushed the konsti/support-uv-extra-build-annotations branch from 4fd294c to a6aaf44 Compare July 20, 2026 22:43
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.

4 participants