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

fix: keep build in pixi upgrade #2476

Merged
merged 6 commits into from
Nov 15, 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
10 changes: 10 additions & 0 deletions docs/reference/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
46 changes: 34 additions & 12 deletions src/cli/upgrade.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use std::cmp::Ordering;
use std::sync::Arc;

use crate::cli::cli_config::ProjectConfig;
use crate::Project;
Expand All @@ -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)]
Expand Down Expand Up @@ -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();

Expand All @@ -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,
Expand Down
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -9,55 +9,83 @@
"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": {
"arch": "x86_64",
"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": {
"arch": "x86_64",
"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": {
"arch": "x86_64",
"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"
}
},
Expand Down
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -9,55 +9,83 @@
"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": {
"arch": "x86_64",
"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": {
"arch": "x86_64",
"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": {
"arch": "x86_64",
"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"
}
},
Expand Down
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -9,55 +9,83 @@
"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": {
"arch": "arm64",
"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": {
"arch": "arm64",
"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": {
"arch": "arm64",
"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"
}
},
Expand Down
Binary file not shown.
Binary file not shown.
Loading
Loading