Skip to content

Commit 35291bd

Browse files
authored
refactor: Improve AuthenticationStorage, update rattler (#2909)
1 parent 35f3ddb commit 35291bd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+437
-334
lines changed

Cargo.lock

+184-170
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+9-9
Original file line numberDiff line numberDiff line change
@@ -113,20 +113,20 @@ which = "7.0.1"
113113

114114
# Rattler crates
115115
file_url = "0.2.2"
116-
rattler = { version = "0.28.11", default-features = false }
117-
rattler_cache = { version = "0.3.3", default-features = false }
118-
rattler_conda_types = { version = "0.29.9", default-features = false, features = [
116+
rattler = { version = "0.29.0", default-features = false }
117+
rattler_cache = { version = "0.3.5", default-features = false }
118+
rattler_conda_types = { version = "0.30.0", default-features = false, features = [
119119
"rayon",
120120
] }
121121
rattler_digest = { version = "1.0.5", default-features = false }
122-
rattler_lock = { version = "0.22.38", default-features = false }
123-
rattler_networking = { version = "0.21.10", default-features = false, features = [
122+
rattler_lock = { version = "0.22.40", default-features = false }
123+
rattler_networking = { version = "0.22.0", default-features = false, features = [
124124
"google-cloud-auth",
125125
] }
126-
rattler_repodata_gateway = { version = "0.21.31", default-features = false }
127-
rattler_shell = { version = "0.22.14", default-features = false }
128-
rattler_solve = { version = "1.3.3", default-features = false }
129-
rattler_virtual_packages = { version = "1.1.17", default-features = false }
126+
rattler_repodata_gateway = { version = "0.21.33", default-features = false }
127+
rattler_shell = { version = "0.22.16", default-features = false }
128+
rattler_solve = { version = "1.3.5", default-features = false }
129+
rattler_virtual_packages = { version = "2.0.0", default-features = false }
130130

131131

132132
# Bumping this to a higher version breaks the Windows path handling.

crates/pixi_build_frontend/src/protocol_builder.rs

+9-5
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ impl Default for EnabledProtocols {
3838
#[derive(Debug)]
3939
pub(crate) enum ProtocolBuilder {
4040
/// A pixi project.
41-
Pixi(pixi_protocol::ProtocolBuilder),
41+
Pixi(Box<pixi_protocol::ProtocolBuilder>),
4242

4343
/// A directory containing a `meta.yaml` that can be interpreted by
4444
/// conda-build.
@@ -51,7 +51,7 @@ pub(crate) enum ProtocolBuilder {
5151

5252
impl From<pixi_protocol::ProtocolBuilder> for ProtocolBuilder {
5353
fn from(value: pixi_protocol::ProtocolBuilder) -> Self {
54-
Self::Pixi(value)
54+
Self::Pixi(Box::new(value))
5555
}
5656
}
5757

@@ -125,7 +125,9 @@ impl ProtocolBuilder {
125125
/// Sets the channel configuration used by the protocol.
126126
pub fn with_channel_config(self, channel_config: ChannelConfig) -> Self {
127127
match self {
128-
Self::Pixi(protocol) => Self::Pixi(protocol.with_channel_config(channel_config)),
128+
Self::Pixi(protocol) => {
129+
Self::Pixi(Box::new(protocol.with_channel_config(channel_config)))
130+
}
129131
Self::CondaBuild(protocol) => {
130132
Self::CondaBuild(protocol.with_channel_config(channel_config))
131133
}
@@ -139,7 +141,7 @@ impl ProtocolBuilder {
139141
if let Some(backend_override) = backend_override {
140142
match self {
141143
Self::Pixi(protocol) => {
142-
Self::Pixi(protocol.with_backend_override(backend_override))
144+
Self::Pixi(Box::new(protocol.with_backend_override(backend_override)))
143145
}
144146
Self::CondaBuild(protocol) => {
145147
Self::CondaBuild(protocol.with_backend_override(backend_override))
@@ -156,7 +158,9 @@ impl ProtocolBuilder {
156158
/// Sets the cache directory to use for any caching.
157159
pub fn with_opt_cache_dir(self, cache_directory: Option<PathBuf>) -> Self {
158160
match self {
159-
Self::Pixi(protocol) => Self::Pixi(protocol.with_opt_cache_dir(cache_directory)),
161+
Self::Pixi(protocol) => {
162+
Self::Pixi(Box::new(protocol.with_opt_cache_dir(cache_directory)))
163+
}
160164
Self::CondaBuild(protocol) => {
161165
Self::CondaBuild(protocol.with_opt_cache_dir(cache_directory))
162166
}

crates/pixi_build_frontend/src/tool/cache.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,12 @@ mod tests {
405405
.await
406406
.unwrap();
407407

408-
tool.command().arg("--version").spawn().unwrap();
408+
tool.command()
409+
.arg("--version")
410+
.spawn()
411+
.unwrap()
412+
.wait()
413+
.unwrap();
409414
}
410415

411416
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]

crates/pixi_build_frontend/src/tool/installer.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ impl ToolInstaller for ToolContext {
301301
self.cache_dir
302302
.join(pixi_consts::consts::CONDA_PACKAGE_CACHE_DIR),
303303
))
304-
.install(&cached_dir, solved_records)
304+
.install(&cached_dir, solved_records.records)
305305
.await
306306
.into_diagnostic()?;
307307

crates/pixi_build_type_conversions/src/project_model.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ fn to_pixi_spec_v1(
5959
}
6060
itertools::Either::Right(binary) => {
6161
let nameless = binary.try_into_nameless_match_spec(channel_config)?;
62-
pbt::PackageSpecV1::Binary(pbt::BinaryPackageSpecV1 {
62+
pbt::PackageSpecV1::Binary(Box::new(pbt::BinaryPackageSpecV1 {
6363
version: nameless.version,
6464
build: nameless.build,
6565
build_number: nameless.build_number,
@@ -68,7 +68,7 @@ fn to_pixi_spec_v1(
6868
subdir: nameless.subdir,
6969
md5: nameless.md5.map(Into::into),
7070
sha256: nameless.sha256.map(Into::into),
71-
})
71+
}))
7272
}
7373
};
7474
Ok(pbt_spec)

crates/pixi_build_types/src/project_model.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ pub struct TargetV1 {
152152
#[serde(rename_all = "camelCase")]
153153
pub enum PackageSpecV1 {
154154
/// This is a binary dependency
155-
Binary(BinaryPackageSpecV1),
155+
Binary(Box<BinaryPackageSpecV1>),
156156
/// This is a dependency on a source package
157157
Source(SourcePackageSpecV1),
158158
}

crates/pixi_config/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ pub struct ConfigCli {
9898
tls_no_verify: bool,
9999

100100
/// Path to the file containing the authentication token.
101-
#[arg(long, env = "RATTLER_AUTH_FILE")]
101+
#[arg(long)]
102102
auth_file: Option<PathBuf>,
103103

104104
/// Specifies if we want to use uv keyring provider

crates/pixi_default_versions/src/lib.rs

+5
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ pub fn default_linux_version() -> Version {
1010
"4.18".parse().unwrap()
1111
}
1212

13+
/// The default Windows version to use. This is used when no system requirements are specified.
14+
pub fn default_windows_version() -> Version {
15+
"10.0".parse().unwrap()
16+
}
17+
1318
/// Returns the default Mac OS version for the specified platform. The platform must refer to a
1419
/// MacOS platform.
1520
pub fn default_mac_os_version(platform: Platform) -> Version {

crates/pixi_manifest/src/manifests/snapshots/pixi_manifest__manifests__workspace__tests__invalid_target_specific.snap

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
---
22
source: crates/pixi_manifest/src/manifests/workspace.rs
3+
assertion_line: 298
34
expression: "expect_parse_failure(&format!(\"{PROJECT_BOILERPLATE}\\n{}\", examples[0]))"
5+
snapshot_kind: text
46
---
5-
× 'foobar' is not a known platform. Valid platforms are 'noarch', 'unknown', 'linux-32', 'linux-64', 'linux-aarch64', 'linux-armv6l', 'linux-armv7l', 'linux-ppc64le', 'linux-ppc64', 'linux-s390x',
6-
'linux-riscv32', 'linux-riscv64', 'osx-64', 'osx-arm64', 'win-32', 'win-64', 'win-arm64', 'emscripten-wasm32', 'wasi-wasm32', 'zos-z'
7+
× 'foobar' is not a known platform. Valid platforms are 'noarch', 'unknown', 'linux-32', 'linux-64', 'linux-aarch64', 'linux-armv6l', 'linux-armv7l', 'linux-ppc64le', 'linux-ppc64', 'linux-ppc',
8+
'linux-s390x', 'linux-riscv32', 'linux-riscv64', 'osx-64', 'osx-arm64', 'win-32', 'win-64', 'win-arm64', 'emscripten-wasm32', 'wasi-wasm32', 'zos-z'
79
╭─[pixi.toml:8:9]
810
7
911
8 │ [target.foobar.dependencies]

crates/pixi_manifest/src/utils/package_map.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ impl<'de> Deserialize<'de> for UniquePackageMap {
9191

9292
struct PackageMap<'a>(&'a IndexMap<rattler_conda_types::PackageName, PixiSpec>);
9393

94-
impl<'de, 'a> DeserializeSeed<'de> for PackageMap<'a> {
94+
impl<'de> DeserializeSeed<'de> for PackageMap<'_> {
9595
type Value = PixiSpanned<rattler_conda_types::PackageName>;
9696

9797
fn deserialize<D>(self, deserializer: D) -> Result<Self::Value, D::Error>

crates/pixi_record/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ impl PixiRecord {
3737
}
3838

3939
/// Converts this instance into a binary record if it is a binary record.
40-
4140
pub fn into_binary(self) -> Option<RepoDataRecord> {
4241
match self {
4342
PixiRecord::Binary(record) => Some(record),

crates/pixi_spec/src/detailed.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,13 @@ impl DetailedSpec {
6969
md5: self.md5,
7070
sha256: self.sha256,
7171
url: None,
72+
extras: Default::default(),
7273
})
7374
}
7475
}
7576

7677
impl From<DetailedSpec> for BinarySpec {
7778
fn from(value: DetailedSpec) -> Self {
78-
Self::DetailedVersion(value)
79+
Self::DetailedVersion(Box::new(value))
7980
}
8081
}

crates/pixi_spec/src/lib.rs

+7-9
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ pub enum PixiSpec {
6565

6666
/// The spec is represented by a detailed version spec. The package should
6767
/// be retrieved from a channel.
68-
DetailedVersion(DetailedSpec),
68+
DetailedVersion(Box<DetailedSpec>),
6969

7070
/// The spec is represented as an archive that can be downloaded from the
7171
/// specified URL. The package should be retrieved from the URL and can
@@ -117,7 +117,7 @@ impl PixiSpec {
117117
{
118118
Self::Version(spec.version.unwrap_or(VersionSpec::Any))
119119
} else {
120-
Self::DetailedVersion(DetailedSpec {
120+
Self::DetailedVersion(Box::new(DetailedSpec {
121121
version: spec.version,
122122
build: spec.build,
123123
build_number: spec.build_number,
@@ -129,7 +129,7 @@ impl PixiSpec {
129129
subdir: spec.subdir,
130130
md5: spec.md5,
131131
sha256: spec.sha256,
132-
})
132+
}))
133133
}
134134
}
135135

@@ -189,17 +189,15 @@ impl PixiSpec {
189189
pub fn into_version(self) -> Option<VersionSpec> {
190190
match self {
191191
Self::Version(v) => Some(v),
192-
Self::DetailedVersion(DetailedSpec {
193-
version: Some(v), ..
194-
}) => Some(v),
192+
Self::DetailedVersion(v) => v.version,
195193
_ => None,
196194
}
197195
}
198196

199197
/// Converts this instance into a [`DetailedSpec`] if possible.
200198
pub fn into_detailed(self) -> Option<DetailedSpec> {
201199
match self {
202-
Self::DetailedVersion(v) => Some(v),
200+
Self::DetailedVersion(v) => Some(*v),
203201
Self::Version(v) => Some(DetailedSpec {
204202
version: Some(v),
205203
..DetailedSpec::default()
@@ -351,7 +349,7 @@ impl From<SourceSpec> for PixiSpec {
351349

352350
impl From<DetailedSpec> for PixiSpec {
353351
fn from(value: DetailedSpec) -> Self {
354-
Self::DetailedVersion(value)
352+
Self::DetailedVersion(Box::new(value))
355353
}
356354
}
357355

@@ -407,7 +405,7 @@ pub enum BinarySpec {
407405

408406
/// The spec is represented by a detailed version spec. The package should
409407
/// be retrieved from a channel.
410-
DetailedVersion(DetailedSpec),
408+
DetailedVersion(Box<DetailedSpec>),
411409

412410
/// The spec is represented as an archive that can be downloaded from the
413411
/// specified URL. The package should be retrieved from the URL and can

crates/pixi_spec/src/toml.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ impl TomlSpec {
286286
return Err(SpecError::MissingDetailedIdentifier);
287287
}
288288

289-
PixiSpec::DetailedVersion(DetailedSpec {
289+
PixiSpec::DetailedVersion(Box::new(DetailedSpec {
290290
version: self.version,
291291
build: self.build,
292292
build_number: self.build_number,
@@ -295,7 +295,7 @@ impl TomlSpec {
295295
subdir: self.subdir,
296296
md5: self.md5,
297297
sha256: self.sha256,
298-
})
298+
}))
299299
}
300300
(_, _, _) => return Err(SpecError::MultipleIdentifiers),
301301
};
@@ -344,7 +344,7 @@ impl TomlSpec {
344344
return Err(SpecError::MissingDetailedIdentifier);
345345
}
346346

347-
BinarySpec::DetailedVersion(DetailedSpec {
347+
BinarySpec::DetailedVersion(Box::new(DetailedSpec {
348348
version: self.version,
349349
build: self.build,
350350
build_number: self.build_number,
@@ -353,7 +353,7 @@ impl TomlSpec {
353353
subdir: self.subdir,
354354
md5: self.md5,
355355
sha256: self.sha256,
356-
})
356+
}))
357357
}
358358
(_, _, _) => return Err(SpecError::MultipleIdentifiers),
359359
};

crates/pixi_utils/src/reqwest.rs

+27-9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::{path::PathBuf, sync::Arc, time::Duration};
1+
use std::{any::Any, path::PathBuf, sync::Arc, time::Duration};
22

33
use pixi_consts::consts;
44
use rattler_networking::{
@@ -22,23 +22,41 @@ pub fn default_retry_policy() -> ExponentialBackoff {
2222
ExponentialBackoff::builder().build_with_max_retries(3)
2323
}
2424

25-
fn auth_middleware(config: &Config) -> Result<AuthenticationMiddleware, FileStorageError> {
25+
fn auth_store(config: &Config) -> Result<AuthenticationStorage, FileStorageError> {
26+
let mut store = AuthenticationStorage::from_env_and_defaults()?;
2627
if let Some(auth_file) = config.authentication_override_file() {
2728
tracing::info!("Loading authentication from file: {:?}", auth_file);
2829

2930
if !auth_file.exists() {
3031
tracing::warn!("Authentication file does not exist: {:?}", auth_file);
3132
}
3233

33-
let mut store = AuthenticationStorage::new();
34-
store.add_backend(Arc::from(
35-
authentication_storage::backends::file::FileStorage::new(PathBuf::from(&auth_file))?,
36-
));
37-
38-
return Ok(AuthenticationMiddleware::new(store));
34+
// this should be the first place before the keyring authentication
35+
// i.e. either index 0 if RATTLER_AUTH_FILE is not set or index 1 if it is
36+
let first_storage = store.backends.first().unwrap();
37+
let index = if first_storage.type_id()
38+
== std::any::TypeId::of::<authentication_storage::backends::file::FileStorage>()
39+
{
40+
1
41+
} else {
42+
0
43+
};
44+
store.backends.insert(
45+
index,
46+
Arc::from(
47+
authentication_storage::backends::file::FileStorage::from_path(PathBuf::from(
48+
&auth_file,
49+
))?,
50+
),
51+
);
3952
}
53+
Ok(store)
54+
}
4055

41-
Ok(AuthenticationMiddleware::default())
56+
fn auth_middleware(config: &Config) -> Result<AuthenticationMiddleware, FileStorageError> {
57+
Ok(AuthenticationMiddleware::from_auth_storage(auth_store(
58+
config,
59+
)?))
4260
}
4361

4462
pub fn mirror_middleware(config: &Config) -> MirrorMiddleware {

0 commit comments

Comments
 (0)