Skip to content

Commit db96d41

Browse files
authored
Write resolved constraints to [tool.uv] constraint-dependencies (#90)
* Add design spec for native uv constraint-dependencies support * Refine spec: preserve source order and provenance comments in uv constraint-dependencies * Spec: mark tomlkit array-comment risk as de-risked via spike * Spec: confirm keeping mxdev-disabled markers in constraint-dependencies array * Add implementation plan for uv constraint-dependencies * Add _constraints_to_uv: turn resolved constraints into uv array items * uv hook: write resolved constraints to [tool.uv] constraint-dependencies * Add end-to-end test for uv constraint-dependencies from -c chain * Document uv constraint-dependencies and add attribution * Update CHANGES.md for uv constraint-dependencies
1 parent 0ff5368 commit db96d41

6 files changed

Lines changed: 1000 additions & 3 deletions

File tree

CHANGES.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22

33
## 5.3.3 (unreleased)
44

5-
<!-- Add future changes here -->
5+
- The uv hook now writes the fully resolved constraints (including external `-c`/`-r`
6+
chains like Plone release constraints) into `[tool.uv] constraint-dependencies`, so
7+
`uv sync` honors them. Source order and provenance comments are preserved; the array is
8+
fully managed by mxdev. Disable via `uv-constraint-dependencies = false` in `[settings]`.
9+
Inspired by Maik Derstappen's `uv-import-constraint-dependencies`. [jensens]
610

711

812
## 5.3.2 (2026-05-30)

README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,33 @@ override-dependencies = [
330330

331331
This allows you to seamlessly use `uv sync` or `uv run` with the packages mxdev has checked out for you, without needing to use `requirements-mxdev.txt`.
332332

333+
The fully resolved constraints — including external `-c`/`-r` chains such as Plone
334+
release constraints (`-c https://dist.plone.org/release/6.2.0rc1/constraints.txt`) — are
335+
written to `[tool.uv] constraint-dependencies`. uv itself cannot follow `-c URL` includes,
336+
so mxdev expands the whole chain and inlines the pins, preserving source order and the
337+
`# begin/end constraints from: ...` provenance comments. Packages developed from source or
338+
replaced via `version-overrides` are kept as `# ... -> mxdev disabled` comments (they are
339+
provided through `[tool.uv.sources]` / `override-dependencies` instead):
340+
341+
```toml
342+
[tool.uv]
343+
constraint-dependencies = [
344+
# managed by mxdev - do not edit
345+
# begin constraints from: https://dist.plone.org/release/6.2.0rc1/constraints.txt
346+
"Zope==6.0",
347+
"AccessControl==7.3",
348+
# end constraints from: https://dist.plone.org/release/6.2.0rc1/constraints.txt
349+
]
350+
```
351+
352+
mxdev owns this array completely and rewrites it on every run. To turn it off, set in
353+
`mx.ini`:
354+
355+
```ini
356+
[settings]
357+
uv-constraint-dependencies = false
358+
```
359+
333360
To disable this feature, you can either remove the `managed = true` flag from your `pyproject.toml`, or explicitly set it to `false`:
334361
```toml
335362
[tool.uv]
@@ -408,3 +435,7 @@ Mx (generally pronounced like mix [mɪks], or [məks] in the UK) is meant to be
408435
The VCS-related code is taken from `mr.developer`.
409436
Thanks to Florian Schulze and Contributors.
410437

438+
The approach of importing pip constraints into `[tool.uv] constraint-dependencies` was
439+
inspired by Maik Derstappen's [uv-import-constraint-dependencies](https://github.com/derico-de/uv-import-constraint-dependencies).
440+
Thanks to Maik for the idea and his blessing to adopt it natively.
441+

0 commit comments

Comments
 (0)