Skip to content

Conversation

@zanieb
Copy link
Member

@zanieb zanieb commented Jul 18, 2025

Replaces #14092

Adds tool.uv.extra-build-dependencies = {package = [dependency, ...]} which extends build-system.requires during package builds.

These are lowered via workspace sources, are applied to transitive dependencies, and are included in the wheel cache shard hash.

There are some features we need to follow-up on, but are out of scope here:

  • Preferring locked versions for build dependencies
  • Settings for requiring locked versions for build depencies

There are some quality of life follow-ups we should also do:

  • Warn on extra-build-dependencies that do not apply to any packages
  • Add test cases and improve error messaging when the extra-build-dependencies resolve fails

There are were a few open decisions to be made here

  1. Should we resolve these dependencies alongside the build-system.requires dependencies? Or should we resolve separately? (I think the latter is more powerful? because you can override things? but it opens the door to breaking your build)
  2. Should we install these dependencies into the same environment? Or should we layer it on top as we do elsewhere? (I think it's fine to install into the same environment)
  3. Should we respect sources defined in the parent project? (I think yes, but then we need to lower the dependencies earlier — I don't think that's a big deal, but it's not implemented)
  4. Should we respect sources defined in the child project? (I think no, this gets really complicated and seems weird to allow)
  5. Should we apply this to transitive dependencies? (I think so)

@zanieb zanieb added enhancement New feature or improvement to existing functionality preview Experimental behavior labels Jul 18, 2025
@zanieb zanieb temporarily deployed to uv-test-registries July 18, 2025 17:40 — with GitHub Actions Inactive
fn sync_extra_build_dependencies() -> Result<()> {
let context = TestContext::new("3.12").with_filtered_counts();

// Write a test package that arbitrarily requires `anyio` at build time
Copy link
Member Author

Choose a reason for hiding this comment

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

Thank you <3 @konstin for the deranged test case

@charliermarsh
Copy link
Member

Should we resolve these dependencies alongside the build-system.requires dependencies? Or should we resolve separately? (I think the latter is more powerful? because you can override things? but it opens the door to breaking your build)

I would probably resolve them together. At least until we see a use-case to resolve them separately. (We could add build dependency overrides to allow explicit overrides, like we have build dependency constraints.)

Should we install these dependencies into the same environment? Or should we layer it on top as we do elsewhere. (I think it's fine to install into the same environment)

Same environment IMO.

Should we respect sources defined in the parent project? (I think yes, but then we need to lower the dependencies earlier)

I think yes... I think we should respect the sources defined in the same file as the extra-build-dependencies definition, for consistency.

Should we respect sources defined in the child project? (I think no)

I don't think so.

Should we apply this to transitive dependencies? (I think so)

I think so, yeah. Similar to other settings, like --config-settings-package.

@zanieb zanieb force-pushed the zb/extra-build-dependencies branch from ae3d08f to 1d2d9aa Compare July 23, 2025 18:39
@zanieb zanieb temporarily deployed to uv-test-registries July 23, 2025 18:43 — with GitHub Actions Inactive
@zanieb zanieb temporarily deployed to uv-test-registries July 23, 2025 23:25 — with GitHub Actions Inactive
@zanieb zanieb force-pushed the zb/extra-build-dependencies branch from 9b52574 to db10dcb Compare July 23, 2025 23:57
@zanieb zanieb temporarily deployed to uv-test-registries July 23, 2025 23:59 — with GitHub Actions Inactive
@zanieb zanieb temporarily deployed to uv-test-registries July 24, 2025 22:37 — with GitHub Actions Inactive
@zanieb zanieb temporarily deployed to uv-test-registries July 25, 2025 19:18 — with GitHub Actions Inactive
@zanieb zanieb temporarily deployed to uv-test-publish July 25, 2025 19:19 — with GitHub Actions Inactive
@zanieb zanieb force-pushed the zb/extra-build-dependencies branch from b44584e to bd55fda Compare July 25, 2025 19:25
@zanieb zanieb temporarily deployed to uv-test-registries July 25, 2025 19:27 — with GitHub Actions Inactive
@zanieb zanieb force-pushed the zb/extra-build-dependencies branch from 6d46b63 to 6c61c7f Compare July 29, 2025 23:16
@zanieb zanieb temporarily deployed to uv-test-registries July 29, 2025 23:20 — with GitHub Actions Inactive
@zanieb zanieb had a problem deploying to uv-test-registries July 29, 2025 23:34 — with GitHub Actions Failure
}

/// Create from pre-lowered dependencies (for non-workspace contexts).
pub fn from_lowered(extra_build_dependencies: ExtraBuildDependencies) -> Self {
Copy link
Member

Choose a reason for hiding this comment

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

Should this just be a From<ExtraBuildDependencies> impl?

Copy link
Member

Choose a reason for hiding this comment

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

This separate method avoids accidentally converting them without lowering

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah I think a dedicated method makes sense here.

}
VersionOrUrl::Url(url) => {
1u8.cache_key(state);
url.to_string().cache_key(state);
Copy link
Member

Choose a reason for hiding this comment

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

Is the to_string because it's generic? I wonder if we could require Pep508Url to impl CacheKey?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah I think so, I looked at it briefly and it the generic aspect seemed tricky.

Copy link
Member

@charliermarsh charliermarsh left a comment

Choose a reason for hiding this comment

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

Nice work.

}

/// Create from pre-lowered dependencies (for non-workspace contexts).
pub fn from_lowered(extra_build_dependencies: ExtraBuildDependencies) -> Self {
Copy link
Member

Choose a reason for hiding this comment

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

This separate method avoids accidentally converting them without lowering

@zanieb zanieb temporarily deployed to uv-test-registries July 30, 2025 13:20 — with GitHub Actions Inactive
@zanieb zanieb force-pushed the zb/extra-build-dependencies branch from cf66317 to 3d2e5fc Compare July 30, 2025 13:42
@zanieb zanieb temporarily deployed to uv-test-registries July 30, 2025 13:44 — with GitHub Actions Inactive
@zanieb zanieb force-pushed the zb/extra-build-dependencies branch from 3d2e5fc to 285b8b2 Compare July 30, 2025 14:00
@zanieb zanieb temporarily deployed to uv-test-registries July 30, 2025 14:02 — with GitHub Actions Inactive
@zanieb zanieb merged commit 6856a27 into main Jul 30, 2025
138 checks passed
@zanieb zanieb deleted the zb/extra-build-dependencies branch July 30, 2025 14:53
tmeijn pushed a commit to tmeijn/dotfiles that referenced this pull request Jul 31, 2025
This MR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [astral-sh/uv](https://github.com/astral-sh/uv) | patch | `0.8.3` -> `0.8.4` |

MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot).

**Proposed changes to behavior should be submitted there as MRs.**

---

### Release Notes

<details>
<summary>astral-sh/uv (astral-sh/uv)</summary>

### [`v0.8.4`](https://github.com/astral-sh/uv/blob/HEAD/CHANGELOG.md#084)

[Compare Source](astral-sh/uv@0.8.3...0.8.4)

##### Enhancements

- Improve styling of warning cause chains  ([#&#8203;14934](astral-sh/uv#14934))
- Extend wheel filtering to Android tags ([#&#8203;14977](astral-sh/uv#14977))
- Perform wheel lockfile filtering based on platform and OS intersection ([#&#8203;14976](astral-sh/uv#14976))
- Clarify messaging when a new resolution needs to be performed ([#&#8203;14938](astral-sh/uv#14938))

##### Preview features

- Add support for extending package's build dependencies with `extra-build-dependencies` ([#&#8203;14735](astral-sh/uv#14735))
- Split preview mode into separate feature flags ([#&#8203;14823](astral-sh/uv#14823))

##### Configuration

- Add support for package specific `exclude-newer` dates via `exclude-newer-package` ([#&#8203;14489](astral-sh/uv#14489))

##### Bug fixes

- Avoid invalidating lockfile when path or workspace dependencies define explicit indexes ([#&#8203;14876](astral-sh/uv#14876))
- Copy entrypoints that have a shebang that differs in `python` vs `python3` ([#&#8203;14970](astral-sh/uv#14970))
- Fix incorrect file permissions in wheel packages ([#&#8203;14930](astral-sh/uv#14930))
- Update validation for `environments` and `required-environments` in `uv.toml` ([#&#8203;14905](astral-sh/uv#14905))

##### Documentation

- Show `uv_build` in projects documentation ([#&#8203;14968](astral-sh/uv#14968))
- Add `UV_` prefix to installer environment variables ([#&#8203;14964](astral-sh/uv#14964))
- Un-hide `uv` from `--build-backend` options ([#&#8203;14939](astral-sh/uv#14939))
- Update documentation for preview flags ([#&#8203;14902](astral-sh/uv#14902))

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this MR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box

---

This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0MS40NS4wIiwidXBkYXRlZEluVmVyIjoiNDEuNDUuMCIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiUmVub3ZhdGUgQm90Il19-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or improvement to existing functionality preview Experimental behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants