diff --git a/Cargo.lock b/Cargo.lock index 78880fa055..bfdff3265f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4701,7 +4701,6 @@ dependencies = [ "minijinja", "nix 0.29.0", "once_cell", - "parking_lot", "pathdiff", "pep440_rs", "pep508_rs", @@ -4721,6 +4720,7 @@ dependencies = [ "pixi_pty", "pixi_pypi_spec", "pixi_record", + "pixi_reporters", "pixi_spec", "pixi_spec_containers", "pixi_test_utils", @@ -5128,6 +5128,37 @@ dependencies = [ "url", ] +[[package]] +name = "pixi_reporters" +version = "0.1.0" +dependencies = [ + "console 0.15.11", + "futures", + "human_bytes", + "indexmap 2.10.0", + "indicatif", + "itertools 0.14.0", + "parking_lot", + "pixi_command_dispatcher", + "pixi_git", + "pixi_progress", + "pixi_spec", + "rattler", + "rattler_conda_types", + "rattler_repodata_gateway", + "regex", + "tokio", + "tracing", + "url", + "uv-configuration", + "uv-distribution", + "uv-distribution-types", + "uv-installer", + "uv-normalize", + "uv-redacted", + "uv-resolver", +] + [[package]] name = "pixi_spec" version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml index da69ecb130..674abeda13 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -182,6 +182,7 @@ pixi_manifest = { path = "crates/pixi_manifest" } pixi_progress = { path = "crates/pixi_progress" } pixi_pypi_spec = { path = "crates/pixi_pypi_spec" } pixi_record = { path = "crates/pixi_record" } +pixi_reporters = { path = "crates/pixi_reporters" } pixi_spec = { path = "crates/pixi_spec" } pixi_spec_containers = { path = "crates/pixi_spec_containers" } pixi_test_utils = { path = "crates/pixi_test_utils" } @@ -267,7 +268,6 @@ itertools = { workspace = true } miette = { workspace = true, features = ["fancy-no-backtrace"] } minijinja = { workspace = true, features = ["builtins"] } once_cell = { workspace = true } -parking_lot = { workspace = true } pathdiff = { workspace = true } rstest = { workspace = true } uv-build-frontend = { workspace = true } @@ -312,6 +312,7 @@ pixi_manifest = { workspace = true, features = ["rattler_lock"] } pixi_progress = { workspace = true } pixi_pypi_spec = { workspace = true } pixi_record = { workspace = true } +pixi_reporters = { workspace = true } pixi_spec = { workspace = true } pixi_spec_containers = { workspace = true } pixi_toml = { workspace = true } diff --git a/crates/pixi_reporters/Cargo.toml b/crates/pixi_reporters/Cargo.toml new file mode 100644 index 0000000000..5c3bae6a28 --- /dev/null +++ b/crates/pixi_reporters/Cargo.toml @@ -0,0 +1,51 @@ +[package] +authors.workspace = true +description = "Progress reporting infrastructure for pixi" +edition.workspace = true +homepage.workspace = true +license.workspace = true +name = "pixi_reporters" +readme.workspace = true +repository.workspace = true +version = "0.1.0" + +[dependencies] +# Standard library +futures = { workspace = true } +indexmap = { workspace = true } +itertools = { workspace = true } +parking_lot = { workspace = true } +tokio = { workspace = true } +url = { workspace = true } + +# Progress and UI +console = { workspace = true } +indicatif = { workspace = true } + +# Utilities +human_bytes = { workspace = true } +regex = { workspace = true } +tracing = { workspace = true } + +# Pixi ecosystem +pixi_command_dispatcher = { workspace = true } +pixi_git = { workspace = true } +pixi_progress = { workspace = true } +pixi_spec = { workspace = true } + +# Rattler ecosystem +rattler = { workspace = true } +rattler_conda_types = { workspace = true } +rattler_repodata_gateway = { workspace = true } + +# UV ecosystem +uv-configuration = { workspace = true } +uv-distribution = { workspace = true } +uv-distribution-types = { workspace = true } +uv-installer = { workspace = true } +uv-normalize = { workspace = true } +uv-redacted = { workspace = true } +uv-resolver = { workspace = true } + +[dev-dependencies] +# Add test dependencies if needed diff --git a/src/reporters/download_verify_reporter.rs b/crates/pixi_reporters/src/download_verify_reporter.rs similarity index 100% rename from src/reporters/download_verify_reporter.rs rename to crates/pixi_reporters/src/download_verify_reporter.rs diff --git a/src/reporters/git.rs b/crates/pixi_reporters/src/git.rs similarity index 100% rename from src/reporters/git.rs rename to crates/pixi_reporters/src/git.rs diff --git a/src/reporters/install_reporter.rs b/crates/pixi_reporters/src/install_reporter.rs similarity index 99% rename from src/reporters/install_reporter.rs rename to crates/pixi_reporters/src/install_reporter.rs index 615da41d23..c75aec4cda 100644 --- a/src/reporters/install_reporter.rs +++ b/crates/pixi_reporters/src/install_reporter.rs @@ -14,7 +14,7 @@ use rattler::install::Transaction; use rattler_conda_types::{PrefixRecord, RepoDataRecord}; use tokio::sync::mpsc::UnboundedReceiver; -use crate::reporters::{ +use crate::{ download_verify_reporter::BuildDownloadVerifyReporter, main_progress_bar::{MainProgressBar, Tracker}, }; diff --git a/src/reporters/mod.rs b/crates/pixi_reporters/src/lib.rs similarity index 95% rename from src/reporters/mod.rs rename to crates/pixi_reporters/src/lib.rs index 3ea90b7b6f..f90349f28e 100644 --- a/src/reporters/mod.rs +++ b/crates/pixi_reporters/src/lib.rs @@ -4,6 +4,7 @@ mod install_reporter; mod main_progress_bar; mod release_notes; mod repodata_reporter; +pub mod uv_reporter; use std::sync::LazyLock; @@ -20,15 +21,17 @@ use rattler_repodata_gateway::Reporter; pub use release_notes::format_release_notes; use uv_configuration::RAYON_INITIALIZE; -use crate::reporters::{ - install_reporter::SyncReporter, main_progress_bar::MainProgressBar, - repodata_reporter::RepodataReporter, -}; +use install_reporter::SyncReporter; +use main_progress_bar::MainProgressBar; +use repodata_reporter::RepodataReporter; + +// Re-export the uv_reporter types for external use +pub use uv_reporter::{UvReporter, UvReporterOptions}; /// A top-level reporter that combines the different reporters into one. This /// directly implements the [`pixi_command_dispatcher::Reporter`] trait. /// And subsequently, offloads the work to its sub progress reporters. -pub(crate) struct TopLevelProgress { +pub struct TopLevelProgress { source_checkout_reporter: GitCheckoutProgress, conda_solve_reporter: MainProgressBar, repodata_reporter: RepodataReporter, diff --git a/src/reporters/main_progress_bar.rs b/crates/pixi_reporters/src/main_progress_bar.rs similarity index 100% rename from src/reporters/main_progress_bar.rs rename to crates/pixi_reporters/src/main_progress_bar.rs diff --git a/src/reporters/release_notes.rs b/crates/pixi_reporters/src/release_notes.rs similarity index 100% rename from src/reporters/release_notes.rs rename to crates/pixi_reporters/src/release_notes.rs diff --git a/src/reporters/repodata_reporter.rs b/crates/pixi_reporters/src/repodata_reporter.rs similarity index 100% rename from src/reporters/repodata_reporter.rs rename to crates/pixi_reporters/src/repodata_reporter.rs diff --git a/src/uv_reporter.rs b/crates/pixi_reporters/src/uv_reporter.rs similarity index 93% rename from src/uv_reporter.rs rename to crates/pixi_reporters/src/uv_reporter.rs index b30609dc1c..d8b9c304af 100644 --- a/src/uv_reporter.rs +++ b/crates/pixi_reporters/src/uv_reporter.rs @@ -25,7 +25,7 @@ pub struct UvReporterOptions { } impl UvReporterOptions { - pub(crate) fn new() -> Self { + pub fn new() -> Self { Self { length: None, top_level_message: "", @@ -34,27 +34,33 @@ impl UvReporterOptions { } } - pub(crate) fn with_length(mut self, length: u64) -> Self { + pub fn with_length(mut self, length: u64) -> Self { self.length = Some(length); self } - pub(crate) fn with_top_level_message(mut self, message: &'static str) -> Self { + pub fn with_top_level_message(mut self, message: &'static str) -> Self { self.top_level_message = message; self } - pub(crate) fn with_existing(mut self, progress_bar: ProgressBar) -> Self { + pub fn with_existing(mut self, progress_bar: ProgressBar) -> Self { self.progress_bar = Some(progress_bar); self } - pub(crate) fn with_starting_tasks(mut self, tasks: impl Iterator) -> Self { + pub fn with_starting_tasks(mut self, tasks: impl Iterator) -> Self { self.starting_tasks = tasks.collect_vec(); self } } +impl Default for UvReporterOptions { + fn default() -> Self { + Self::new() + } +} + /// Reports on download progress. pub struct UvReporter { pb: ProgressBar, @@ -68,7 +74,7 @@ pub struct UvReporter { impl UvReporter { /// Create a new instance that will report on the progress the given uv reporter /// This uses a set size and message - pub(crate) fn new(options: UvReporterOptions) -> Self { + pub fn new(options: UvReporterOptions) -> Self { // Use a new progress bar if none was provided. let pb = if let Some(pb) = options.progress_bar { pixi_progress::global_multi_progress().add(pb) @@ -100,7 +106,7 @@ impl UvReporter { } } - pub(crate) fn new_arc(options: UvReporterOptions) -> Arc { + pub fn new_arc(options: UvReporterOptions) -> Arc { Arc::new(Self::new(options)) } @@ -108,14 +114,14 @@ impl UvReporter { self.scoped_tasks.lock().expect("progress lock poison") } - pub(crate) fn start(&self, message: String) -> usize { + pub fn start(&self, message: String) -> usize { let task = self.fmt.start(message); let mut lock = self.lock(); lock.push(Some(task)); lock.len() - 1 } - pub(crate) fn finish(&self, id: usize) { + pub fn finish(&self, id: usize) { let mut lock = self.lock(); let len = lock.len(); let task = lock @@ -127,11 +133,11 @@ impl UvReporter { } } - pub(crate) fn finish_all(&self) { + pub fn finish_all(&self) { self.pb.finish_and_clear() } - pub(crate) fn increment_progress(&self) { + pub fn increment_progress(&self) { self.pb.inc(1); } diff --git a/src/cli/build.rs b/src/cli/build.rs index e0614c03ca..e6cf5bc10d 100644 --- a/src/cli/build.rs +++ b/src/cli/build.rs @@ -12,7 +12,8 @@ use pixi_progress::global_multi_progress; use pixi_record::{PinnedPathSpec, PinnedSourceSpec}; use rattler_conda_types::{GenericVirtualPackage, Platform}; -use crate::{WorkspaceLocator, cli::cli_config::WorkspaceConfig, reporters::TopLevelProgress}; +use crate::{WorkspaceLocator, cli::cli_config::WorkspaceConfig}; +use pixi_reporters::TopLevelProgress; #[derive(Parser, Debug)] #[clap(verbatim_doc_comment)] diff --git a/src/cli/self_update.rs b/src/cli/self_update.rs index a6ed0f622a..5fcca3dfd7 100644 --- a/src/cli/self_update.rs +++ b/src/cli/self_update.rs @@ -15,7 +15,7 @@ use rattler_conda_types::Version; use std::str::FromStr; use crate::cli::GlobalOptions; -use crate::reporters::format_release_notes; +use pixi_reporters::format_release_notes; /// Update pixi to the latest version or a specific version. #[derive(Debug, clap::Parser)] diff --git a/src/global/project/mod.rs b/src/global/project/mod.rs index 8b2ae6f054..4f75aa0ba5 100644 --- a/src/global/project/mod.rs +++ b/src/global/project/mod.rs @@ -29,6 +29,7 @@ use pixi_config::{Config, RunPostLinkScripts, default_channel_config, pixi_home} use pixi_consts::consts::{self}; use pixi_manifest::PrioritizedChannel; use pixi_progress::global_multi_progress; +use pixi_reporters::TopLevelProgress; use pixi_spec_containers::DependencyMap; use pixi_utils::{executable_from_path, reqwest::build_reqwest_clients}; use rattler_conda_types::{ @@ -62,7 +63,6 @@ use crate::{ }, prefix::{Executable, Prefix}, repodata::Repodata, - reporters::TopLevelProgress, rlimit::try_increase_rlimit_to_sensible, }; diff --git a/src/install_pypi/mod.rs b/src/install_pypi/mod.rs index b15727d312..4d96593671 100644 --- a/src/install_pypi/mod.rs +++ b/src/install_pypi/mod.rs @@ -42,8 +42,8 @@ use crate::{ install_pypi::plan::{CachedWheels, RequiredDists}, lock_file::UvResolutionContext, prefix::Prefix, - uv_reporter::{UvReporter, UvReporterOptions}, }; +use pixi_reporters::{UvReporter, UvReporterOptions}; pub(crate) mod conda_pypi_clobber; pub(crate) mod conversions; diff --git a/src/lib.rs b/src/lib.rs index cad84fc472..458a6e782e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -13,11 +13,8 @@ pub(crate) mod repodata; pub mod task; pub mod workspace; -mod reporters; - mod rlimit; mod signals; -mod uv_reporter; pub mod variants; pub use lock_file::UpdateLockFileOptions; diff --git a/src/lock_file/resolve/pypi.rs b/src/lock_file/resolve/pypi.rs index ff49370f23..395a1a8150 100644 --- a/src/lock_file/resolve/pypi.rs +++ b/src/lock_file/resolve/pypi.rs @@ -18,6 +18,7 @@ use pixi_consts::consts; use pixi_manifest::{EnvironmentName, SystemRequirements, pypi::pypi_options::PypiOptions}; use pixi_pypi_spec::PixiPypiSpec; use pixi_record::PixiRecord; +use pixi_reporters::{UvReporter, UvReporterOptions}; use pixi_uv_conversions::{ ConversionError, as_uv_req, convert_uv_requirements_to_pep508, into_pinned_git_spec, pypi_options_to_build_options, pypi_options_to_index_locations, to_exclude_newer, @@ -63,7 +64,6 @@ use crate::{ resolver_provider::CondaResolverProvider, }, }, - uv_reporter::{UvReporter, UvReporterOptions}, workspace::{Environment, EnvironmentVars}, }; diff --git a/src/lock_file/update.rs b/src/lock_file/update.rs index 72511c5269..cfa340eab4 100644 --- a/src/lock_file/update.rs +++ b/src/lock_file/update.rs @@ -86,7 +86,7 @@ impl Workspace { let anchor_pb = multi_progress.add(ProgressBar::hidden()); let command_dispatcher = self .command_dispatcher_builder()? - .with_reporter(crate::reporters::TopLevelProgress::new( + .with_reporter(pixi_reporters::TopLevelProgress::new( global_multi_progress(), anchor_pb, )) @@ -1144,7 +1144,7 @@ impl<'p> UpdateContextBuilder<'p> { None => self .project .command_dispatcher_builder()? - .with_reporter(crate::reporters::TopLevelProgress::new( + .with_reporter(pixi_reporters::TopLevelProgress::new( global_multi_progress(), anchor_pb.clone(), ))