diff --git a/docs/reference/cli.md b/docs/reference/cli.md index 13b6d9958..18375ec6b 100644 --- a/docs/reference/cli.md +++ b/docs/reference/cli.md @@ -216,6 +216,16 @@ pixi upgrade --json pixi upgrade --dry-run ``` +!!! note + The `pixi upgrade` command will only update `version`s, except when you specify the exact package name (`pixi upgrade numpy`). + + Then it will remove all fields, apart from: + - `build` field containing a wildcard `*` + - `channel` + - `file_name` + - `url` + - `subdir`. + ## `run` The `run` commands first checks if the environment is ready to use. diff --git a/src/cli/upgrade.rs b/src/cli/upgrade.rs index 428e3a5b0..9d773d530 100644 --- a/src/cli/upgrade.rs +++ b/src/cli/upgrade.rs @@ -1,5 +1,4 @@ use std::cmp::Ordering; -use std::sync::Arc; use crate::cli::cli_config::ProjectConfig; use crate::Project; @@ -17,7 +16,7 @@ use pixi_manifest::FeatureName; use pixi_manifest::PyPiRequirement; use pixi_manifest::SpecType; use pixi_spec::PixiSpec; -use rattler_conda_types::MatchSpec; +use rattler_conda_types::{MatchSpec, StringMatcher}; /// Update dependencies as recorded in the local lock file #[derive(Parser, Debug, Default)] @@ -111,24 +110,46 @@ pub async fn execute(args: Args) -> miette::Result<()> { // Only upgrade version specs .filter_map(|(name, req)| match req { PixiSpec::DetailedVersion(version_spec) => { - let channel = version_spec - .channel - .and_then(|c| c.into_channel(&project.channel_config()).ok()) - .map(Arc::new); + let mut nameless_match_spec = version_spec + .try_into_nameless_match_spec(&project.channel_config()) + .ok()?; + // If it is a detailed spec, always unset version + nameless_match_spec.version = None; + + // If the package as specifically requested, unset more fields + if let Some(packages) = &args.specs.packages { + if packages.contains(&name.as_normalized().to_string()) { + // If the build contains a wildcard, keep it + nameless_match_spec.build = match nameless_match_spec.build { + Some( + build @ StringMatcher::Glob(_) | build @ StringMatcher::Regex(_), + ) => Some(build), + _ => None, + }; + nameless_match_spec.build_number = None; + nameless_match_spec.md5 = None; + nameless_match_spec.sha256 = None; + // These are still to sensitive to be unset, so skipping these for now + // nameless_match_spec.url = None; + // nameless_match_spec.file_name = None; + // nameless_match_spec.channel = None; + // nameless_match_spec.subdir = None; + } + } + Some(( name.clone(), ( - MatchSpec { - name: Some(name), - channel, - ..Default::default() - }, + MatchSpec::from_nameless(nameless_match_spec, Some(name)), spec_type, ), )) } PixiSpec::Version(_) => Some((name.clone(), (MatchSpec::from(name), spec_type))), - _ => None, + _ => { + tracing::debug!("skipping non-version spec {:?}", req); + None + } }) .collect(); @@ -152,6 +173,7 @@ pub async fn execute(args: Args) -> miette::Result<()> { Requirement { name: name.as_normalized().clone(), extras, + // TODO: Add marker support here to avoid overwriting existing markers marker: MarkerTree::default(), origin: None, version_or_url: None, diff --git a/tests/data/channels/channels/multiple_versions_channel_1/linux-64/package3-0.1.0-abc.conda b/tests/data/channels/channels/multiple_versions_channel_1/linux-64/package3-0.1.0-abc.conda new file mode 100644 index 000000000..dcfd9c392 Binary files /dev/null and b/tests/data/channels/channels/multiple_versions_channel_1/linux-64/package3-0.1.0-abc.conda differ diff --git a/tests/data/channels/channels/multiple_versions_channel_1/linux-64/package3-0.2.0-abc.conda b/tests/data/channels/channels/multiple_versions_channel_1/linux-64/package3-0.2.0-abc.conda new file mode 100644 index 000000000..fc292c7fd Binary files /dev/null and b/tests/data/channels/channels/multiple_versions_channel_1/linux-64/package3-0.2.0-abc.conda differ diff --git a/tests/data/channels/channels/multiple_versions_channel_1/linux-64/repodata.json b/tests/data/channels/channels/multiple_versions_channel_1/linux-64/repodata.json index 6caed42de..22e20eb6f 100644 --- a/tests/data/channels/channels/multiple_versions_channel_1/linux-64/repodata.json +++ b/tests/data/channels/channels/multiple_versions_channel_1/linux-64/repodata.json @@ -9,13 +9,13 @@ "build": "hb0f4dca_0", "build_number": 0, "depends": [], - "md5": "a2f28b306e1ad1196ca6dae59e96a18d", + "md5": "eda5e13e034ed30fabbb49d6adec78af", "name": "package", "platform": "linux", - "sha256": "cc382444ece609943e5d4ec18abf5aeabfc364ac59c1eed30c89524db92c8805", - "size": 1237, + "sha256": "cd7e704f3a54e76a9a2f386d695e388039a63b4d5ed2e57f9c13c30dd6978cd1", + "size": 1253, "subdir": "linux-64", - "timestamp": 1730898132739, + "timestamp": 1731504816716, "version": "0.1.0" }, "package-0.2.0-hb0f4dca_0.conda": { @@ -23,13 +23,13 @@ "build": "hb0f4dca_0", "build_number": 0, "depends": [], - "md5": "868a498e8f36354c28d91005752797d5", + "md5": "cead91f7d9e6bbd014b5781c63684fef", "name": "package", "platform": "linux", - "sha256": "74fc123c3902ba53e570ed9172a591d7025cec9995193500bd4aee672a565da3", - "size": 1239, + "sha256": "7588a51e818dc716df8d0748db902c37d170102360bc2464e8edafdef40a28d5", + "size": 1252, "subdir": "linux-64", - "timestamp": 1730898132949, + "timestamp": 1731504816943, "version": "0.2.0" }, "package2-0.1.0-hb0f4dca_0.conda": { @@ -37,13 +37,13 @@ "build": "hb0f4dca_0", "build_number": 0, "depends": [], - "md5": "e764e06f7d440c3358f10a4e15f8bda5", + "md5": "4f840c89f3a644a666b529d58084c320", "name": "package2", "platform": "linux", - "sha256": "f0826cb7a6f56741d320dbfd783d28c7ea63b860ac4abcaa73373c0e408fe9d3", - "size": 1161, + "sha256": "1ebbb8ff9b7018a3363074b1d8536a2ca5d658153368458a9c129cd6edd38cc2", + "size": 1181, "subdir": "linux-64", - "timestamp": 1730898132739, + "timestamp": 1731504816715, "version": "0.1.0" }, "package2-0.2.0-hb0f4dca_0.conda": { @@ -51,13 +51,41 @@ "build": "hb0f4dca_0", "build_number": 0, "depends": [], - "md5": "2341a61eac6973353c46a795a292b8f9", + "md5": "ebef22cf4f0313a21065ae4856e335e5", "name": "package2", "platform": "linux", - "sha256": "3269562fee84b6c1b5af97bfb31d0db6c128a7253f16e60895bd4117408ec58c", - "size": 1158, + "sha256": "20c4af256078236462b16f329b71f6c89818f72174482f5cf02fd3a536aab494", + "size": 1179, "subdir": "linux-64", - "timestamp": 1730898132949, + "timestamp": 1731504816942, + "version": "0.2.0" + }, + "package3-0.1.0-abc.conda": { + "arch": "x86_64", + "build": "abc", + "build_number": 1, + "depends": [], + "md5": "1b94f7d0d9813fb55d9d60dcbb096219", + "name": "package3", + "platform": "linux", + "sha256": "61ffb579d1f2e5d1c6423e97f0c9def9501d17ea5d012dc2fcf55e86ed139aba", + "size": 1149, + "subdir": "linux-64", + "timestamp": 1731504816716, + "version": "0.1.0" + }, + "package3-0.2.0-abc.conda": { + "arch": "x86_64", + "build": "abc", + "build_number": 1, + "depends": [], + "md5": "686ce11c0f47d1d39dd015219d62b1ce", + "name": "package3", + "platform": "linux", + "sha256": "919f961cfe8fa046f487ef07e20a736efcd57ac0a4966b1f26a29fc6bfa420ba", + "size": 1148, + "subdir": "linux-64", + "timestamp": 1731504816942, "version": "0.2.0" } }, diff --git a/tests/data/channels/channels/multiple_versions_channel_1/osx-64/package3-0.1.0-abc.conda b/tests/data/channels/channels/multiple_versions_channel_1/osx-64/package3-0.1.0-abc.conda new file mode 100644 index 000000000..4f579dac9 Binary files /dev/null and b/tests/data/channels/channels/multiple_versions_channel_1/osx-64/package3-0.1.0-abc.conda differ diff --git a/tests/data/channels/channels/multiple_versions_channel_1/osx-64/package3-0.2.0-abc.conda b/tests/data/channels/channels/multiple_versions_channel_1/osx-64/package3-0.2.0-abc.conda new file mode 100644 index 000000000..a98dac911 Binary files /dev/null and b/tests/data/channels/channels/multiple_versions_channel_1/osx-64/package3-0.2.0-abc.conda differ diff --git a/tests/data/channels/channels/multiple_versions_channel_1/osx-64/repodata.json b/tests/data/channels/channels/multiple_versions_channel_1/osx-64/repodata.json index 608b2a966..bf91c9fe8 100644 --- a/tests/data/channels/channels/multiple_versions_channel_1/osx-64/repodata.json +++ b/tests/data/channels/channels/multiple_versions_channel_1/osx-64/repodata.json @@ -9,13 +9,13 @@ "build": "h0dc7051_0", "build_number": 0, "depends": [], - "md5": "4e840b763722d23947a58cb583598112", + "md5": "cd5cefae6b8ee44483c1f5d1926f479c", "name": "package", "platform": "osx", - "sha256": "6879c4592a030f28f6d971b2f22668179ce4f795205b44a29b0338ab612f7a51", - "size": 1231, + "sha256": "1b5b1605043908b3c57a0b0b1bb82836f760014d2f37fb92a8bd0b56cd5e74c4", + "size": 1254, "subdir": "osx-64", - "timestamp": 1730898132845, + "timestamp": 1731504816824, "version": "0.1.0" }, "package-0.2.0-h0dc7051_0.conda": { @@ -23,13 +23,13 @@ "build": "h0dc7051_0", "build_number": 0, "depends": [], - "md5": "8cc0b6cec2e59931ddadca42240ff7f0", + "md5": "6216bf1cac37a1230527e672861e95cc", "name": "package", "platform": "osx", - "sha256": "6dab29d04cf60699d6e3b63247dbbb76212f707f79d4ec7660d42553684a02fe", - "size": 1230, + "sha256": "eef67185a1e033337b01989855e940245e419b994398cc1145cfe67de1853adc", + "size": 1255, "subdir": "osx-64", - "timestamp": 1730898133054, + "timestamp": 1731504817061, "version": "0.2.0" }, "package2-0.1.0-h0dc7051_0.conda": { @@ -37,13 +37,13 @@ "build": "h0dc7051_0", "build_number": 0, "depends": [], - "md5": "55569971ef4023d3d8bc4406e07dfd50", + "md5": "42a10f70e5336177d03bdf980dcf52ed", "name": "package2", "platform": "osx", - "sha256": "25f70b1283ccdc00cd052d0b392d2fc11753574073eb00140f5064b1c587eccd", - "size": 1159, + "sha256": "610b69d5176142ceb2ff50585b37d4eae15d870a3dbae4b6b35e92160f3de258", + "size": 1179, "subdir": "osx-64", - "timestamp": 1730898132846, + "timestamp": 1731504816824, "version": "0.1.0" }, "package2-0.2.0-h0dc7051_0.conda": { @@ -51,13 +51,41 @@ "build": "h0dc7051_0", "build_number": 0, "depends": [], - "md5": "fbbb2080c0cf031504886eaf4e57c6a4", + "md5": "6adffa07bbf495bd712505127f7777d3", "name": "package2", "platform": "osx", - "sha256": "7b0844fb3358077e0929c5c3da1d11c68514b8a29bba7ee766073f600be03a76", - "size": 1158, + "sha256": "ce887fbf6af0fadaf2686bde2cb325eafef52baafc5b5f6f2f24dd501aa01505", + "size": 1178, "subdir": "osx-64", - "timestamp": 1730898133054, + "timestamp": 1731504817061, + "version": "0.2.0" + }, + "package3-0.1.0-abc.conda": { + "arch": "x86_64", + "build": "abc", + "build_number": 1, + "depends": [], + "md5": "f6b3b14366eb72ab782986536ecb351d", + "name": "package3", + "platform": "osx", + "sha256": "abeec449f4886f35ca1aab2ada497d0f12cf600bc86b9cd0f38b8fc4b2c46a60", + "size": 1146, + "subdir": "osx-64", + "timestamp": 1731504816824, + "version": "0.1.0" + }, + "package3-0.2.0-abc.conda": { + "arch": "x86_64", + "build": "abc", + "build_number": 1, + "depends": [], + "md5": "b0220ddbc2488a2fc2fddd581812aa34", + "name": "package3", + "platform": "osx", + "sha256": "fca31c056b6ad5949d444fd95d9dbf0eaaa5a748e97dc5ddf1abf85fff4203cd", + "size": 1145, + "subdir": "osx-64", + "timestamp": 1731504817061, "version": "0.2.0" } }, diff --git a/tests/data/channels/channels/multiple_versions_channel_1/osx-arm64/package3-0.1.0-abc.conda b/tests/data/channels/channels/multiple_versions_channel_1/osx-arm64/package3-0.1.0-abc.conda new file mode 100644 index 000000000..99340f894 Binary files /dev/null and b/tests/data/channels/channels/multiple_versions_channel_1/osx-arm64/package3-0.1.0-abc.conda differ diff --git a/tests/data/channels/channels/multiple_versions_channel_1/osx-arm64/package3-0.2.0-abc.conda b/tests/data/channels/channels/multiple_versions_channel_1/osx-arm64/package3-0.2.0-abc.conda new file mode 100644 index 000000000..ac4c9a7dc Binary files /dev/null and b/tests/data/channels/channels/multiple_versions_channel_1/osx-arm64/package3-0.2.0-abc.conda differ diff --git a/tests/data/channels/channels/multiple_versions_channel_1/osx-arm64/repodata.json b/tests/data/channels/channels/multiple_versions_channel_1/osx-arm64/repodata.json index 1896d3393..7e41a04e6 100644 --- a/tests/data/channels/channels/multiple_versions_channel_1/osx-arm64/repodata.json +++ b/tests/data/channels/channels/multiple_versions_channel_1/osx-arm64/repodata.json @@ -9,13 +9,13 @@ "build": "h60d57d3_0", "build_number": 0, "depends": [], - "md5": "066f9bdf289cc4e12ed885bcffdb026b", + "md5": "54a8e5f584012d2c2a90ee36b8fa4d9b", "name": "package", "platform": "osx", - "sha256": "d81a3861e03f8f90dbb4ece27bafc267564a5dd6667f81af2a78fd0618ec7147", - "size": 1238, + "sha256": "54cacbb4f9e6b2bc525a498047b0bdf3a7c633f4be2efa63a0d20d77b9dd70bc", + "size": 1255, "subdir": "osx-arm64", - "timestamp": 1730898132792, + "timestamp": 1731504816770, "version": "0.1.0" }, "package-0.2.0-h60d57d3_0.conda": { @@ -23,13 +23,13 @@ "build": "h60d57d3_0", "build_number": 0, "depends": [], - "md5": "a38507e7536708b09b42ec84103eb635", + "md5": "b6f34dee13e2d1fa1f53e461db68a804", "name": "package", "platform": "osx", - "sha256": "a0562541a0cb6f91fba34734ff2fa4bf31dbe2d5f42b6bf7372160c7063f1bd2", - "size": 1230, + "sha256": "dac9087cab9d8118aebfff7c7025caf73b7898f27bdf2e5280b6184188aa12b4", + "size": 1255, "subdir": "osx-arm64", - "timestamp": 1730898133, + "timestamp": 1731504817004, "version": "0.2.0" }, "package2-0.1.0-h60d57d3_0.conda": { @@ -37,13 +37,13 @@ "build": "h60d57d3_0", "build_number": 0, "depends": [], - "md5": "d91c7863513e7900022e2847fa709c44", + "md5": "2fab185533f1a148111e10c0e9eb6ae3", "name": "package2", "platform": "osx", - "sha256": "54b560e721fae0674ce64ede3cc12e93a33ccee0164b08af9b88de2ad1bf537a", - "size": 1159, + "sha256": "39ec0d7a3253c5b57c7b28f159e958682515e74c0ce2ced29a56879682dad5ed", + "size": 1178, "subdir": "osx-arm64", - "timestamp": 1730898132792, + "timestamp": 1731504816769, "version": "0.1.0" }, "package2-0.2.0-h60d57d3_0.conda": { @@ -51,13 +51,41 @@ "build": "h60d57d3_0", "build_number": 0, "depends": [], - "md5": "da479bbc76cf304ff31f5d4a3610364f", + "md5": "0ccd3bd6e89eee05b2bde619f35d0ec7", "name": "package2", "platform": "osx", - "sha256": "6788f6d1d79bbdc280eee31d9565ca6e355cfe83198aa8c9b8468892e22f9d0a", - "size": 1151, + "sha256": "36ebaee298f7e0835f16d4dbd5f70e3d14ec2010e84fb5eed78b71f77a5af974", + "size": 1178, "subdir": "osx-arm64", - "timestamp": 1730898133, + "timestamp": 1731504817004, + "version": "0.2.0" + }, + "package3-0.1.0-abc.conda": { + "arch": "arm64", + "build": "abc", + "build_number": 1, + "depends": [], + "md5": "641baaeddbbaf30048cb4907bf353915", + "name": "package3", + "platform": "osx", + "sha256": "e0b6f97664134fbd347201f06445a4fd4c5d6603fb5b13eb92b0724b20a8d494", + "size": 1147, + "subdir": "osx-arm64", + "timestamp": 1731504816770, + "version": "0.1.0" + }, + "package3-0.2.0-abc.conda": { + "arch": "arm64", + "build": "abc", + "build_number": 1, + "depends": [], + "md5": "3c1b2b9eb6dbc745d764632b1d606883", + "name": "package3", + "platform": "osx", + "sha256": "5e9bcb10865c04afebf6dcb0f297b678e8d4352fb876fb44842ddea53ca667d3", + "size": 1147, + "subdir": "osx-arm64", + "timestamp": 1731504817004, "version": "0.2.0" } }, diff --git a/tests/data/channels/channels/multiple_versions_channel_1/win-64/package3-0.1.0-abc.conda b/tests/data/channels/channels/multiple_versions_channel_1/win-64/package3-0.1.0-abc.conda new file mode 100644 index 000000000..de690f9ed Binary files /dev/null and b/tests/data/channels/channels/multiple_versions_channel_1/win-64/package3-0.1.0-abc.conda differ diff --git a/tests/data/channels/channels/multiple_versions_channel_1/win-64/package3-0.2.0-abc.conda b/tests/data/channels/channels/multiple_versions_channel_1/win-64/package3-0.2.0-abc.conda new file mode 100644 index 000000000..dfe10a34f Binary files /dev/null and b/tests/data/channels/channels/multiple_versions_channel_1/win-64/package3-0.2.0-abc.conda differ diff --git a/tests/data/channels/channels/multiple_versions_channel_1/win-64/repodata.json b/tests/data/channels/channels/multiple_versions_channel_1/win-64/repodata.json index dfa9f377a..6556a6102 100644 --- a/tests/data/channels/channels/multiple_versions_channel_1/win-64/repodata.json +++ b/tests/data/channels/channels/multiple_versions_channel_1/win-64/repodata.json @@ -9,13 +9,13 @@ "build": "h9490d1a_0", "build_number": 0, "depends": [], - "md5": "745d63cedc7ab134762eed55fa130224", + "md5": "733cbca029f63164981aa6cbd35f6737", "name": "package", "platform": "win", - "sha256": "3ca104fc659f7e7d43f028665ff009b1afbd1df45c6a55787176eda973746a87", - "size": 1240, + "sha256": "3d04fd717d06b36e31e750b4154cff9fbcb8d8421ca4c83d8b78f6cfbf5def06", + "size": 1263, "subdir": "win-64", - "timestamp": 1730898132680, + "timestamp": 1731504816663, "version": "0.1.0" }, "package-0.2.0-h9490d1a_0.conda": { @@ -23,13 +23,13 @@ "build": "h9490d1a_0", "build_number": 0, "depends": [], - "md5": "986f652f269e8ac205f395581a5cc59f", + "md5": "cf371c15b424263bc4b438a668591b72", "name": "package", "platform": "win", - "sha256": "c5d72e133b9f37f2030a92149375f1ae1a6ac5bcfc3e373364c4bbf5dbeb8c98", - "size": 1241, + "sha256": "5513e6dca4c70224e0ee979b2fd3e0e4c63d5d74940f50e0134cd432d3eec429", + "size": 1267, "subdir": "win-64", - "timestamp": 1730898132900, + "timestamp": 1731504816889, "version": "0.2.0" }, "package2-0.1.0-h9490d1a_0.conda": { @@ -37,13 +37,13 @@ "build": "h9490d1a_0", "build_number": 0, "depends": [], - "md5": "ed3dbf7b4f1b80b63f9ff6e34c5501a8", + "md5": "b1910c5bb7e2f0e0c2a7e95d248a559b", "name": "package2", "platform": "win", - "sha256": "1038a96bafb2fb49357848d5c9aca6a67cdd89d6c4d04ed6ce4480eff6b81a81", - "size": 1169, + "sha256": "5a883cb674b0f38878f1a24c4f3f212ebcae0396ead2a18ef1b833507f432ccd", + "size": 1191, "subdir": "win-64", - "timestamp": 1730898132681, + "timestamp": 1731504816663, "version": "0.1.0" }, "package2-0.2.0-h9490d1a_0.conda": { @@ -51,13 +51,41 @@ "build": "h9490d1a_0", "build_number": 0, "depends": [], - "md5": "07a7e70d365efdcc754bf329feb3d95a", + "md5": "c929b114201d0126313c1c3e516635dd", "name": "package2", "platform": "win", - "sha256": "ea6324a02aaf3f5ef7ad9f3e164aeb81f8c7dd46b5b25eb026101c53d81aca47", - "size": 1168, + "sha256": "c5720f1e7152093a441c7d94ba50fd29011262021fcd3316e9b0741234a61a56", + "size": 1191, "subdir": "win-64", - "timestamp": 1730898132900, + "timestamp": 1731504816889, + "version": "0.2.0" + }, + "package3-0.1.0-abc.conda": { + "arch": "x86_64", + "build": "abc", + "build_number": 1, + "depends": [], + "md5": "52efac3ff5c1c9e29b1ed63abcaa6b15", + "name": "package3", + "platform": "win", + "sha256": "3876959677ee92a9d455c978a30a6b0d1816a034b28a82cfcf94374e9711bbd6", + "size": 1159, + "subdir": "win-64", + "timestamp": 1731504816663, + "version": "0.1.0" + }, + "package3-0.2.0-abc.conda": { + "arch": "x86_64", + "build": "abc", + "build_number": 1, + "depends": [], + "md5": "ba7358eb624281c8ee958cdaf982376f", + "name": "package3", + "platform": "win", + "sha256": "83817100dc1aaacdc33449aea3072057fdab300fd40180d4caa9db6a6ed02c82", + "size": 1159, + "subdir": "win-64", + "timestamp": 1731504816889, "version": "0.2.0" } }, diff --git a/tests/data/channels/recipes/multiple_versions_channel_1_010.yaml b/tests/data/channels/recipes/multiple_versions_channel_1_010.yaml index d1abfb773..121ac5ab0 100644 --- a/tests/data/channels/recipes/multiple_versions_channel_1_010.yaml +++ b/tests/data/channels/recipes/multiple_versions_channel_1_010.yaml @@ -37,3 +37,19 @@ outputs: else: - echo "package2$PKG_VERSION on unix" > $PREFIX/bin/package2 - chmod +x $PREFIX/bin/package2 + + - package: + name: package3 + version: ${{ version }} + + build: + number: 1 + string: abc + script: + - mkdir -p $PREFIX/bin + - if: win + then: + - echo "package3$PKG_VERSION on windows" > $PREFIX/bin/package3.bat + else: + - echo "package3$PKG_VERSION on unix" > $PREFIX/bin/package3 + - chmod +x $PREFIX/bin/package3 diff --git a/tests/data/channels/recipes/multiple_versions_channel_1_020.yaml b/tests/data/channels/recipes/multiple_versions_channel_1_020.yaml index 6238927d1..66a34d260 100644 --- a/tests/data/channels/recipes/multiple_versions_channel_1_020.yaml +++ b/tests/data/channels/recipes/multiple_versions_channel_1_020.yaml @@ -36,3 +36,19 @@ outputs: else: - echo "package2$PKG_VERSION on unix" > $PREFIX/bin/package2 - chmod +x $PREFIX/bin/package2 + + - package: + name: package3 + version: ${{ version }} + + build: + number: 1 + string: abc + script: + - mkdir -p $PREFIX/bin + - if: win + then: + - echo "package3$PKG_VERSION on windows" > $PREFIX/bin/package3.bat + else: + - echo "package3$PKG_VERSION on unix" > $PREFIX/bin/package3 + - chmod +x $PREFIX/bin/package3 diff --git a/tests/integration_python/test_main_cli.py b/tests/integration_python/test_main_cli.py index 2fa34d978..5b44e2a08 100644 --- a/tests/integration_python/test_main_cli.py +++ b/tests/integration_python/test_main_cli.py @@ -505,3 +505,84 @@ def test_upgrade_pypi_and_conda_package(pixi: Path, tmp_path: Path) -> None: assert "1.*" not in numpy_pypi numpy_conda = parsed_manifest["tool"]["pixi"]["dependencies"]["numpy"] assert numpy_conda != "1.*" + + +def test_upgrade_keep_info(pixi: Path, tmp_path: Path, multiple_versions_channel_1: str) -> None: + manifest_path = tmp_path / "pixi.toml" + + # Create a new project + verify_cli_command([pixi, "init", "--channel", multiple_versions_channel_1, tmp_path]) + + # Add package pinned to version 0.1.0 + verify_cli_command( + [ + pixi, + "add", + "--manifest-path", + manifest_path, + f"{multiple_versions_channel_1}::package3==0.1.0=ab*", + ] + ) + parsed_manifest = tomllib.loads(manifest_path.read_text()) + assert "==0.1.0" in parsed_manifest["dependencies"]["package3"]["version"] + assert "ab*" in parsed_manifest["dependencies"]["package3"]["build"] + assert multiple_versions_channel_1 in parsed_manifest["dependencies"]["package3"]["channel"] + + # Upgrade all, it should now be at 0.2.0, with the build intact + verify_cli_command( + [pixi, "upgrade", "--manifest-path", manifest_path], + stderr_contains=["package3", "0.1.0", "0.2.0"], + ) + parsed_manifest = tomllib.loads(manifest_path.read_text()) + # Update version + assert parsed_manifest["dependencies"]["package3"]["version"] == ">=0.2.0,<0.3" + # Keep build + assert "ab*" in parsed_manifest["dependencies"]["package3"]["build"] + # Keep channel + assert multiple_versions_channel_1 in parsed_manifest["dependencies"]["package3"]["channel"] + + # Upgrade package3, it should now be at 0.2.0, with the build intact because it has a wildcard + verify_cli_command( + [pixi, "upgrade", "--manifest-path", manifest_path, "package3"], + ) + parsed_manifest = tomllib.loads(manifest_path.read_text()) + # Update version + assert parsed_manifest["dependencies"]["package3"]["version"] == ">=0.2.0,<0.3" + # Keep build + assert "ab*" in parsed_manifest["dependencies"]["package3"]["build"] + # Keep channel + assert multiple_versions_channel_1 in parsed_manifest["dependencies"]["package3"]["channel"] + + +def test_upgrade_remove_info(pixi: Path, tmp_path: Path, multiple_versions_channel_1: str) -> None: + manifest_path = tmp_path / "pixi.toml" + + # Create a new project + verify_cli_command([pixi, "init", "--channel", multiple_versions_channel_1, tmp_path]) + + # Add package pinned to version 0.1.0 + verify_cli_command( + [ + pixi, + "add", + "--manifest-path", + manifest_path, + f"{multiple_versions_channel_1}::package3==0.1.0=abc", + ] + ) + parsed_manifest = tomllib.loads(manifest_path.read_text()) + assert "==0.1.0" in parsed_manifest["dependencies"]["package3"]["version"] + assert "abc" in parsed_manifest["dependencies"]["package3"]["build"] + assert multiple_versions_channel_1 in parsed_manifest["dependencies"]["package3"]["channel"] + + # Upgrade package3, it should now be at 0.2.0, without the build but with the channel + verify_cli_command( + [pixi, "upgrade", "--manifest-path", manifest_path, "package3"], + ) + parsed_manifest = tomllib.loads(manifest_path.read_text()) + # Update version + assert parsed_manifest["dependencies"]["package3"]["version"] == ">=0.2.0,<0.3" + # Keep channel + assert multiple_versions_channel_1 in parsed_manifest["dependencies"]["package3"]["channel"] + # Remove build + assert "build" not in parsed_manifest["dependencies"]["package3"]