From 179519b7b647d0956952572a603abaa045d3ed78 Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Mon, 19 Aug 2024 15:36:58 -0400 Subject: [PATCH] Move concurrency settings to top-level (#4257) These are global and non-specific to the `pip` API, so I think they should be elevated. - Ran `UV_CONCURRENT_DOWNLOADS=1 cargo run pip list`; verified that `downloads` resolved to 1. - Added `concurrent-downloads = 5` under `[tool.uv]` in `pyproject.toml`; ran `cargo run pip list`; verified that `downloads` resolved to 5. - Ran `UV_CONCURRENT_DOWNLOADS=1 cargo run pip list`; verified that `downloads` resolved to 1. --- crates/uv-settings/src/settings.rs | 66 ++++----- crates/uv/src/commands/venv.rs | 6 +- crates/uv/src/lib.rs | 50 +++---- crates/uv/src/settings.rs | 45 ++---- crates/uv/tests/show_settings.rs | 215 +++++++++++++++-------------- docs/reference/settings.md | 165 +++++++++++----------- uv.schema.json | 54 ++++---- 7 files changed, 290 insertions(+), 311 deletions(-) diff --git a/crates/uv-settings/src/settings.rs b/crates/uv-settings/src/settings.rs index 80e8d71b94b24..d2b7219f2f10d 100644 --- a/crates/uv-settings/src/settings.rs +++ b/crates/uv-settings/src/settings.rs @@ -164,6 +164,39 @@ pub struct GlobalOptions { possible_values = true )] pub python_downloads: Option, + /// The maximum number of in-flight concurrent downloads that uv will perform at any given + /// time. + #[option( + default = "50", + value_type = "int", + example = r#" + concurrent-downloads = 4 + "# + )] + pub concurrent_downloads: Option, + /// The maximum number of source distributions that uv will build concurrently at any given + /// time. + /// + /// Defaults to the number of available CPU cores. + #[option( + default = "None", + value_type = "int", + example = r#" + concurrent-builds = 4 + "# + )] + pub concurrent_builds: Option, + /// The number of threads used when installing and unzipping packages. + /// + /// Defaults to the number of available CPU cores. + #[option( + default = "None", + value_type = "int", + example = r#" + concurrent-installs = 4 + "# + )] + pub concurrent_installs: Option, } /// Settings relevant to all installer operations. @@ -1172,39 +1205,6 @@ pub struct PipOptions { "# )] pub reinstall_package: Option>, - /// The maximum number of in-flight concurrent downloads that uv will perform at any given - /// time. - #[option( - default = "50", - value_type = "int", - example = r#" - concurrent-downloads = 4 - "# - )] - pub concurrent_downloads: Option, - /// The maximum number of source distributions that uv will build concurrently at any given - /// time. - /// - /// Defaults to the number of available CPU cores. - #[option( - default = "None", - value_type = "int", - example = r#" - concurrent-builds = 4 - "# - )] - pub concurrent_builds: Option, - /// The number of threads used when installing and unzipping packages. - /// - /// Defaults to the number of available CPU cores. - #[option( - default = "None", - value_type = "int", - example = r#" - concurrent-installs = 4 - "# - )] - pub concurrent_installs: Option, } impl From for ResolverOptions { diff --git a/crates/uv/src/commands/venv.rs b/crates/uv/src/commands/venv.rs index a4838818eae0b..7c9a821af5cf9 100644 --- a/crates/uv/src/commands/venv.rs +++ b/crates/uv/src/commands/venv.rs @@ -55,6 +55,7 @@ pub(crate) async fn venv( seed: bool, allow_existing: bool, exclude_newer: Option, + concurrency: Concurrency, native_tls: bool, cache: &Cache, printer: Printer, @@ -75,6 +76,7 @@ pub(crate) async fn venv( python_downloads, allow_existing, exclude_newer, + concurrency, native_tls, cache, printer, @@ -126,6 +128,7 @@ async fn venv_impl( python_downloads: PythonDownloads, allow_existing: bool, exclude_newer: Option, + concurrency: Concurrency, native_tls: bool, cache: &Cache, printer: Printer, @@ -268,9 +271,8 @@ async fn venv_impl( // Initialize any shared state. let state = SharedState::default(); - // For seed packages, assume a bunch of default settings and concurrency are sufficient. + // For seed packages, assume a bunch of default settings are sufficient. let build_constraints = []; - let concurrency = Concurrency::default(); let config_settings = ConfigSettings::default(); let setup_py = SetupPyStrategy::default(); let sources = SourceStrategy::Disabled; diff --git a/crates/uv/src/lib.rs b/crates/uv/src/lib.rs index b518870a03c52..bcea1ec94fe07 100644 --- a/crates/uv/src/lib.rs +++ b/crates/uv/src/lib.rs @@ -20,7 +20,6 @@ use uv_cli::{ use uv_cli::{PythonCommand, PythonNamespace, ToolCommand, ToolNamespace}; #[cfg(feature = "self-update")] use uv_cli::{SelfCommand, SelfNamespace}; -use uv_configuration::Concurrency; use uv_fs::CWD; use uv_requirements::RequirementsSource; use uv_scripts::Pep723Script; @@ -209,6 +208,11 @@ async fn run(cli: Cli) -> Result { ) }))?; + rayon::ThreadPoolBuilder::new() + .num_threads(globals.concurrency.installs) + .build_global() + .expect("failed to initialize global rayon pool"); + debug!("uv {}", version::version()); // Write out any resolved settings. @@ -246,11 +250,6 @@ async fn run(cli: Cli) -> Result { let args = PipCompileSettings::resolve(args, filesystem); show_settings!(args); - rayon::ThreadPoolBuilder::new() - .num_threads(args.settings.concurrency.installs) - .build_global() - .expect("failed to initialize global rayon pool"); - // Initialize the cache. let cache = cache.init()?.with_refresh( args.refresh @@ -323,7 +322,7 @@ async fn run(cli: Cli) -> Result { args.settings.python, args.settings.system, globals.python_preference, - args.settings.concurrency, + globals.concurrency, globals.native_tls, globals.quiet, cache, @@ -340,11 +339,6 @@ async fn run(cli: Cli) -> Result { let args = PipSyncSettings::resolve(args, filesystem); show_settings!(args); - rayon::ThreadPoolBuilder::new() - .num_threads(args.settings.concurrency.installs) - .build_global() - .expect("failed to initialize global rayon pool"); - // Initialize the cache. let cache = cache.init()?.with_refresh( args.refresh @@ -396,7 +390,7 @@ async fn run(cli: Cli) -> Result { args.settings.target, args.settings.prefix, args.settings.sources, - args.settings.concurrency, + globals.concurrency, globals.native_tls, cache, args.dry_run, @@ -413,11 +407,6 @@ async fn run(cli: Cli) -> Result { let args = PipInstallSettings::resolve(args, filesystem); show_settings!(args); - rayon::ThreadPoolBuilder::new() - .num_threads(args.settings.concurrency.installs) - .build_global() - .expect("failed to initialize global rayon pool"); - // Initialize the cache. let cache = cache.init()?.with_refresh( args.refresh @@ -488,7 +477,7 @@ async fn run(cli: Cli) -> Result { args.settings.break_system_packages, args.settings.target, args.settings.prefix, - args.settings.concurrency, + globals.concurrency, globals.native_tls, cache, args.dry_run, @@ -693,6 +682,7 @@ async fn run(cli: Cli) -> Result { args.seed, args.allow_existing, args.settings.exclude_newer, + globals.concurrency, globals.native_tls, &cache, printer, @@ -762,7 +752,7 @@ async fn run(cli: Cli) -> Result { globals.python_preference, globals.python_downloads, globals.connectivity, - Concurrency::default(), + globals.concurrency, globals.native_tls, cache, printer, @@ -806,7 +796,7 @@ async fn run(cli: Cli) -> Result { globals.python_preference, globals.python_downloads, globals.connectivity, - Concurrency::default(), + globals.concurrency, globals.native_tls, &cache, printer, @@ -840,7 +830,7 @@ async fn run(cli: Cli) -> Result { globals.connectivity, args.args, args.filesystem, - Concurrency::default(), + globals.concurrency, globals.native_tls, &cache, printer, @@ -1048,7 +1038,7 @@ async fn run_project( globals.python_preference, globals.python_downloads, globals.connectivity, - Concurrency::default(), + globals.concurrency, globals.native_tls, &cache, printer, @@ -1079,7 +1069,7 @@ async fn run_project( globals.python_downloads, args.settings, globals.connectivity, - Concurrency::default(), + globals.concurrency, globals.native_tls, &cache, printer, @@ -1102,7 +1092,7 @@ async fn run_project( globals.python_preference, globals.python_downloads, globals.connectivity, - Concurrency::default(), + globals.concurrency, globals.native_tls, &cache, printer, @@ -1142,7 +1132,7 @@ async fn run_project( ) .collect::>(); - commands::add( + Box::pin(commands::add( args.locked, args.frozen, args.no_sync, @@ -1161,11 +1151,11 @@ async fn run_project( globals.python_preference, globals.python_downloads, globals.connectivity, - Concurrency::default(), + globals.concurrency, globals.native_tls, &cache, printer, - ) + )) .await } ProjectCommand::Remove(args) => { @@ -1193,7 +1183,7 @@ async fn run_project( globals.python_preference, globals.python_downloads, globals.connectivity, - Concurrency::default(), + globals.concurrency, globals.native_tls, &cache, printer, @@ -1224,7 +1214,7 @@ async fn run_project( globals.python_preference, globals.python_downloads, globals.connectivity, - Concurrency::default(), + globals.concurrency, globals.native_tls, &cache, printer, diff --git a/crates/uv/src/settings.rs b/crates/uv/src/settings.rs index e75a5799c4e70..24ca92d7adb41 100644 --- a/crates/uv/src/settings.rs +++ b/crates/uv/src/settings.rs @@ -46,6 +46,7 @@ pub(crate) struct GlobalSettings { pub(crate) verbose: u8, pub(crate) color: ColorChoice, pub(crate) native_tls: bool, + pub(crate) concurrency: Concurrency, pub(crate) connectivity: Connectivity, pub(crate) show_settings: bool, pub(crate) preview: PreviewMode, @@ -86,6 +87,20 @@ impl GlobalSettings { native_tls: flag(args.native_tls, args.no_native_tls) .combine(workspace.and_then(|workspace| workspace.globals.native_tls)) .unwrap_or(false), + concurrency: Concurrency { + downloads: env(env::CONCURRENT_DOWNLOADS) + .combine(workspace.and_then(|workspace| workspace.globals.concurrent_downloads)) + .map(NonZeroUsize::get) + .unwrap_or(Concurrency::DEFAULT_DOWNLOADS), + builds: env(env::CONCURRENT_BUILDS) + .combine(workspace.and_then(|workspace| workspace.globals.concurrent_builds)) + .map(NonZeroUsize::get) + .unwrap_or_else(Concurrency::threads), + installs: env(env::CONCURRENT_INSTALLS) + .combine(workspace.and_then(|workspace| workspace.globals.concurrent_installs)) + .map(NonZeroUsize::get) + .unwrap_or_else(Concurrency::threads), + }, connectivity: if flag(args.offline, args.no_offline) .combine(workspace.and_then(|workspace| workspace.globals.offline)) .unwrap_or(false) @@ -1019,9 +1034,6 @@ impl PipCompileSettings { emit_marker_expression: flag(emit_marker_expression, no_emit_marker_expression), emit_index_annotation: flag(emit_index_annotation, no_emit_index_annotation), annotation_style, - concurrent_builds: env(env::CONCURRENT_BUILDS), - concurrent_downloads: env(env::CONCURRENT_DOWNLOADS), - concurrent_installs: env(env::CONCURRENT_INSTALLS), ..PipOptions::from(resolver) }, filesystem, @@ -1110,9 +1122,6 @@ impl PipSyncSettings { python_version, python_platform, strict: flag(strict, no_strict), - concurrent_builds: env(env::CONCURRENT_BUILDS), - concurrent_downloads: env(env::CONCURRENT_DOWNLOADS), - concurrent_installs: env(env::CONCURRENT_INSTALLS), ..PipOptions::from(installer) }, filesystem, @@ -1247,9 +1256,6 @@ impl PipInstallSettings { python_platform, require_hashes: flag(require_hashes, no_require_hashes), verify_hashes: flag(verify_hashes, no_verify_hashes), - concurrent_builds: env(env::CONCURRENT_BUILDS), - concurrent_downloads: env(env::CONCURRENT_DOWNLOADS), - concurrent_installs: env(env::CONCURRENT_INSTALLS), ..PipOptions::from(installer) }, filesystem, @@ -1852,7 +1858,6 @@ pub(crate) struct PipSettings { pub(crate) hash_checking: Option, pub(crate) upgrade: Upgrade, pub(crate) reinstall: Reinstall, - pub(crate) concurrency: Concurrency, } impl PipSettings { @@ -1915,9 +1920,6 @@ impl PipSettings { upgrade_package, reinstall, reinstall_package, - concurrent_builds, - concurrent_downloads, - concurrent_installs, } = pip.unwrap_or_default(); let ResolverInstallerOptions { @@ -2112,23 +2114,6 @@ impl PipSettings { .combine(reinstall_package) .unwrap_or_default(), ), - concurrency: Concurrency { - downloads: args - .concurrent_downloads - .combine(concurrent_downloads) - .map(NonZeroUsize::get) - .unwrap_or(Concurrency::DEFAULT_DOWNLOADS), - builds: args - .concurrent_builds - .combine(concurrent_builds) - .map(NonZeroUsize::get) - .unwrap_or_else(Concurrency::threads), - installs: args - .concurrent_installs - .combine(concurrent_installs) - .map(NonZeroUsize::get) - .unwrap_or_else(Concurrency::threads), - }, build_options: BuildOptions::new( NoBinary::from_pip_args(args.no_binary.combine(no_binary).unwrap_or_default()) .combine(NoBinary::from_args( diff --git a/crates/uv/tests/show_settings.rs b/crates/uv/tests/show_settings.rs index 9326b55894daf..ee9b5aa1a7348 100644 --- a/crates/uv/tests/show_settings.rs +++ b/crates/uv/tests/show_settings.rs @@ -52,6 +52,11 @@ fn resolve_uv_toml() -> anyhow::Result<()> { verbose: 0, color: Auto, native_tls: false, + concurrency: Concurrency { + downloads: 50, + builds: 16, + installs: 8, + }, connectivity: Online, show_settings: true, preview: Disabled, @@ -163,11 +168,6 @@ fn resolve_uv_toml() -> anyhow::Result<()> { hash_checking: None, upgrade: None, reinstall: None, - concurrency: Concurrency { - downloads: 50, - builds: 16, - installs: 8, - }, }, } @@ -188,6 +188,11 @@ fn resolve_uv_toml() -> anyhow::Result<()> { verbose: 0, color: Auto, native_tls: false, + concurrency: Concurrency { + downloads: 50, + builds: 16, + installs: 8, + }, connectivity: Online, show_settings: true, preview: Disabled, @@ -299,11 +304,6 @@ fn resolve_uv_toml() -> anyhow::Result<()> { hash_checking: None, upgrade: None, reinstall: None, - concurrency: Concurrency { - downloads: 50, - builds: 16, - installs: 8, - }, }, } @@ -325,6 +325,11 @@ fn resolve_uv_toml() -> anyhow::Result<()> { verbose: 0, color: Auto, native_tls: false, + concurrency: Concurrency { + downloads: 50, + builds: 16, + installs: 8, + }, connectivity: Online, show_settings: true, preview: Disabled, @@ -436,11 +441,6 @@ fn resolve_uv_toml() -> anyhow::Result<()> { hash_checking: None, upgrade: None, reinstall: None, - concurrency: Concurrency { - downloads: 50, - builds: 16, - installs: 8, - }, }, } @@ -494,6 +494,11 @@ fn resolve_pyproject_toml() -> anyhow::Result<()> { verbose: 0, color: Auto, native_tls: false, + concurrency: Concurrency { + downloads: 50, + builds: 16, + installs: 8, + }, connectivity: Online, show_settings: true, preview: Disabled, @@ -605,11 +610,6 @@ fn resolve_pyproject_toml() -> anyhow::Result<()> { hash_checking: None, upgrade: None, reinstall: None, - concurrency: Concurrency { - downloads: 50, - builds: 16, - installs: 8, - }, }, } @@ -632,6 +632,11 @@ fn resolve_pyproject_toml() -> anyhow::Result<()> { verbose: 0, color: Auto, native_tls: false, + concurrency: Concurrency { + downloads: 50, + builds: 16, + installs: 8, + }, connectivity: Online, show_settings: true, preview: Disabled, @@ -720,11 +725,6 @@ fn resolve_pyproject_toml() -> anyhow::Result<()> { hash_checking: None, upgrade: None, reinstall: None, - concurrency: Concurrency { - downloads: 50, - builds: 16, - installs: 8, - }, }, } @@ -756,6 +756,11 @@ fn resolve_pyproject_toml() -> anyhow::Result<()> { verbose: 0, color: Auto, native_tls: false, + concurrency: Concurrency { + downloads: 50, + builds: 16, + installs: 8, + }, connectivity: Online, show_settings: true, preview: Disabled, @@ -867,11 +872,6 @@ fn resolve_pyproject_toml() -> anyhow::Result<()> { hash_checking: None, upgrade: None, reinstall: None, - concurrency: Concurrency { - downloads: 50, - builds: 16, - installs: 8, - }, }, } @@ -917,6 +917,11 @@ fn resolve_index_url() -> anyhow::Result<()> { verbose: 0, color: Auto, native_tls: false, + concurrency: Concurrency { + downloads: 50, + builds: 16, + installs: 8, + }, connectivity: Online, show_settings: true, preview: Disabled, @@ -1051,11 +1056,6 @@ fn resolve_index_url() -> anyhow::Result<()> { hash_checking: None, upgrade: None, reinstall: None, - concurrency: Concurrency { - downloads: 50, - builds: 16, - installs: 8, - }, }, } @@ -1078,6 +1078,11 @@ fn resolve_index_url() -> anyhow::Result<()> { verbose: 0, color: Auto, native_tls: false, + concurrency: Concurrency { + downloads: 50, + builds: 16, + installs: 8, + }, connectivity: Online, show_settings: true, preview: Disabled, @@ -1234,11 +1239,6 @@ fn resolve_index_url() -> anyhow::Result<()> { hash_checking: None, upgrade: None, reinstall: None, - concurrency: Concurrency { - downloads: 50, - builds: 16, - installs: 8, - }, }, } @@ -1284,6 +1284,11 @@ fn resolve_find_links() -> anyhow::Result<()> { verbose: 0, color: Auto, native_tls: false, + concurrency: Concurrency { + downloads: 50, + builds: 16, + installs: 8, + }, connectivity: Online, show_settings: true, preview: Disabled, @@ -1395,11 +1400,6 @@ fn resolve_find_links() -> anyhow::Result<()> { hash_checking: None, upgrade: None, reinstall: None, - concurrency: Concurrency { - downloads: 50, - builds: 16, - installs: 8, - }, }, } @@ -1444,6 +1444,11 @@ fn resolve_top_level() -> anyhow::Result<()> { verbose: 0, color: Auto, native_tls: false, + concurrency: Concurrency { + downloads: 50, + builds: 16, + installs: 8, + }, connectivity: Online, show_settings: true, preview: Disabled, @@ -1532,11 +1537,6 @@ fn resolve_top_level() -> anyhow::Result<()> { hash_checking: None, upgrade: None, reinstall: None, - concurrency: Concurrency { - downloads: 50, - builds: 16, - installs: 8, - }, }, } @@ -1574,6 +1574,11 @@ fn resolve_top_level() -> anyhow::Result<()> { verbose: 0, color: Auto, native_tls: false, + concurrency: Concurrency { + downloads: 50, + builds: 16, + installs: 8, + }, connectivity: Online, show_settings: true, preview: Disabled, @@ -1707,11 +1712,6 @@ fn resolve_top_level() -> anyhow::Result<()> { hash_checking: None, upgrade: None, reinstall: None, - concurrency: Concurrency { - downloads: 50, - builds: 16, - installs: 8, - }, }, } @@ -1732,6 +1732,11 @@ fn resolve_top_level() -> anyhow::Result<()> { verbose: 0, color: Auto, native_tls: false, + concurrency: Concurrency { + downloads: 50, + builds: 16, + installs: 8, + }, connectivity: Online, show_settings: true, preview: Disabled, @@ -1865,11 +1870,6 @@ fn resolve_top_level() -> anyhow::Result<()> { hash_checking: None, upgrade: None, reinstall: None, - concurrency: Concurrency { - downloads: 50, - builds: 16, - installs: 8, - }, }, } @@ -1914,6 +1914,11 @@ fn resolve_user_configuration() -> anyhow::Result<()> { verbose: 0, color: Auto, native_tls: false, + concurrency: Concurrency { + downloads: 50, + builds: 16, + installs: 8, + }, connectivity: Online, show_settings: true, preview: Disabled, @@ -2002,11 +2007,6 @@ fn resolve_user_configuration() -> anyhow::Result<()> { hash_checking: None, upgrade: None, reinstall: None, - concurrency: Concurrency { - downloads: 50, - builds: 16, - installs: 8, - }, }, } @@ -2034,6 +2034,11 @@ fn resolve_user_configuration() -> anyhow::Result<()> { verbose: 0, color: Auto, native_tls: false, + concurrency: Concurrency { + downloads: 50, + builds: 16, + installs: 8, + }, connectivity: Online, show_settings: true, preview: Disabled, @@ -2122,11 +2127,6 @@ fn resolve_user_configuration() -> anyhow::Result<()> { hash_checking: None, upgrade: None, reinstall: None, - concurrency: Concurrency { - downloads: 50, - builds: 16, - installs: 8, - }, }, } @@ -2154,6 +2154,11 @@ fn resolve_user_configuration() -> anyhow::Result<()> { verbose: 0, color: Auto, native_tls: false, + concurrency: Concurrency { + downloads: 50, + builds: 16, + installs: 8, + }, connectivity: Online, show_settings: true, preview: Disabled, @@ -2242,11 +2247,6 @@ fn resolve_user_configuration() -> anyhow::Result<()> { hash_checking: None, upgrade: None, reinstall: None, - concurrency: Concurrency { - downloads: 50, - builds: 16, - installs: 8, - }, }, } @@ -2276,6 +2276,11 @@ fn resolve_user_configuration() -> anyhow::Result<()> { verbose: 0, color: Auto, native_tls: false, + concurrency: Concurrency { + downloads: 50, + builds: 16, + installs: 8, + }, connectivity: Online, show_settings: true, preview: Disabled, @@ -2364,11 +2369,6 @@ fn resolve_user_configuration() -> anyhow::Result<()> { hash_checking: None, upgrade: None, reinstall: None, - concurrency: Concurrency { - downloads: 50, - builds: 16, - installs: 8, - }, }, } @@ -2417,6 +2417,11 @@ fn resolve_tool() -> anyhow::Result<()> { verbose: 0, color: Auto, native_tls: false, + concurrency: Concurrency { + downloads: 50, + builds: 16, + installs: 8, + }, connectivity: Online, show_settings: true, preview: Disabled, @@ -2563,6 +2568,11 @@ fn resolve_poetry_toml() -> anyhow::Result<()> { verbose: 0, color: Auto, native_tls: false, + concurrency: Concurrency { + downloads: 50, + builds: 16, + installs: 8, + }, connectivity: Online, show_settings: true, preview: Disabled, @@ -2651,11 +2661,6 @@ fn resolve_poetry_toml() -> anyhow::Result<()> { hash_checking: None, upgrade: None, reinstall: None, - concurrency: Concurrency { - downloads: 50, - builds: 16, - installs: 8, - }, }, } @@ -2711,6 +2716,11 @@ fn resolve_both() -> anyhow::Result<()> { verbose: 0, color: Auto, native_tls: false, + concurrency: Concurrency { + downloads: 50, + builds: 16, + installs: 8, + }, connectivity: Online, show_settings: true, preview: Disabled, @@ -2822,11 +2832,6 @@ fn resolve_both() -> anyhow::Result<()> { hash_checking: None, upgrade: None, reinstall: None, - concurrency: Concurrency { - downloads: 50, - builds: 16, - installs: 8, - }, }, } @@ -2874,6 +2879,11 @@ fn resolve_config_file() -> anyhow::Result<()> { verbose: 0, color: Auto, native_tls: false, + concurrency: Concurrency { + downloads: 50, + builds: 16, + installs: 8, + }, connectivity: Online, show_settings: true, preview: Disabled, @@ -2985,11 +2995,6 @@ fn resolve_config_file() -> anyhow::Result<()> { hash_checking: None, upgrade: None, reinstall: None, - concurrency: Concurrency { - downloads: 50, - builds: 16, - installs: 8, - }, }, } @@ -3112,6 +3117,11 @@ fn resolve_skip_empty() -> anyhow::Result<()> { verbose: 0, color: Auto, native_tls: false, + concurrency: Concurrency { + downloads: 50, + builds: 16, + installs: 8, + }, connectivity: Online, show_settings: true, preview: Disabled, @@ -3200,11 +3210,6 @@ fn resolve_skip_empty() -> anyhow::Result<()> { hash_checking: None, upgrade: None, reinstall: None, - concurrency: Concurrency { - downloads: 50, - builds: 16, - installs: 8, - }, }, } @@ -3235,6 +3240,11 @@ fn resolve_skip_empty() -> anyhow::Result<()> { verbose: 0, color: Auto, native_tls: false, + concurrency: Concurrency { + downloads: 50, + builds: 16, + installs: 8, + }, connectivity: Online, show_settings: true, preview: Disabled, @@ -3323,11 +3333,6 @@ fn resolve_skip_empty() -> anyhow::Result<()> { hash_checking: None, upgrade: None, reinstall: None, - concurrency: Concurrency { - downloads: 50, - builds: 16, - installs: 8, - }, }, } diff --git a/docs/reference/settings.md b/docs/reference/settings.md index 779d6bb08dcec..30a7b411fd958 100644 --- a/docs/reference/settings.md +++ b/docs/reference/settings.md @@ -61,6 +61,87 @@ ignore errors. --- +#### [`concurrent-builds`](#concurrent-builds) {: #concurrent-builds } + +The maximum number of source distributions that uv will build concurrently at any given +time. + +Defaults to the number of available CPU cores. + +**Default value**: `None` + +**Type**: `int` + +**Example usage**: + +=== "pyproject.toml" + + ```toml + [tool.uv] + concurrent-builds = 4 + ``` +=== "uv.toml" + + ```toml + + concurrent-builds = 4 + ``` + +--- + +#### [`concurrent-downloads`](#concurrent-downloads) {: #concurrent-downloads } + +The maximum number of in-flight concurrent downloads that uv will perform at any given +time. + +**Default value**: `50` + +**Type**: `int` + +**Example usage**: + +=== "pyproject.toml" + + ```toml + [tool.uv] + concurrent-downloads = 4 + ``` +=== "uv.toml" + + ```toml + + concurrent-downloads = 4 + ``` + +--- + +#### [`concurrent-installs`](#concurrent-installs) {: #concurrent-installs } + +The number of threads used when installing and unzipping packages. + +Defaults to the number of available CPU cores. + +**Default value**: `None` + +**Type**: `int` + +**Example usage**: + +=== "pyproject.toml" + + ```toml + [tool.uv] + concurrent-installs = 4 + ``` +=== "uv.toml" + + ```toml + + concurrent-installs = 4 + ``` + +--- + #### [`config-settings`](#config-settings) {: #config-settings } Settings to pass to the [PEP 517](https://peps.python.org/pep-0517/) build backend, @@ -1048,90 +1129,6 @@ ignore errors. --- -#### [`concurrent-builds`](#pip_concurrent-builds) {: #pip_concurrent-builds } - - -The maximum number of source distributions that uv will build concurrently at any given -time. - -Defaults to the number of available CPU cores. - -**Default value**: `None` - -**Type**: `int` - -**Example usage**: - -=== "pyproject.toml" - - ```toml - [tool.uv.pip] - concurrent-builds = 4 - ``` -=== "uv.toml" - - ```toml - [pip] - concurrent-builds = 4 - ``` - ---- - -#### [`concurrent-downloads`](#pip_concurrent-downloads) {: #pip_concurrent-downloads } - - -The maximum number of in-flight concurrent downloads that uv will perform at any given -time. - -**Default value**: `50` - -**Type**: `int` - -**Example usage**: - -=== "pyproject.toml" - - ```toml - [tool.uv.pip] - concurrent-downloads = 4 - ``` -=== "uv.toml" - - ```toml - [pip] - concurrent-downloads = 4 - ``` - ---- - -#### [`concurrent-installs`](#pip_concurrent-installs) {: #pip_concurrent-installs } - - -The number of threads used when installing and unzipping packages. - -Defaults to the number of available CPU cores. - -**Default value**: `None` - -**Type**: `int` - -**Example usage**: - -=== "pyproject.toml" - - ```toml - [tool.uv.pip] - concurrent-installs = 4 - ``` -=== "uv.toml" - - ```toml - [pip] - concurrent-installs = 4 - ``` - ---- - #### [`config-settings`](#pip_config-settings) {: #pip_config-settings } diff --git a/uv.schema.json b/uv.schema.json index 0ac5a8819bfba..94bf6bc319527 100644 --- a/uv.schema.json +++ b/uv.schema.json @@ -18,6 +18,33 @@ "null" ] }, + "concurrent-builds": { + "description": "The maximum number of source distributions that uv will build concurrently at any given time.\n\nDefaults to the number of available CPU cores.", + "type": [ + "integer", + "null" + ], + "format": "uint", + "minimum": 1.0 + }, + "concurrent-downloads": { + "description": "The maximum number of in-flight concurrent downloads that uv will perform at any given time.", + "type": [ + "integer", + "null" + ], + "format": "uint", + "minimum": 1.0 + }, + "concurrent-installs": { + "description": "The number of threads used when installing and unzipping packages.\n\nDefaults to the number of available CPU cores.", + "type": [ + "integer", + "null" + ], + "format": "uint", + "minimum": 1.0 + }, "config-settings": { "description": "Settings to pass to the [PEP 517](https://peps.python.org/pep-0517/) build backend, specified as `KEY=VALUE` pairs.", "anyOf": [ @@ -550,33 +577,6 @@ "null" ] }, - "concurrent-builds": { - "description": "The maximum number of source distributions that uv will build concurrently at any given time.\n\nDefaults to the number of available CPU cores.", - "type": [ - "integer", - "null" - ], - "format": "uint", - "minimum": 1.0 - }, - "concurrent-downloads": { - "description": "The maximum number of in-flight concurrent downloads that uv will perform at any given time.", - "type": [ - "integer", - "null" - ], - "format": "uint", - "minimum": 1.0 - }, - "concurrent-installs": { - "description": "The number of threads used when installing and unzipping packages.\n\nDefaults to the number of available CPU cores.", - "type": [ - "integer", - "null" - ], - "format": "uint", - "minimum": 1.0 - }, "config-settings": { "description": "Settings to pass to the [PEP 517](https://peps.python.org/pep-0517/) build backend, specified as `KEY=VALUE` pairs.", "anyOf": [