Skip to content

Commit 4ac2e07

Browse files
authored
feat: make s3 support optional (#1950)
1 parent d4d9a38 commit 4ac2e07

File tree

6 files changed

+41
-27
lines changed

6 files changed

+41
-27
lines changed

Cargo.lock

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ default-run = "rattler-build"
5151
rust-version = "1.86.0"
5252

5353
[features]
54-
default = ['rustls-tls', 'recipe-generation']
54+
default = ['rustls-tls', 'recipe-generation', 's3']
5555
native-tls = [
5656
'reqwest/native-tls',
5757
'rattler/native-tls',
@@ -75,6 +75,10 @@ tui = [
7575
'throbber-widgets-tui',
7676
'tui-input',
7777
]
78+
s3 = [
79+
'rattler_networking/s3',
80+
'rattler_upload/s3',
81+
]
7882
recipe-generation = ["rattler_build_recipe_generator"]
7983
# This feature needs to add a dependency on
8084
# clap-markdown = { git = "https://github.com/ruben-arts/clap-markdown", branch = "main" }
@@ -171,9 +175,6 @@ reflink-copy = "0.1.26"
171175
rayon = "1.11.0"
172176
regex = { workspace = true }
173177
async-recursion = { workspace = true }
174-
opendal = { version = "0.54.0", default-features = false, features = [
175-
"services-s3",
176-
] }
177178

178179
# Rattler crates
179180
rattler_config = { version = "0.2.11" }
@@ -186,12 +187,9 @@ rattler_conda_types = { workspace = true, features = ["rayon"] }
186187
rattler_digest = { workspace = true }
187188
rattler_index = { version = "0.25.5", default-features = false }
188189
rattler_networking = { version = "0.25.16", default-features = false, features = [
189-
"s3",
190190
"rattler_config",
191191
] }
192-
rattler_upload = { version = "0.3.4", default-features = false, features = [
193-
"s3",
194-
] }
192+
rattler_upload = { version = "0.3.4", default-features = false }
195193
rattler_redaction = { version = "0.1.12" }
196194
rattler_repodata_gateway = { version = "0.24.7", default-features = false, features = [
197195
"gateway",

py-rattler-build/pixi.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ pub fn get_tool_config(
135135
) -> miette::Result<Configuration> {
136136
let client = tool_configuration::reqwest_client_from_auth_storage(
137137
build_data.common.auth_file.clone(),
138+
#[cfg(feature = "s3")]
138139
build_data.common.s3_config.clone(),
139140
build_data.common.mirror_config.clone(),
140141
build_data.common.allow_insecure_host.clone(),
@@ -694,6 +695,7 @@ pub async fn run_test(
694695
.with_reqwest_client(
695696
tool_configuration::reqwest_client_from_auth_storage(
696697
test_data.common.auth_file,
698+
#[cfg(feature = "s3")]
697699
test_data.common.s3_config,
698700
test_data.common.mirror_config,
699701
test_data.common.allow_insecure_host.clone(),
@@ -752,6 +754,7 @@ pub async fn rebuild(
752754
) -> miette::Result<()> {
753755
let reqwest_client = tool_configuration::reqwest_client_from_auth_storage(
754756
rebuild_data.common.auth_file,
757+
#[cfg(feature = "s3")]
755758
rebuild_data.common.s3_config.clone(),
756759
rebuild_data.common.mirror_config.clone(),
757760
rebuild_data.common.allow_insecure_host.clone(),

src/opt.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ use rattler_conda_types::{
1111
NamedChannelOrUrl, Platform, compression_level::CompressionLevel, package::ArchiveType,
1212
};
1313
use rattler_config::config::build::PackageFormatAndCompression;
14-
use rattler_networking::{mirror_middleware, s3_middleware};
14+
use rattler_networking::mirror_middleware;
15+
#[cfg(feature = "s3")]
16+
use rattler_networking::s3_middleware;
1517
use rattler_solve::ChannelPriority;
1618
use rattler_upload::upload::opt::{Config, UploadOpts};
1719
use serde_json::{Value, json};
@@ -231,6 +233,7 @@ pub struct CommonData {
231233
pub experimental: bool,
232234
pub auth_file: Option<PathBuf>,
233235
pub channel_priority: ChannelPriority,
236+
#[cfg(feature = "s3")]
234237
pub s3_config: HashMap<String, s3_middleware::S3Config>,
235238
pub mirror_config: HashMap<Url, Vec<mirror_middleware::Mirror>>,
236239
pub allow_insecure_host: Option<Vec<String>>,
@@ -285,11 +288,14 @@ impl CommonData {
285288
mirror_config.insert(ensure_trailing_slash(key), mirrors);
286289
}
287290

291+
#[cfg(feature = "s3")]
288292
let s3_config = rattler_networking::s3_middleware::compute_s3_config(&config.s3_options.0);
293+
289294
Self {
290295
output_dir: output_dir.unwrap_or_else(|| PathBuf::from("./output")),
291296
experimental,
292297
auth_file,
298+
#[cfg(feature = "s3")]
293299
s3_config,
294300
mirror_config,
295301
channel_priority: channel_priority.unwrap_or(ChannelPriority::Strict),

src/tool_configuration.rs

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@ use std::{collections::HashMap, path::PathBuf, sync::Arc};
66
use clap::ValueEnum;
77
use rattler::package_cache::PackageCache;
88
use rattler_conda_types::{ChannelConfig, Platform};
9+
#[cfg(feature = "s3")]
10+
use rattler_networking::s3_middleware;
911
use rattler_networking::{
1012
AuthenticationMiddleware, AuthenticationStorage,
1113
authentication_storage::{self, AuthenticationStorageError},
12-
mirror_middleware, s3_middleware,
14+
mirror_middleware,
1315
};
1416
use rattler_repodata_gateway::Gateway;
1517
use rattler_solve::ChannelPriority;
@@ -85,12 +87,13 @@ impl BaseClient {
8587
pub fn new(
8688
auth_file: Option<PathBuf>,
8789
allow_insecure_host: Option<Vec<String>>,
88-
s3_middleware_config: HashMap<String, s3_middleware::S3Config>,
90+
#[cfg(feature = "s3")] s3_middleware_config: HashMap<String, s3_middleware::S3Config>,
8991
mirror_middleware_config: HashMap<Url, Vec<mirror_middleware::Mirror>>,
9092
) -> Result<Self, AuthenticationStorageError> {
9193
let auth_storage = get_auth_store(auth_file)?;
9294
let timeout = 5 * 60;
9395

96+
#[cfg(feature = "s3")]
9497
let s3_middleware =
9598
s3_middleware::S3Middleware::new(s3_middleware_config, auth_storage.clone());
9699
let mirror_middleware =
@@ -104,20 +107,24 @@ impl BaseClient {
104107
.read_timeout(std::time::Duration::from_secs(timeout))
105108
};
106109

107-
let client = reqwest_middleware::ClientBuilder::new(
110+
let client_builder = reqwest_middleware::ClientBuilder::new(
108111
common_settings(reqwest::Client::builder())
109112
.build()
110113
.expect("failed to create client"),
111114
)
112-
.with(mirror_middleware)
113-
.with(s3_middleware)
114-
.with_arc(Arc::new(AuthenticationMiddleware::from_auth_storage(
115-
auth_storage.clone(),
116-
)))
117-
.with(RetryTransientMiddleware::new_with_policy(
118-
ExponentialBackoff::builder().build_with_max_retries(3),
119-
))
120-
.build();
115+
.with(mirror_middleware);
116+
117+
#[cfg(feature = "s3")]
118+
let client_builder = client_builder.with(s3_middleware);
119+
120+
let client = client_builder
121+
.with_arc(Arc::new(AuthenticationMiddleware::from_auth_storage(
122+
auth_storage.clone(),
123+
)))
124+
.with(RetryTransientMiddleware::new_with_policy(
125+
ExponentialBackoff::builder().build_with_max_retries(3),
126+
))
127+
.build();
121128

122129
let dangerous_client = reqwest_middleware::ClientBuilder::new(
123130
common_settings(reqwest::Client::builder())
@@ -259,13 +266,14 @@ pub fn get_auth_store(
259266
/// * `allow_insecure_host` - Optional list of hosts for which to disable SSL certificate verification
260267
pub fn reqwest_client_from_auth_storage(
261268
auth_file: Option<PathBuf>,
262-
s3_middleware_config: HashMap<String, s3_middleware::S3Config>,
269+
#[cfg(feature = "s3")] s3_middleware_config: HashMap<String, s3_middleware::S3Config>,
263270
mirror_middleware_config: HashMap<Url, Vec<mirror_middleware::Mirror>>,
264271
allow_insecure_host: Option<Vec<String>>,
265272
) -> Result<BaseClient, AuthenticationStorageError> {
266273
BaseClient::new(
267274
auth_file,
268275
allow_insecure_host,
276+
#[cfg(feature = "s3")]
269277
s3_middleware_config,
270278
mirror_middleware_config,
271279
)

0 commit comments

Comments
 (0)