Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow distributions to be absent in deserialization #5453

Merged
merged 1 commit into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion crates/uv-resolver/src/lock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -571,8 +571,9 @@ impl Lock {
#[serde(rename_all = "kebab-case")]
struct LockWire {
version: u32,
#[serde(rename = "distribution")]
#[serde(rename = "distribution", default)]
distributions: Vec<DistributionWire>,
#[serde(default)]
requires_python: Option<RequiresPython>,
#[serde(default)]
resolution_mode: ResolutionMode,
Expand Down
43 changes: 43 additions & 0 deletions crates/uv/tests/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,3 +162,46 @@ fn frozen() -> Result<()> {

Ok(())
}

#[test]
fn empty() -> Result<()> {
let context = TestContext::new("3.12");

let pyproject_toml = context.temp_dir.child("pyproject.toml");
pyproject_toml.write_str(
r"
[tool.uv.workspace]
members = []
",
)?;

// Running `uv sync` should generate an empty lockfile.
uv_snapshot!(context.filters(), context.sync(), @r###"
success: true
exit_code: 0
----- stdout -----
----- stderr -----
warning: `uv sync` is experimental and may change without warning
warning: No `requires-python` value found in the workspace. Defaulting to `>=3.12`.
Copy link
Member

Choose a reason for hiding this comment

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

Maybe we should throw a requires-python in there to reduce the noise?

Copy link
Member Author

Choose a reason for hiding this comment

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

Not sure if we "can" since it's a virtual workspace (not a project). I'll try.

Copy link
Member Author

Choose a reason for hiding this comment

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

Typically it would have at least one member.

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 as soon as we add a project field it becomes non-virtual and the package itself gets included in the lockfile (making it non-empty).

Resolved 0 packages in [TIME]
Audited 0 packages in [TIME]
"###);

assert!(context.temp_dir.child("uv.lock").exists());

// Running `uv sync` again should succeed.
uv_snapshot!(context.filters(), context.sync(), @r###"
success: true
exit_code: 0
----- stdout -----
----- stderr -----
warning: `uv sync` is experimental and may change without warning
warning: No `requires-python` value found in the workspace. Defaulting to `>=3.12`.
Resolved 0 packages in [TIME]
Audited 0 packages in [TIME]
"###);

Ok(())
}
Loading