Repository navigation
Support workspace metadata without workspace manifests - #22017
charliermarsh merged 2 commits into
Conversation
597d14e to
027ebc9
Compare
027ebc9 to
e64cb9c
Compare
e64cb9c to
2e9e004
Compare
2e9e004 to
a8e034e
Compare
a8e034e to
005545d
Compare
005545d to
08421e7
Compare
08421e7 to
c620959
Compare
c620959 to
e86b5f3
Compare
badd9b9 to
de67764
Compare
de67764 to
7b8ecd3
Compare
7b8ecd3 to
3cf3c96
Compare
3cf3c96 to
cd4790f
Compare
Merging this PR will not alter performance
Comparing Footnotes
|
EliteTK
left a comment
There was a problem hiding this comment.
This problem was introduced in #22103 but only shows up here:
#!/usr/bin/env bash
set -e
tmpdir=$(mktemp -d)
trap 'rm -rf "$tmpdir"' EXIT
cd "$tmpdir"
tmpdir=$(pwd -P)
mkdir foo bar other
cat >pyproject.toml <<EOF
[project]
name = "root"
version = "1.0"
requires-python = ">=3.9"
dependencies = ["bar"]
[tool.uv.sources]
bar = { path = "bar" }
[tool.uv.workspace]
members = ["foo"]
[tool.uv]
conflicts = [[{ package = "root" }, { package = "foo" }]]
EOF
cat >foo/pyproject.toml <<EOF
[project]
name = "foo"
version = "1.0"
EOF
cat >other/pyproject.toml <<EOF
[project]
name = "foo"
version = "2.0"
[build-system]
requires = []
build-backend = "example"
EOF
cat >bar/pyproject.toml <<EOF
[project]
name = "bar"
version = "1.0"
dependencies = ["foo @ file://$tmpdir/other"]
[build-system]
requires = []
build-backend = "example"
EOF
uv lock --offline --quiet --preview-features package-conflicts
args=(workspace metadata --offline
--preview-features workspace-metadata,frozen-lockfile,package-conflicts)
set -x
uv "${args[@]}" >before
rm pyproject.toml foo/pyproject.toml bar/pyproject.toml other/pyproject.toml
uv "${args[@]}" --frozen >after
diff -u before after || trueoutput:
+ uv workspace metadata --offline --preview-features workspace-metadata,frozen-lockfile,package-conflicts
Using CPython 3.14.0
Resolved 4 packages in 8ms
+ rm pyproject.toml foo/pyproject.toml bar/pyproject.toml other/pyproject.toml
+ uv workspace metadata --offline --preview-features workspace-metadata,frozen-lockfile,package-conflicts --frozen
+ diff -u before after
--- before 2026-10-02 14:48:24
+++ after 2026-10-02 14:48:24
@@ -15,7 +15,7 @@
{
"package": "foo",
"kind": "Project",
- "id": "foo==1.0@virtual+.../tmp.2DVqnbZd9z/foo"
+ "id": "foo==2.0@directory+.../tmp.2DVqnbZd9z/other"
},
{
"package": "root",
@@ -29,12 +29,7 @@
"members": [
{
"name": "foo",
- "path": ".../tmp.2DVqnbZd9z/foo",
- "id": "foo==1.0@virtual+.../tmp.2DVqnbZd9z/foo"
- },
- {
- "name": "foo",
- "path": ".../tmp.2DVqnbZd9z/foo",
+ "path": ".../tmp.2DVqnbZd9z/other",
"id": "foo==2.0@directory+.../tmp.2DVqnbZd9z/other"
},
{
+ true
+ rm -rf .../tmp.2DVqnbZd9z
We look up workspace members by package name only, which is insufficient here.
Looks good aside from that.
| enum MetadataTarget<'a> { | ||
| Workspace(&'a Workspace), | ||
| Lockfile(&'a Path), | ||
| Script(&'a Path), | ||
| } |
There was a problem hiding this comment.
Isn't this more of a MetadataSource?
|
|
||
| impl Metadata { | ||
| /// Construct [`Metadata`] for a workspace from a uv lockfile. | ||
| pub fn from_lock(workspace: &Workspace, lock: &Lock) -> Result<Self, MetadataError> { |
There was a problem hiding this comment.
It seems weird to have from_lock and now from_lockfile. One is the workspace oriented version, and the other is the frozen lockfile-only variant. Seems like something should be renamed.
Summary
Allow
uv workspace metadata --frozento discoveruv.lockwhen the workspace manifest is unavailable. We emit a preview warning unless--preview-features frozen-lockfileis enabled. We discover an existing environment relative to the lockfile and include its environment metadata and module ownership.We derive member identities and paths from the lockfile even when workspace manifests are available, so frozen metadata stays consistent when a manifest moves a member.
Lockfile-only metadata requires revision 5 or later.
--syncrequires the workspace manifest in this PR; #22018 adds support for syncing without it.