mirror of https://github.com/astral-sh/uv
Discard forks when using `--upgrade` (#5905)
Fixes #5817 Needs https://github.com/astral-sh/packse/pull/213 for the test to pass.
This commit is contained in:
parent
1e6b021506
commit
eed23be1bd
|
|
@ -420,8 +420,12 @@ async fn do_lock(
|
|||
// "preferences-dependent-forking" packse scenario). To avoid this, we store the forks in the
|
||||
// lockfile. We read those after all the lockfile filters, to allow the forks to change when
|
||||
// the environment changed, e.g. the python bound check above can lead to different forking.
|
||||
let resolver_markers =
|
||||
ResolverMarkers::universal(existing_lock.and_then(|lock| lock.fork_markers().clone()));
|
||||
let resolver_markers = ResolverMarkers::universal(if upgrade.is_all() {
|
||||
// We're discarding all preferences, so we're also discarding the existing forks.
|
||||
None
|
||||
} else {
|
||||
existing_lock.and_then(|lock| lock.fork_markers().clone())
|
||||
});
|
||||
|
||||
let resolution = match existing_lock.filter(|_| upgrade.is_none()) {
|
||||
None => None,
|
||||
|
|
|
|||
|
|
@ -1,11 +1,13 @@
|
|||
#![cfg(all(feature = "python", feature = "pypi"))]
|
||||
|
||||
use anyhow::Result;
|
||||
use assert_cmd::assert::OutputAssertExt;
|
||||
use assert_fs::prelude::*;
|
||||
use indoc::{formatdoc, indoc};
|
||||
use insta::assert_snapshot;
|
||||
use url::Url;
|
||||
|
||||
use crate::common::packse_index_url;
|
||||
use common::{uv_snapshot, TestContext};
|
||||
|
||||
mod common;
|
||||
|
|
@ -2208,10 +2210,6 @@ fn lock_upgrade_log_multi_version() -> Result<()> {
|
|||
lock, @r###"
|
||||
version = 1
|
||||
requires-python = ">=3.12"
|
||||
environment-markers = [
|
||||
"sys_platform == 'win32'",
|
||||
"sys_platform != 'win32'",
|
||||
]
|
||||
|
||||
[options]
|
||||
exclude-newer = "2024-03-25 00:00:00 UTC"
|
||||
|
|
@ -5804,3 +5802,42 @@ fn lock_upgrade_package() -> Result<()> {
|
|||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Check that we discard the fork marker from the lockfile when using `--upgrade`.
|
||||
#[test]
|
||||
fn lock_upgrade_drop_fork_markers() -> Result<()> {
|
||||
let context = TestContext::new("3.12");
|
||||
|
||||
let requirements = r#"[project]
|
||||
name = "forking"
|
||||
version = "0.1.0"
|
||||
requires-python = ">=3.12"
|
||||
dependencies = ["fork-upgrade-foo==1"]
|
||||
"#;
|
||||
|
||||
let pyproject_toml = context.temp_dir.child("pyproject.toml");
|
||||
pyproject_toml.write_str(requirements)?;
|
||||
context
|
||||
.lock()
|
||||
.arg("--index-url")
|
||||
.arg(packse_index_url())
|
||||
.env_remove("UV_EXCLUDE_NEWER")
|
||||
.assert()
|
||||
.success();
|
||||
let lock = fs_err::read_to_string(context.temp_dir.join("uv.lock")).unwrap();
|
||||
assert!(lock.contains("environment-markers"));
|
||||
|
||||
// Remove the bound and lock with `--upgrade`.
|
||||
pyproject_toml.write_str(&requirements.replace("fork-upgrade-foo==1", "fork-upgrade-foo"))?;
|
||||
context
|
||||
.lock()
|
||||
.arg("--index-url")
|
||||
.arg(packse_index_url())
|
||||
.env_remove("UV_EXCLUDE_NEWER")
|
||||
.arg("--upgrade")
|
||||
.assert()
|
||||
.success();
|
||||
let lock = fs_err::read_to_string(context.temp_dir.join("uv.lock")).unwrap();
|
||||
assert!(!lock.contains("environment-markers"));
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue