Skip to content

Enable extra build dependencies to 'match runtime' versions#15036

Merged
charliermarsh merged 3 commits intomainfrom
charlie/match-runtime
Aug 5, 2025
Merged

Enable extra build dependencies to 'match runtime' versions#15036
charliermarsh merged 3 commits intomainfrom
charlie/match-runtime

Conversation

@charliermarsh
Copy link
Member

Summary

This is an alternative to #14944 that functions a little differently. Rather than adding separate strategies, you can instead say:

[tool.uv.extra-build-dependencies]
child = [{ requirement = "anyio", match-runtime = true }]

Which will then enforce that anyio uses the same version as in the lockfile.

@charliermarsh charliermarsh added no-build Disable building binaries in CI test:skip Disable running tests for a pull request labels Aug 3, 2025
@charliermarsh charliermarsh force-pushed the charlie/match-runtime branch from ffeb0cf to ddb5edf Compare August 3, 2025 00:39
@charliermarsh charliermarsh requested a review from zanieb August 3, 2025 00:44
@charliermarsh charliermarsh force-pushed the charlie/match-runtime branch from ddb5edf to 7b55e51 Compare August 3, 2025 00:50
@charliermarsh
Copy link
Member Author

(Need to rebase this, then fix the TODO I commented-on above.)

@charliermarsh charliermarsh force-pushed the charlie/match-runtime branch 6 times, most recently from e9eafd4 to 23bd920 Compare August 5, 2025 10:15
@charliermarsh charliermarsh marked this pull request as ready for review August 5, 2025 10:15
@charliermarsh charliermarsh added enhancement New feature or improvement to existing functionality and removed test:skip Disable running tests for a pull request labels Aug 5, 2025
@charliermarsh charliermarsh force-pushed the charlie/match-runtime branch 2 times, most recently from 3918c1a to 6c430d1 Compare August 5, 2025 10:17
@charliermarsh
Copy link
Member Author

I addressed the remaining TODOs, should be ready for review.

@konstin
Copy link
Member

konstin commented Aug 5, 2025

Is it intentional that extra build dependencies work in uv pip too, but match-runtime = true is limited to project mode, while being ignore in uv pip mode? (I can make an MRE if helpful)

@charliermarsh
Copy link
Member Author

We could make it work in uv pip, probably.

@zanieb
Copy link
Member

zanieb commented Aug 5, 2025

It seems fine to defer that to start.

@charliermarsh
Copy link
Member Author

It could help inform the name though... If we intend for that to work, then it's another point against things like locked or match-lockfile etc.

@zanieb
Copy link
Member

zanieb commented Aug 5, 2025

This name has sort of grown on me, fwiw. The entire field is in preview too, so we have some leeway here.

@konstin
Copy link
Member

konstin commented Aug 5, 2025

I'm always in favor of smaller PRs and adding this another PR :) I do see the current behavior (match-runtime is ignored in uv pip without warning) as a blocker to stabilization, we should interpret the extra build deps table the same between project mode and uv pip for extra build dependencies.

child = { path = "child" }

[tool.uv.extra-build-dependencies]
child = [{ requirement = "anyio", match-runtime = true }]
Copy link
Member

Choose a reason for hiding this comment

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

We should call this requires instead of requirement to by consistent with PEP 517 (It's still a str here and a list in PEP 517, but it's the same key)

Copy link
Member

Choose a reason for hiding this comment

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

I don't think I agree — I don't think that's particularly clearer and matching build-requires isn't really a goal here, i.e., it's not called extra-build-requires.

child = [{ requirement = "anyio", match-runtime = true }]
"#})?;

// The child should be rebuilt with anyio 3.7, without `--reinstall`
Copy link
Member

Choose a reason for hiding this comment

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

Can you add a test where we change the requirement in a compatible way (say anyio>3.1 to anyio>3.2) to track whether we rebuild?

Copy link
Member

Choose a reason for hiding this comment

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

What happens if the requirement has a pin or constraint that's incompatible with the runtime dist version? We should error, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

I was considering erroring entirely if a version specifier or constraint is provided with match-runtime = true. What do you think?

Copy link
Member Author

Choose a reason for hiding this comment

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

It would be relatively easy to support preserving both though. We'd just add a new requirement here rather than overwriting, and let the resolver do the rest.

Copy link
Member

Choose a reason for hiding this comment

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

It seems okay to eagerly fail if any constraint is provided. It's plausible someone will have a use-case for it? but I can't think of one right now.

Copy link
Member

Choose a reason for hiding this comment

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

I think letting the resolver handle it sounds cool, but we'd probably need to add a hint to the error for it to be a good experience and that sounds like more work we don't want to tackle rn.

Copy link
Member Author

Choose a reason for hiding this comment

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

Okay, made it reject for now.

@charliermarsh charliermarsh force-pushed the charlie/match-runtime branch from 6c430d1 to 0b389f0 Compare August 5, 2025 17:03
@charliermarsh charliermarsh temporarily deployed to uv-test-registries August 5, 2025 17:06 — with GitHub Actions Inactive
@charliermarsh charliermarsh temporarily deployed to uv-test-registries August 5, 2025 17:40 — with GitHub Actions Inactive
@charliermarsh charliermarsh force-pushed the charlie/match-runtime branch from acd9d45 to 4883084 Compare August 5, 2025 17:43
@charliermarsh charliermarsh temporarily deployed to uv-test-registries August 5, 2025 17:46 — with GitHub Actions Inactive
@charliermarsh charliermarsh merged commit 8ef3b2e into main Aug 5, 2025
92 checks passed
@charliermarsh charliermarsh deleted the charlie/match-runtime branch August 5, 2025 18:00
tmeijn pushed a commit to tmeijn/dotfiles that referenced this pull request Aug 6, 2025
This MR contains the following updates:

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

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.5`](https://github.com/astral-sh/uv/blob/HEAD/CHANGELOG.md#085)

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

##### Enhancements

- Enable `uv run` with a GitHub Gist ([#&#8203;15058](astral-sh/uv#15058))
- Improve HTTP response caching log messages ([#&#8203;15067](astral-sh/uv#15067))
- Show wheel tag hints in install plan ([#&#8203;15066](astral-sh/uv#15066))
- Support installing additional executables in `uv tool install` ([#&#8203;14014](astral-sh/uv#14014))

##### Preview features

- Enable extra build dependencies to 'match runtime' versions ([#&#8203;15036](astral-sh/uv#15036))
- Remove duplicate `extra-build-dependencies` warnings for `uv pip` ([#&#8203;15088](astral-sh/uv#15088))
- Use "option" instead of "setting" in `pylock` warning ([#&#8203;15089](astral-sh/uv#15089))
- Respect extra build requires when reading from wheel cache ([#&#8203;15030](astral-sh/uv#15030))
- Preserve lowered extra build dependencies ([#&#8203;15038](astral-sh/uv#15038))

##### Bug fixes

- Add Python versions to markers implied from wheels ([#&#8203;14913](astral-sh/uv#14913))
- Ensure consistent indentation when adding dependencies ([#&#8203;14991](astral-sh/uv#14991))
- Fix handling of `python-preference = system` when managed interpreters are on the PATH ([#&#8203;15059](astral-sh/uv#15059))
- Fix symlink preservation in virtual environment creation ([#&#8203;14933](astral-sh/uv#14933))
- Gracefully handle entrypoint permission errors ([#&#8203;15026](astral-sh/uv#15026))
- Include wheel hashes from local Simple indexes ([#&#8203;14993](astral-sh/uv#14993))
- Prefer system Python installations over managed ones when `--system` is used ([#&#8203;15061](astral-sh/uv#15061))
- Remove retry wrapper when matching on error kind ([#&#8203;14996](astral-sh/uv#14996))
- Revert `h2` upgrade ([#&#8203;15079](astral-sh/uv#15079))

##### Documentation

- Improve visibility of copy and line separator in dark mode ([#&#8203;14987](astral-sh/uv#14987))

</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:eyJjcmVhdGVkSW5WZXIiOiI0MS41Mi4yIiwidXBkYXRlZEluVmVyIjoiNDEuNTIuMiIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiUmVub3ZhdGUgQm90Il19-->
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 no-build Disable building binaries in CI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Comments