Skip to content
Draft
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
34 changes: 32 additions & 2 deletions crates/uv-configuration/src/concurrency.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ pub struct Concurrency {
///
/// Note this value must be non-zero.
pub installs: usize,
/// The maximum number of concurrent publish uploads.
///
/// Note this value must be non-zero.
pub uploads: usize,
/// The maximum number of concurrent pyx wheel validations.
///
/// Note this value must be non-zero.
pub pyx_wheel_validations: usize,
/// A global semaphore to limit the number of concurrent downloads.
pub downloads_semaphore: Arc<Semaphore>,
/// A global semaphore to limit the number of concurrent builds.
Expand All @@ -34,26 +42,48 @@ impl fmt::Debug for Concurrency {
.field("downloads", &self.downloads)
.field("builds", &self.builds)
.field("installs", &self.installs)
.field("uploads", &self.uploads)
.field("pyx_wheel_validations", &self.pyx_wheel_validations)
.finish()
}
}

impl Default for Concurrency {
fn default() -> Self {
Self::new(Self::DEFAULT_DOWNLOADS, Self::threads(), Self::threads())
Self::new(
Self::DEFAULT_DOWNLOADS,
Self::threads(),
Self::threads(),
Self::DEFAULT_UPLOADS,
Self::DEFAULT_PYX_WHEEL_VALIDATIONS,
)
}
}

impl Concurrency {
// The default concurrent downloads limit.
pub const DEFAULT_DOWNLOADS: usize = 50;

// The default concurrent uploads limit.
pub const DEFAULT_UPLOADS: usize = 1;

// The default concurrent pyx wheel validations limit.
pub const DEFAULT_PYX_WHEEL_VALIDATIONS: usize = 32;

/// Create a new [`Concurrency`] with the given limits.
pub fn new(downloads: usize, builds: usize, installs: usize) -> Self {
pub fn new(
downloads: usize,
builds: usize,
installs: usize,
uploads: usize,
pyx_wheel_validations: usize,
) -> Self {
Self {
downloads,
builds,
installs,
uploads,
pyx_wheel_validations,
downloads_semaphore: Arc::new(Semaphore::new(downloads)),
builds_semaphore: Arc::new(Semaphore::new(builds)),
}
Expand Down
7 changes: 7 additions & 0 deletions crates/uv-settings/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,8 @@ pub struct Concurrency {
pub downloads: Option<NonZeroUsize>,
pub builds: Option<NonZeroUsize>,
pub installs: Option<NonZeroUsize>,
pub uploads: Option<NonZeroUsize>,
pub pyx_wheel_validations: Option<NonZeroUsize>,
}

/// A boolean flag parsed from an environment variable.
Expand Down Expand Up @@ -790,6 +792,11 @@ impl EnvironmentOptions {
EnvVars::UV_CONCURRENT_INSTALLS,
None,
)?,
uploads: parse_integer_environment_variable(EnvVars::UV_CONCURRENT_UPLOADS, None)?,
pyx_wheel_validations: parse_integer_environment_variable(
EnvVars::UV_CONCURRENT_PYX_WHEEL_VALIDATIONS,
None,
)?,
},
install_mirrors: PythonInstallMirrors {
python_install_mirror: parse_string_environment_variable(
Expand Down
11 changes: 11 additions & 0 deletions crates/uv-static/src/env_vars.rs
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,17 @@ impl EnvVars {
#[attr_added_in("0.1.45")]
pub const UV_CONCURRENT_INSTALLS: &'static str = "UV_CONCURRENT_INSTALLS";

/// Sets the maximum number of concurrent publish uploads that uv will
/// perform at any given time.
#[attr_added_in("next release")]
pub const UV_CONCURRENT_UPLOADS: &'static str = "UV_CONCURRENT_UPLOADS";

/// Sets the maximum number of concurrent pyx wheel validations that uv will
/// perform at any given time during `uv publish --dry-run` with direct mode.
#[attr_added_in("next release")]
pub const UV_CONCURRENT_PYX_WHEEL_VALIDATIONS: &'static str =
"UV_CONCURRENT_PYX_WHEEL_VALIDATIONS";

/// Equivalent to the `--no-progress` command-line argument. Disables all progress output. For
/// example, spinners and progress bars.
#[attr_added_in("0.2.28")]
Expand Down
Loading
Loading