Skip to content

Support workspace metadata without workspace manifests - #22017

Merged
charliermarsh merged 2 commits into
charlie/frozen-lockfile-treefrom
charlie/frozen-lockfile-metadata
Oct 3, 2026
Merged

charliermarsh merged 2 commits into
charlie/frozen-lockfile-treefrom
charlie/frozen-lockfile-metadata

Conversation

@charliermarsh

@charliermarsh charliermarsh commented Sep 28, 2026 •

Copy link
Copy Markdown
Member

Summary

Allow uv workspace metadata --frozen to discover uv.lock when the workspace manifest is unavailable. We emit a preview warning unless --preview-features frozen-lockfile is 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. --sync requires the workspace manifest in this PR; #22018 adds support for syncing without it.

@charliermarsh
charliermarsh force-pushed the charlie/frozen-lockfile-metadata branch from 597d14e to 027ebc9 Compare September 28, 2026 00:43
@charliermarsh
charliermarsh added this pull request to stack #22012 September 28, 2026 00:43
@charliermarsh
charliermarsh force-pushed the charlie/frozen-lockfile-metadata branch from 027ebc9 to e64cb9c Compare September 28, 2026 00:51
@charliermarsh
charliermarsh force-pushed the charlie/frozen-lockfile-metadata branch from e64cb9c to 2e9e004 Compare September 28, 2026 01:11
@charliermarsh
charliermarsh force-pushed the charlie/frozen-lockfile-metadata branch from 2e9e004 to a8e034e Compare September 28, 2026 01:28
@charliermarsh
charliermarsh force-pushed the charlie/frozen-lockfile-metadata branch from a8e034e to 005545d Compare September 28, 2026 14:02
@charliermarsh charliermarsh changed the title Support workspace metadata directly from lockfiles Support workspace metadata without workspace manifests Sep 28, 2026
@charliermarsh
charliermarsh force-pushed the charlie/frozen-lockfile-metadata branch from 005545d to 08421e7 Compare September 28, 2026 17:19
@charliermarsh
charliermarsh removed this pull request from stack #22012 September 28, 2026 17:21
@charliermarsh
charliermarsh added this pull request to stack #22045 September 28, 2026 17:21
@charliermarsh
charliermarsh force-pushed the charlie/frozen-lockfile-metadata branch from 08421e7 to c620959 Compare September 28, 2026 17:30
@charliermarsh
charliermarsh force-pushed the charlie/frozen-lockfile-metadata branch from c620959 to e86b5f3 Compare September 28, 2026 17:42
@charliermarsh charliermarsh added enhancement New feature or improvement to existing functionality preview Experimental behavior labels Sep 28, 2026
@charliermarsh
charliermarsh marked this pull request as ready for review September 28, 2026 19:22
@charliermarsh
charliermarsh force-pushed the charlie/frozen-lockfile-metadata branch from badd9b9 to de67764 Compare September 28, 2026 19:32
@charliermarsh
charliermarsh force-pushed the charlie/frozen-lockfile-metadata branch from de67764 to 7b8ecd3 Compare September 28, 2026 19:42
@charliermarsh
charliermarsh force-pushed the charlie/frozen-lockfile-metadata branch from 7b8ecd3 to 3cf3c96 Compare September 28, 2026 19:52
@charliermarsh
charliermarsh force-pushed the charlie/frozen-lockfile-metadata branch from 3cf3c96 to cd4790f Compare September 29, 2026 15:59
@charliermarsh
charliermarsh removed this pull request from stack #22048 September 29, 2026 16:00
@codspeed

codspeed Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 54 untouched benchmarks
⏩ 47 skipped benchmarks1


Comparing charlie/frozen-lockfile-metadata (5a6c4cc) with charlie/frozen-lockfile-tree (7cf6cda)

Open in CodSpeed

Footnotes

  1. 47 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

@EliteTK EliteTK left a comment

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.

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 || true

output:

+ 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.

Comment on lines +1258 to +1262
enum MetadataTarget<'a> {
Workspace(&'a Workspace),
Lockfile(&'a Path),
Script(&'a Path),
}

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.

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> {

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.

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.

This branch was successfully deployed

1 active deployment
automations — 5a6c4cce Deployed Oct 2, 2026 by charliermarsh via review / security review #49016
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.

2 participants