Skip to content
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
1 change: 1 addition & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions crates/uv-build/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ uv-static = { workspace = true }

anstream = { workspace = true }
anyhow = { workspace = true }
tracing = { workspace = true }
tracing-subscriber = { workspace = true, features = ["env-filter"] }

[lints]
Expand Down
7 changes: 7 additions & 0 deletions crates/uv-build/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use uv_preview::Preview;
use uv_static::{EnvVars, parse_boolish_environment_variable};

use anyhow::{Context, Result, bail};
use tracing::debug;
use tracing_subscriber::filter::LevelFilter;
use tracing_subscriber::layer::SubscriberExt;
use tracing_subscriber::util::SubscriberInitExt;
Expand Down Expand Up @@ -57,6 +58,12 @@ fn main() -> Result<()> {
} else {
Preview::default()
};
if preview.all_enabled() {
debug!("All preview features are enabled");
} else if preview.any_enabled() {
debug!("The following preview features are enabled: {preview}");
}

match command.as_str() {
"build-sdist" => {
let sdist_directory = PathBuf::from(args.next().context("Missing sdist directory")?);
Expand Down
8 changes: 4 additions & 4 deletions crates/uv-fs/src/locked_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ impl LockedFile {
let try_lock_exclusive = tokio::task::spawn_blocking(move || (mode.try_lock(&file), file));
let file = match try_lock_exclusive.await? {
(Ok(()), file) => {
debug!("Acquired {mode} lock for `{resource}`");
trace!("Acquired {mode} lock for `{resource}`");
return Ok(Self(file));
}
(Err(err), file) => {
Expand Down Expand Up @@ -180,7 +180,7 @@ impl LockedFile {
source: err,
})?;

debug!("Acquired {mode} lock for `{resource}`");
trace!("Acquired {mode} lock for `{resource}`");
Ok(Self(file))
}

Expand All @@ -192,7 +192,7 @@ impl LockedFile {
);
match mode.try_lock(&file) {
Ok(()) => {
debug!("Acquired {mode} lock for `{resource}`");
trace!("Acquired {mode} lock for `{resource}`");
Some(Self(file))
}
Err(err) => {
Expand Down Expand Up @@ -341,7 +341,7 @@ impl Drop for LockedFile {
self.0.path().display()
);
} else {
debug!("Released lock at `{}`", self.0.path().display());
trace!("Released lock at `{}`", self.0.path().display());
}
}
}
12 changes: 11 additions & 1 deletion crates/uv-preview/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,20 @@ impl Preview {
Self::new(preview_features)
}

/// Check if a single feature is enabled
/// Check if a single feature is enabled.
pub fn is_enabled(&self, flag: PreviewFeature) -> bool {
self.flags.contains(flag)
}

/// Check if all preview feature rae enabled.
pub fn all_enabled(&self) -> bool {
self.flags.is_all()
}

/// Check if any preview feature is enabled.
pub fn any_enabled(&self) -> bool {
!self.flags.is_empty()
}
}

impl Display for Preview {
Expand Down
56 changes: 32 additions & 24 deletions crates/uv/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,38 @@ async fn run(mut cli: Cli) -> Result<ExitStatus> {
&environment,
);

// Set the global flags.
uv_flags::init(EnvironmentFlags::from(&environment))
.map_err(|()| anyhow::anyhow!("Flags are already initialized"))?;

// Configure the `tracing` crate, which controls internal logging.
#[cfg(feature = "tracing-durations-export")]
let (durations_layer, _duration_guard) =
logging::setup_durations(environment.tracing_durations_file.as_ref())?;
#[cfg(not(feature = "tracing-durations-export"))]
let durations_layer = None::<tracing_subscriber::layer::Identity>;
logging::setup_logging(
match globals.verbose {
0 => logging::Level::Off,
1 => logging::Level::DebugUv,
2 => logging::Level::TraceUv,
3.. => logging::Level::TraceAll,
},
durations_layer,
globals.color,
environment.log_context.unwrap_or_default(),
)?;

debug!("uv {}", uv_cli::version::uv_self_version());
if globals.preview.all_enabled() {
debug!("All preview features are enabled");
} else if globals.preview.any_enabled() {
debug!(
"The following preview features are enabled: {}",
globals.preview
);
}

// Adjust open file limits on Unix if the preview feature is enabled.
#[cfg(unix)]
if globals.preview.is_enabled(PreviewFeature::AdjustUlimit) {
Expand All @@ -353,10 +385,6 @@ async fn run(mut cli: Cli) -> Result<ExitStatus> {
// Resolve the cache settings.
let cache_settings = CacheSettings::resolve(*cli.top_level.cache_args, filesystem.as_ref());

// Set the global flags.
uv_flags::init(EnvironmentFlags::from(&environment))
.map_err(|()| anyhow::anyhow!("Flags are already initialized"))?;

// Enforce the required version.
if let Some(required_version) = globals.required_version.as_ref() {
let package_version = uv_pep440::Version::from_str(uv_version::version())?;
Expand Down Expand Up @@ -396,24 +424,6 @@ async fn run(mut cli: Cli) -> Result<ExitStatus> {
}
}

// Configure the `tracing` crate, which controls internal logging.
#[cfg(feature = "tracing-durations-export")]
let (durations_layer, _duration_guard) =
logging::setup_durations(environment.tracing_durations_file.as_ref())?;
#[cfg(not(feature = "tracing-durations-export"))]
let durations_layer = None::<tracing_subscriber::layer::Identity>;
logging::setup_logging(
match globals.verbose {
0 => logging::Level::Off,
1 => logging::Level::DebugUv,
2 => logging::Level::TraceUv,
3.. => logging::Level::TraceAll,
},
durations_layer,
globals.color,
environment.log_context.unwrap_or_default(),
)?;

// Configure the `Printer`, which controls user-facing output in the CLI.
let printer = if globals.quiet == 1 {
Printer::Quiet
Expand Down Expand Up @@ -454,8 +464,6 @@ async fn run(mut cli: Cli) -> Result<ExitStatus> {
// Don't initialize the rayon threadpool yet, this is too costly when we're doing a noop sync.
uv_configuration::RAYON_PARALLELISM.store(globals.concurrency.installs, Ordering::Relaxed);

debug!("uv {}", uv_cli::version::uv_self_version());

// Write out any resolved settings.
macro_rules! show_settings {
($arg:expr) => {
Expand Down
10 changes: 0 additions & 10 deletions crates/uv/tests/it/cache_clean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ fn clean_all() -> Result<()> {

----- stderr -----
DEBUG uv [VERSION] ([COMMIT] DATE)
DEBUG Acquired exclusive lock for `[CACHE_DIR]/`
Clearing cache at: [CACHE_DIR]/
DEBUG Released lock at `[CACHE_DIR]/.lock`
Removed [N] files ([SIZE])
");

Expand Down Expand Up @@ -60,9 +58,7 @@ async fn clean_force() -> Result<()> {

----- stderr -----
DEBUG uv [VERSION] ([COMMIT] DATE)
DEBUG Acquired exclusive lock for `[CACHE_DIR]/`
Clearing cache at: [CACHE_DIR]/
DEBUG Released lock at `[CACHE_DIR]/.lock`
Removed [N] files ([SIZE])
");

Expand Down Expand Up @@ -140,10 +136,8 @@ fn clean_package_pypi() -> Result<()> {

----- stderr -----
DEBUG uv [VERSION] ([COMMIT] DATE)
DEBUG Acquired exclusive lock for `[CACHE_DIR]/`
DEBUG Removing dangling cache entry: [CACHE_DIR]/archive-v0/[ENTRY]
Removed [N] files ([SIZE])
DEBUG Released lock at `[CACHE_DIR]/.lock`
");

// Assert that the `.rkyv` file is removed for `iniconfig`.
Expand All @@ -160,10 +154,8 @@ fn clean_package_pypi() -> Result<()> {

----- stderr -----
DEBUG uv [VERSION] ([COMMIT] DATE)
DEBUG Acquired exclusive lock for `[CACHE_DIR]/`
Pruning cache at: [CACHE_DIR]/
No unused entries found
DEBUG Released lock at `[CACHE_DIR]/.lock`
");

Ok(())
Expand Down Expand Up @@ -219,10 +211,8 @@ fn clean_package_index() -> Result<()> {

----- stderr -----
DEBUG uv [VERSION] ([COMMIT] DATE)
DEBUG Acquired exclusive lock for `[CACHE_DIR]/`
DEBUG Removing dangling cache entry: [CACHE_DIR]/archive-v0/[ENTRY]
Removed [N] files ([SIZE])
DEBUG Released lock at `[CACHE_DIR]/.lock`
");

// Assert that the `.rkyv` file is removed for `iniconfig`.
Expand Down
12 changes: 0 additions & 12 deletions crates/uv/tests/it/cache_prune.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,8 @@ fn prune_no_op() -> Result<()> {

----- stderr -----
DEBUG uv [VERSION] ([COMMIT] DATE)
DEBUG Acquired exclusive lock for `[CACHE_DIR]/`
Pruning cache at: [CACHE_DIR]/
No unused entries found
DEBUG Released lock at `[CACHE_DIR]/.lock`
");

Ok(())
Expand Down Expand Up @@ -76,11 +74,9 @@ fn prune_stale_directory() -> Result<()> {

----- stderr -----
DEBUG uv [VERSION] ([COMMIT] DATE)
DEBUG Acquired exclusive lock for `[CACHE_DIR]/`
Pruning cache at: [CACHE_DIR]/
DEBUG Removing dangling cache bucket: [CACHE_DIR]/simple-v4
Removed 1 directory
DEBUG Released lock at `[CACHE_DIR]/.lock`
");

Ok(())
Expand Down Expand Up @@ -138,12 +134,10 @@ fn prune_cached_env() {

----- stderr -----
DEBUG uv [VERSION] ([COMMIT] DATE)
DEBUG Acquired exclusive lock for `[CACHE_DIR]/`
Pruning cache at: [CACHE_DIR]/
DEBUG Removing dangling cache environment: [CACHE_DIR]/environments-v2/[ENTRY]
DEBUG Removing dangling cache archive: [CACHE_DIR]/archive-v0/[ENTRY]
Removed [N] files ([SIZE])
DEBUG Released lock at `[CACHE_DIR]/.lock`
");
}

Expand Down Expand Up @@ -185,11 +179,9 @@ fn prune_stale_symlink() -> Result<()> {

----- stderr -----
DEBUG uv [VERSION] ([COMMIT] DATE)
DEBUG Acquired exclusive lock for `[CACHE_DIR]/`
Pruning cache at: [CACHE_DIR]/
DEBUG Removing dangling cache archive: [CACHE_DIR]/archive-v0/[ENTRY]
Removed 44 files ([SIZE])
DEBUG Released lock at `[CACHE_DIR]/.lock`
");

Ok(())
Expand Down Expand Up @@ -217,10 +209,8 @@ async fn prune_force() -> Result<()> {

----- stderr -----
DEBUG uv [VERSION] ([COMMIT] DATE)
DEBUG Acquired exclusive lock for `[CACHE_DIR]/`
Pruning cache at: [CACHE_DIR]/
No unused entries found
DEBUG Released lock at `[CACHE_DIR]/.lock`
");

// Add a stale directory to the cache.
Expand Down Expand Up @@ -407,12 +397,10 @@ fn prune_stale_revision() -> Result<()> {

----- stderr -----
DEBUG uv [VERSION] ([COMMIT] DATE)
DEBUG Acquired exclusive lock for `[CACHE_DIR]/`
Pruning cache at: [CACHE_DIR]/
DEBUG Removing dangling source revision: [CACHE_DIR]/sdists-v9/[ENTRY]
DEBUG Removing dangling cache archive: [CACHE_DIR]/archive-v0/[ENTRY]
Removed [N] files ([SIZE])
DEBUG Released lock at `[CACHE_DIR]/.lock`
");

// Uninstall and reinstall the package. We should use the cached version.
Expand Down
2 changes: 0 additions & 2 deletions crates/uv/tests/it/lock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18841,7 +18841,6 @@ fn lock_explicit_default_index() -> Result<()> {

----- stderr -----
DEBUG uv [VERSION] ([COMMIT] DATE)
DEBUG Acquired shared lock for `[CACHE_DIR]/`
DEBUG Found workspace root: `[TEMP_DIR]/`
DEBUG Adding root workspace member: `[TEMP_DIR]/`
DEBUG No Python version file found in workspace: [TEMP_DIR]/
Expand All @@ -18866,7 +18865,6 @@ fn lock_explicit_default_index() -> Result<()> {
DEBUG No compatible version found for: project
× No solution found when resolving dependencies:
╰─▶ Because anyio was not found in the package registry and your project depends on anyio, we can conclude that your project's requirements are unsatisfiable.
DEBUG Released lock at `[CACHE_DIR]/.lock`
"#);

let lock = fs_err::read_to_string(context.temp_dir.join("uv.lock")).unwrap();
Expand Down
Loading