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

feat: update rattler #2120

Merged
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
109 changes: 22 additions & 87 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -89,16 +89,16 @@ typed-path = "0.9.1"

# Rattler crates
file_url = "0.1.4"
rattler = { version = "0.27.11", default-features = false }
rattler_cache = { version = "0.2.3", default-features = false }
rattler_conda_types = { version = "0.27.6", default-features = false }
rattler = { version = "0.27.12", default-features = false }
rattler_cache = { version = "0.2.4", default-features = false }
rattler_conda_types = { version = "0.28.0", default-features = false }
rattler_digest = { version = "1.0.1", default-features = false }
rattler_lock = { version = "0.22.24", default-features = false }
rattler_lock = { version = "0.22.25", default-features = false }
rattler_networking = { version = "0.21.4", default-features = false }
rattler_repodata_gateway = { version = "0.21.13", default-features = false }
rattler_shell = { version = "0.22.1", default-features = false }
rattler_solve = { version = "1.0.7", default-features = false }
rattler_virtual_packages = { version = "1.1.4", default-features = false }
rattler_repodata_gateway = { version = "0.21.14", default-features = false }
rattler_shell = { version = "0.22.2", default-features = false }
rattler_solve = { version = "1.0.8", default-features = false }
rattler_virtual_packages = { version = "1.1.5", default-features = false }

# Bumping this to a higher version breaks the Windows path handling.
url = "2.5.0"
Expand Down
14 changes: 9 additions & 5 deletions crates/pixi_spec/src/detailed.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use std::sync::Arc;

use rattler_conda_types::{
BuildNumberSpec, ChannelConfig, NamedChannelOrUrl, NamelessMatchSpec, StringMatcher,
VersionSpec,
BuildNumberSpec, ChannelConfig, NamedChannelOrUrl, NamelessMatchSpec, ParseChannelError,
StringMatcher, VersionSpec,
};
use rattler_digest::{Md5Hash, Sha256Hash};
use serde_with::{serde_as, skip_serializing_none};
Expand Down Expand Up @@ -48,21 +48,25 @@ pub struct DetailedSpec {

impl DetailedSpec {
/// Converts this instance into a [`NamelessMatchSpec`].
pub fn into_nameless_match_spec(self, channel_config: &ChannelConfig) -> NamelessMatchSpec {
NamelessMatchSpec {
pub fn try_into_nameless_match_spec(
self,
channel_config: &ChannelConfig,
) -> Result<NamelessMatchSpec, ParseChannelError> {
Ok(NamelessMatchSpec {
version: self.version,
build: self.build,
build_number: self.build_number,
file_name: self.file_name,
channel: self
.channel
.map(|c| c.into_channel(channel_config))
.transpose()?
.map(Arc::new),
subdir: self.subdir,
namespace: None,
md5: self.md5,
sha256: self.sha256,
url: None,
}
})
}
}
12 changes: 10 additions & 2 deletions crates/pixi_spec/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ use std::{path::PathBuf, str::FromStr};
pub use detailed::DetailedSpec;
pub use git::{GitReference, GitSpec};
pub use path::{PathSourceSpec, PathSpec};
use rattler_conda_types::{ChannelConfig, NamedChannelOrUrl, NamelessMatchSpec, VersionSpec};
use rattler_conda_types::{
ChannelConfig, NamedChannelOrUrl, NamelessMatchSpec, ParseChannelError, VersionSpec,
};
use thiserror::Error;
pub use url::{UrlSourceSpec, UrlSpec};

Expand All @@ -38,6 +40,10 @@ pub enum SpecConversionError {
/// Encountered an invalid path
#[error("invalid path '{0}'")]
InvalidPath(String),

/// Encountered an invalid channel url or path
#[error("invalid channel '{0}'")]
InvalidChannel(#[from] ParseChannelError),
}

/// A package specification for pixi.
Expand Down Expand Up @@ -236,7 +242,9 @@ impl PixiSpec {
version: Some(version),
..NamelessMatchSpec::default()
}),
PixiSpec::DetailedVersion(spec) => Some(spec.into_nameless_match_spec(channel_config)),
PixiSpec::DetailedVersion(spec) => {
Some(spec.try_into_nameless_match_spec(channel_config)?)
}
PixiSpec::Url(url) => url.try_into_nameless_match_spec().ok(),
PixiSpec::Git(_) => None,
PixiSpec::Path(path) => path.try_into_nameless_match_spec(&channel_config.root_dir)?,
Expand Down
13 changes: 9 additions & 4 deletions src/cli/cli_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use crate::Project;
use clap::Parser;
use indexmap::IndexSet;
use itertools::Itertools;
use miette::IntoDiagnostic;
use pixi_config::{Config, ConfigCli};
use pixi_consts::consts;
use pixi_manifest::FeaturesExt;
Expand Down Expand Up @@ -38,12 +39,15 @@ pub struct ChannelsConfig {

impl ChannelsConfig {
/// Parses the channels, getting channel config and default channels from config
pub(crate) fn resolve_from_config(&self, config: &Config) -> IndexSet<Channel> {
pub(crate) fn resolve_from_config(&self, config: &Config) -> miette::Result<IndexSet<Channel>> {
self.resolve(config.global_channel_config(), config.default_channels())
}

/// Parses the channels, getting channel config and default channels from project
pub(crate) fn resolve_from_project(&self, project: Option<&Project>) -> IndexSet<Channel> {
pub(crate) fn resolve_from_project(
&self,
project: Option<&Project>,
) -> miette::Result<IndexSet<Channel>> {
match project {
Some(project) => {
let channels = project
Expand All @@ -63,7 +67,7 @@ impl ChannelsConfig {
&self,
channel_config: &ChannelConfig,
default_channels: Vec<NamedChannelOrUrl>,
) -> IndexSet<Channel> {
) -> miette::Result<IndexSet<Channel>> {
let channels = if self.channels.is_empty() {
default_channels
} else {
Expand All @@ -72,7 +76,8 @@ impl ChannelsConfig {
channels
.into_iter()
.map(|c| c.into_channel(channel_config))
.collect()
.try_collect()
.into_diagnostic()
}
}

Expand Down
14 changes: 8 additions & 6 deletions src/cli/exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ pub struct EnvironmentHash {
}

impl EnvironmentHash {
pub(crate) fn from_args(args: &Args, config: &Config) -> Self {
Self {
pub(crate) fn from_args(args: &Args, config: &Config) -> miette::Result<Self> {
Ok(Self {
command: args
.command
.first()
Expand All @@ -65,11 +65,11 @@ impl EnvironmentHash {
specs: args.specs.clone(),
channels: args
.channels
.resolve_from_config(config)
.resolve_from_config(config)?
.iter()
.map(|c| c.base_url().to_string())
.collect(),
}
})
}

/// Returns the name of the environment.
Expand Down Expand Up @@ -118,7 +118,7 @@ pub async fn create_exec_prefix(
config: &Config,
client: &ClientWithMiddleware,
) -> miette::Result<Prefix> {
let environment_name = EnvironmentHash::from_args(args, config).name();
let environment_name = EnvironmentHash::from_args(args, config)?.name();
let prefix = Prefix::new(
cache_dir
.join(pixi_consts::consts::CACHED_ENVS_DIR)
Expand Down Expand Up @@ -168,11 +168,13 @@ pub async fn create_exec_prefix(
args.specs.clone()
};

let channels = args.channels.resolve_from_config(config)?;

// Get the repodata for the specs
let repodata = await_in_progress("fetching repodata for environment", |_| async {
gateway
.query(
args.channels.resolve_from_config(config),
channels,
[Platform::current(), Platform::NoArch],
specs.clone(),
)
Expand Down
Loading
Loading