diff --git a/Cargo.lock b/Cargo.lock index 09e2c7682e..27ebc20069 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -164,9 +164,9 @@ checksum = "9b34d609dfbaf33d6889b2b7106d3ca345eacad44200913df5ba02bfd31d2ba9" [[package]] name = "astral-tokio-tar" -version = "0.5.2" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1abb2bfba199d9ec4759b797115ba6ae435bdd920ce99783bb53aeff57ba919b" +checksum = "0036af73142caf1291d4ec8ed667d3a1145bd55c8189517bd5aa07b3167ae1e1" dependencies = [ "filetime", "futures-core", @@ -4792,6 +4792,7 @@ dependencies = [ "pixi_consts", "pixi_core", "pixi_git", + "pixi_global", "pixi_manifest", "pixi_progress", "pixi_pty", @@ -4960,7 +4961,6 @@ dependencies = [ "dashmap", "deno_task_shell", "dialoguer", - "dirs", "dunce", "fake", "fancy_display", @@ -4973,7 +4973,6 @@ dependencies = [ "indexmap 2.10.0", "indicatif", "insta", - "is_executable", "itertools 0.14.0", "libc", "miette 7.6.0", @@ -4997,9 +4996,7 @@ dependencies = [ "pixi_record", "pixi_reporters", "pixi_spec", - "pixi_spec_containers", "pixi_test_utils", - "pixi_toml", "pixi_utils", "pixi_uv_conversions", "pypi_mapping", @@ -5008,27 +5005,23 @@ dependencies = [ "rattler_conda_types", "rattler_digest", "rattler_lock", - "rattler_menuinst", "rattler_networking", "rattler_repodata_gateway", "rattler_shell", "rattler_solve", "rattler_virtual_packages", "rayon", - "regex", "reqwest", "reqwest-middleware", "rlimit", "rstest", "serde", "serde_json", - "serde_with", "shlex", "tabwriter", "tempfile", "thiserror 2.0.15", "tokio", - "toml-span", "toml_edit 0.22.27", "tracing", "typed-path", @@ -5059,7 +5052,6 @@ dependencies = [ "uv-types", "uv-workspace", "xxhash-rust", - "zstd", ] [[package]] @@ -5116,6 +5108,63 @@ dependencies = [ "wax", ] +[[package]] +name = "pixi_global" +version = "0.1.0" +dependencies = [ + "ahash", + "console 0.15.11", + "dirs", + "dunce", + "fake", + "fancy_display", + "fs-err", + "futures", + "indexmap 2.10.0", + "indicatif", + "insta", + "is_executable", + "itertools 0.14.0", + "libc", + "miette 7.6.0", + "once_cell", + "pixi_build_discovery", + "pixi_build_frontend", + "pixi_command_dispatcher", + "pixi_config", + "pixi_consts", + "pixi_core", + "pixi_manifest", + "pixi_progress", + "pixi_reporters", + "pixi_spec", + "pixi_spec_containers", + "pixi_toml", + "pixi_utils", + "rattler", + "rattler_conda_types", + "rattler_lock", + "rattler_menuinst", + "rattler_repodata_gateway", + "rattler_shell", + "rattler_virtual_packages", + "regex", + "reqwest", + "reqwest-middleware", + "rstest", + "serde", + "serde_json", + "serde_with", + "tempfile", + "thiserror 2.0.15", + "tokio", + "toml-span", + "toml_edit 0.22.27", + "tracing", + "url", + "zstd", +] + [[package]] name = "pixi_manifest" version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml index 78c648bdcd..13dbc6bf2c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -186,6 +186,7 @@ pixi_core = { path = "crates/pixi_core" } pixi_default_versions = { path = "crates/pixi_default_versions" } pixi_git = { path = "crates/pixi_git" } pixi_glob = { path = "crates/pixi_glob" } +pixi_global = { path = "crates/pixi_global" } pixi_manifest = { path = "crates/pixi_manifest" } pixi_progress = { path = "crates/pixi_progress" } pixi_pypi_spec = { path = "crates/pixi_pypi_spec" } diff --git a/crates/pixi_cli/Cargo.toml b/crates/pixi_cli/Cargo.toml index 290c70ada9..f492c2bb5f 100644 --- a/crates/pixi_cli/Cargo.toml +++ b/crates/pixi_cli/Cargo.toml @@ -70,6 +70,7 @@ pixi_config = { workspace = true } pixi_consts = { workspace = true } pixi_core = { workspace = true } pixi_git = { workspace = true } +pixi_global = { workspace = true } pixi_manifest = { workspace = true, features = ["rattler_lock"] } pixi_progress = { workspace = true } pixi_pypi_spec = { workspace = true } diff --git a/crates/pixi_cli/src/global/add.rs b/crates/pixi_cli/src/global/add.rs index 57017258f2..a7ea52a1d4 100644 --- a/crates/pixi_cli/src/global/add.rs +++ b/crates/pixi_cli/src/global/add.rs @@ -3,8 +3,8 @@ use crate::global::revert_environment_after_error; use clap::Parser; use pixi_config::{Config, ConfigCli}; -use pixi_core::global::project::GlobalSpec; -use pixi_core::global::{EnvironmentName, Mapping, Project, StateChange, StateChanges}; +use pixi_global::project::GlobalSpec; +use pixi_global::{EnvironmentName, Mapping, Project, StateChange, StateChanges}; /// Adds dependencies to an environment /// diff --git a/crates/pixi_cli/src/global/edit.rs b/crates/pixi_cli/src/global/edit.rs index 0dced55683..c91fdd6e85 100644 --- a/crates/pixi_cli/src/global/edit.rs +++ b/crates/pixi_cli/src/global/edit.rs @@ -1,7 +1,7 @@ use clap::Parser; use fs_err as fs; use miette::IntoDiagnostic; -use pixi_core::global::Project; +use pixi_global::Project; /// Edit the global manifest file /// diff --git a/crates/pixi_cli/src/global/expose.rs b/crates/pixi_cli/src/global/expose.rs index 93c642e2bb..54e5c87f0a 100644 --- a/crates/pixi_cli/src/global/expose.rs +++ b/crates/pixi_cli/src/global/expose.rs @@ -2,9 +2,9 @@ use clap::Parser; use itertools::Itertools; use miette::Context; use pixi_config::{Config, ConfigCli}; +use pixi_global::{self, EnvironmentName, ExposedName, Mapping, StateChanges}; use crate::global::revert_environment_after_error; -use pixi_core::global::{self, EnvironmentName, ExposedName, Mapping, StateChanges}; /// Add exposed binaries from an environment to your global environment /// @@ -71,13 +71,13 @@ pub async fn execute(args: SubCommand) -> miette::Result<()> { pub async fn add(args: AddArgs) -> miette::Result<()> { let config = Config::with_cli_config(&args.config); - let project_original = global::Project::discover_or_create() + let project_original = pixi_global::Project::discover_or_create() .await? .with_cli_config(config.clone()); async fn apply_changes( args: &AddArgs, - project: &mut global::Project, + project: &mut pixi_global::Project, ) -> Result { let env_name = &args.environment; let mut state_changes = StateChanges::new_with_env(env_name.clone()); @@ -110,14 +110,14 @@ pub async fn add(args: AddArgs) -> miette::Result<()> { pub async fn remove(args: RemoveArgs) -> miette::Result<()> { let config = Config::with_cli_config(&args.config); - let project_original = global::Project::discover_or_create() + let project_original = pixi_global::Project::discover_or_create() .await? .with_cli_config(config.clone()); async fn apply_changes( exposed_name: &ExposedName, env_name: &EnvironmentName, - project: &mut global::Project, + project: &mut pixi_global::Project, ) -> Result { let mut state_changes = StateChanges::new_with_env(env_name.clone()); project diff --git a/crates/pixi_cli/src/global/global_specs.rs b/crates/pixi_cli/src/global/global_specs.rs index 9402c4443d..e3ce4e69ec 100644 --- a/crates/pixi_cli/src/global/global_specs.rs +++ b/crates/pixi_cli/src/global/global_specs.rs @@ -2,12 +2,13 @@ use std::path::Path; use clap::Parser; use miette::Diagnostic; +use url::Url; + use pixi_consts::consts; -use pixi_core::global::project::FromMatchSpecError; +use pixi_global::project::FromMatchSpecError; use pixi_spec::PixiSpec; use rattler_conda_types::{ChannelConfig, MatchSpec, ParseMatchSpecError, ParseStrictness}; use typed_path::Utf8NativePathBuf; -use url::Url; use crate::has_specs::HasSpecs; @@ -57,7 +58,7 @@ pub enum GlobalSpecsConversionError { AbsolutizePath(String), #[error("failed to infer package name")] #[diagnostic(transparent)] - PackageNameInference(#[from] pixi_core::global::project::InferPackageNameError), + PackageNameInference(#[from] pixi_global::project::InferPackageNameError), } impl GlobalSpecs { @@ -66,8 +67,8 @@ impl GlobalSpecs { &self, channel_config: &ChannelConfig, manifest_root: &Path, - project: &pixi_core::global::Project, - ) -> Result, GlobalSpecsConversionError> { + project: &pixi_global::Project, + ) -> Result, GlobalSpecsConversionError> { let git_or_path_spec = if let Some(git_url) = &self.git { let git_spec = pixi_spec::GitSpec { git: git_url.clone(), @@ -97,7 +98,7 @@ impl GlobalSpecs { if self.specs.is_empty() { // Infer the package name from the path/git spec let inferred_name = project.infer_package_name_from_spec(&pixi_spec).await?; - return Ok(vec![pixi_core::global::project::GlobalSpec::new( + return Ok(vec![pixi_global::project::GlobalSpec::new( inferred_name, pixi_spec, )]); @@ -109,16 +110,14 @@ impl GlobalSpecs { MatchSpec::from_str(spec_str, ParseStrictness::Lenient)? .name .ok_or(GlobalSpecsConversionError::NameRequired) - .map(|name| { - pixi_core::global::project::GlobalSpec::new(name, pixi_spec.clone()) - }) + .map(|name| pixi_global::project::GlobalSpec::new(name, pixi_spec.clone())) }) .collect() } else { self.specs .iter() .map(|spec_str| { - pixi_core::global::project::GlobalSpec::try_from_str(spec_str, channel_config) + pixi_global::project::GlobalSpec::try_from_str(spec_str, channel_config) .map_err(Box::new) .map_err(GlobalSpecsConversionError::FromMatchSpec) }) @@ -150,9 +149,7 @@ mod tests { // Create a dummy project - this test doesn't use path/git specs so project // won't be called - let project = pixi_core::global::Project::discover_or_create() - .await - .unwrap(); + let project = pixi_global::Project::discover_or_create().await.unwrap(); let global_specs = specs .to_global_specs(&channel_config, &manifest_root, &project) @@ -177,9 +174,7 @@ mod tests { // Create a dummy project - this test specifies a package name so inference // won't be needed - let project = pixi_core::global::Project::discover_or_create() - .await - .unwrap(); + let project = pixi_global::Project::discover_or_create().await.unwrap(); let global_specs = specs .to_global_specs(&channel_config, &manifest_root, &project) @@ -207,9 +202,7 @@ mod tests { let manifest_root = PathBuf::from("."); // Create a dummy project - let project = pixi_core::global::Project::discover_or_create() - .await - .unwrap(); + let project = pixi_global::Project::discover_or_create().await.unwrap(); let global_specs = specs .to_global_specs(&channel_config, &manifest_root, &project) diff --git a/crates/pixi_cli/src/global/install.rs b/crates/pixi_cli/src/global/install.rs index fab55bf764..8a42701745 100644 --- a/crates/pixi_cli/src/global/install.rs +++ b/crates/pixi_cli/src/global/install.rs @@ -10,7 +10,7 @@ use rattler_conda_types::{MatchSpec, NamedChannelOrUrl, Platform}; use crate::global::{global_specs::GlobalSpecs, revert_environment_after_error}; use pixi_config::{self, Config, ConfigCli}; -use pixi_core::global::{ +use pixi_global::{ self, EnvChanges, EnvState, EnvironmentName, Mapping, Project, StateChange, StateChanges, common::{NotChangedReason, contains_menuinst_document}, list::list_all_global_environments, @@ -78,7 +78,7 @@ pub struct Args { pub async fn execute(args: Args) -> miette::Result<()> { let config = Config::with_cli_config(&args.config); - let project_original = global::Project::discover_or_create() + let project_original = pixi_global::Project::discover_or_create() .await? .with_cli_config(config.clone()); diff --git a/crates/pixi_cli/src/global/list.rs b/crates/pixi_cli/src/global/list.rs index 75b5e43fe5..964e779052 100644 --- a/crates/pixi_cli/src/global/list.rs +++ b/crates/pixi_cli/src/global/list.rs @@ -1,8 +1,8 @@ use clap::Parser; use fancy_display::FancyDisplay; use pixi_config::{Config, ConfigCli}; -use pixi_core::global::list::{list_all_global_environments, list_specific_global_environment}; -use pixi_core::global::{EnvironmentName, Project}; +use pixi_global::list::{list_all_global_environments, list_specific_global_environment}; +use pixi_global::{EnvironmentName, Project}; use std::str::FromStr; /// Lists global environments with their dependencies and exposed commands. Can also display all packages within a specific global environment when using the --environment flag. diff --git a/crates/pixi_cli/src/global/mod.rs b/crates/pixi_cli/src/global/mod.rs index 956868f0a8..d7e3d8c890 100644 --- a/crates/pixi_cli/src/global/mod.rs +++ b/crates/pixi_cli/src/global/mod.rs @@ -1,6 +1,6 @@ use clap::Parser; -use pixi_core::global::{self, EnvironmentName}; +use pixi_global::EnvironmentName; mod add; mod edit; @@ -74,7 +74,7 @@ pub async fn execute(cmd: Args) -> miette::Result<()> { /// Reverts the changes made to the project for a specific environment after an error occurred. async fn revert_environment_after_error( env_name: &EnvironmentName, - project_to_revert_to: &global::Project, + project_to_revert_to: &pixi_global::Project, ) -> miette::Result<()> { if project_to_revert_to.environment(env_name).is_some() { // We don't want to report on changes done by the reversion diff --git a/crates/pixi_cli/src/global/remove.rs b/crates/pixi_cli/src/global/remove.rs index 0d1498bb86..d6b9a82770 100644 --- a/crates/pixi_cli/src/global/remove.rs +++ b/crates/pixi_cli/src/global/remove.rs @@ -2,7 +2,7 @@ use clap::Parser; use itertools::Itertools; use miette::Context; use pixi_config::{Config, ConfigCli}; -use pixi_core::global::{EnvironmentName, ExposedName, Project, StateChanges}; +use pixi_global::{EnvironmentName, ExposedName, Project, StateChanges}; use rattler_conda_types::MatchSpec; use std::str::FromStr; diff --git a/crates/pixi_cli/src/global/shortcut.rs b/crates/pixi_cli/src/global/shortcut.rs index 623d0643e2..854b2d5055 100644 --- a/crates/pixi_cli/src/global/shortcut.rs +++ b/crates/pixi_cli/src/global/shortcut.rs @@ -3,8 +3,8 @@ use clap::Parser; use fancy_display::FancyDisplay; use miette::Context; use pixi_config::{Config, ConfigCli}; -use pixi_core::global::Project; -use pixi_core::global::{EnvironmentName, StateChanges}; +use pixi_global::Project; +use pixi_global::{EnvironmentName, StateChanges}; use rattler_conda_types::PackageName; use std::collections::HashMap; diff --git a/crates/pixi_cli/src/global/sync.rs b/crates/pixi_cli/src/global/sync.rs index 88bcd62e2f..5831935bbe 100644 --- a/crates/pixi_cli/src/global/sync.rs +++ b/crates/pixi_cli/src/global/sync.rs @@ -1,7 +1,6 @@ use clap::Parser; use fancy_display::FancyDisplay; use pixi_config::{Config, ConfigCli}; -use pixi_core::global; /// Sync global manifest with installed environments #[derive(Parser, Debug)] @@ -13,7 +12,7 @@ pub struct Args { /// Sync global manifest with installed environments pub async fn execute(args: Args) -> miette::Result<()> { let config = Config::with_cli_config(&args.config); - let project = global::Project::discover_or_create() + let project = pixi_global::Project::discover_or_create() .await? .with_cli_config(config.clone()); @@ -25,7 +24,7 @@ pub async fn execute(args: Args) -> miette::Result<()> { #[cfg(unix)] { // Prune broken completions - let completions_dir = pixi_core::global::completions::CompletionsDir::from_env().await?; + let completions_dir = pixi_global::completions::CompletionsDir::from_env().await?; completions_dir.prune_old_completions()?; } diff --git a/crates/pixi_cli/src/global/uninstall.rs b/crates/pixi_cli/src/global/uninstall.rs index ac5646c136..79c07b1973 100644 --- a/crates/pixi_cli/src/global/uninstall.rs +++ b/crates/pixi_cli/src/global/uninstall.rs @@ -3,8 +3,8 @@ use clap::Parser; use fancy_display::FancyDisplay; use miette::Context; use pixi_config::{Config, ConfigCli}; -use pixi_core::global::{self, StateChanges}; -use pixi_core::global::{EnvironmentName, Project}; +use pixi_global::StateChanges; +use pixi_global::{EnvironmentName, Project}; /// Uninstalls environments from the global environment. /// @@ -22,7 +22,7 @@ pub struct Args { pub async fn execute(args: Args) -> miette::Result<()> { let config = Config::with_cli_config(&args.config); - let project_original = global::Project::discover_or_create() + let project_original = pixi_global::Project::discover_or_create() .await? .with_cli_config(config.clone()); diff --git a/crates/pixi_cli/src/global/update.rs b/crates/pixi_cli/src/global/update.rs index ccfd30c6e8..5f3d85fcbb 100644 --- a/crates/pixi_cli/src/global/update.rs +++ b/crates/pixi_cli/src/global/update.rs @@ -2,10 +2,10 @@ use crate::global::revert_environment_after_error; use clap::Parser; use fancy_display::FancyDisplay; use pixi_config::{Config, ConfigCli}; -use pixi_core::global::common::check_all_exposed; -use pixi_core::global::project::ExposedType; -use pixi_core::global::{self, StateChanges}; -use pixi_core::global::{EnvironmentName, Project}; +use pixi_global::StateChanges; +use pixi_global::common::check_all_exposed; +use pixi_global::project::ExposedType; +use pixi_global::{EnvironmentName, Project}; /// Updates environments in the global environment. #[derive(Parser, Debug, Clone)] @@ -19,7 +19,7 @@ pub struct Args { pub async fn execute(args: Args) -> miette::Result<()> { let config = Config::with_cli_config(&args.config); - let project_original = global::Project::discover_or_create() + let project_original = pixi_global::Project::discover_or_create() .await? .with_cli_config(config.clone()); @@ -33,7 +33,7 @@ pub async fn execute(args: Args) -> miette::Result<()> { let environment_update = project.install_environment(env_name).await?; state_changes.insert_change( env_name, - global::StateChange::UpdatedEnvironment(environment_update), + pixi_global::StateChange::UpdatedEnvironment(environment_update), ); false } else { @@ -62,7 +62,7 @@ pub async fn execute(args: Args) -> miette::Result<()> { state_changes.insert_change( env_name, - global::StateChange::UpdatedEnvironment(environment_update), + pixi_global::StateChange::UpdatedEnvironment(environment_update), ); } // Sync executables exposed names with the manifest @@ -88,7 +88,7 @@ pub async fn execute(args: Args) -> miette::Result<()> { state_changes.report(); #[cfg(unix)] { - let completions_dir = global::completions::CompletionsDir::from_env().await?; + let completions_dir = pixi_global::completions::CompletionsDir::from_env().await?; completions_dir.prune_old_completions()?; } project_original.environments().keys().cloned().collect() diff --git a/crates/pixi_cli/src/info.rs b/crates/pixi_cli/src/info.rs index cf80351fbd..0f8224ec00 100644 --- a/crates/pixi_cli/src/info.rs +++ b/crates/pixi_cli/src/info.rs @@ -7,11 +7,8 @@ use itertools::Itertools; use miette::IntoDiagnostic; use pixi_config; use pixi_consts::consts; -use pixi_core::{ - WorkspaceLocator, global, - global::{BinDir, EnvRoot}, - task::TaskName, -}; +use pixi_core::{WorkspaceLocator, task::TaskName}; +use pixi_global::{BinDir, EnvRoot}; use pixi_manifest::{EnvironmentName, FeatureName, SystemRequirements}; use pixi_manifest::{FeaturesExt, HasFeaturesIter}; use pixi_progress::await_in_progress; @@ -455,7 +452,7 @@ pub async fn execute(args: Args) -> miette::Result<()> { let global_info = Some(GlobalInfo { bin_dir: BinDir::from_env().await?.path().to_path_buf(), env_dir: EnvRoot::from_env().await?.path().to_path_buf(), - manifest: global::Project::manifest_dir()?.join(consts::GLOBAL_MANIFEST_DEFAULT_NAME), + manifest: pixi_global::Project::manifest_dir()?.join(consts::GLOBAL_MANIFEST_DEFAULT_NAME), }); let virtual_packages = VirtualPackage::detect(&VirtualPackageOverrides::from_env()) diff --git a/crates/pixi_core/Cargo.toml b/crates/pixi_core/Cargo.toml index b951313e79..2ce4fcf5a0 100644 --- a/crates/pixi_core/Cargo.toml +++ b/crates/pixi_core/Cargo.toml @@ -24,7 +24,6 @@ csv = { workspace = true } dashmap = { workspace = true } deno_task_shell = { workspace = true } dialoguer = { workspace = true } -dirs = { workspace = true } dunce = { workspace = true } fancy_display = { workspace = true } fs-err = { workspace = true } @@ -34,7 +33,6 @@ human_bytes = { workspace = true } humantime = { workspace = true } indexmap = { workspace = true } indicatif = { workspace = true } -is_executable = { workspace = true } itertools = { workspace = true } miette = { workspace = true } once_cell = { workspace = true } @@ -51,14 +49,12 @@ pixi_consts = { workspace = true } pixi_default_versions = { workspace = true } pixi_git = { workspace = true } pixi_glob = { workspace = true } -pixi_manifest = { workspace = true } +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 } pixi_utils = { workspace = true, default-features = false } pixi_uv_conversions = { workspace = true } pypi_mapping = { workspace = true } @@ -67,27 +63,23 @@ rattler = { workspace = true } rattler_conda_types = { workspace = true } rattler_digest = { workspace = true } rattler_lock = { workspace = true } -rattler_menuinst = { workspace = true } rattler_networking = { workspace = true, default-features = false } rattler_repodata_gateway = { workspace = true } rattler_shell = { workspace = true } rattler_solve = { workspace = true } rattler_virtual_packages = { workspace = true } rayon = { workspace = true } -regex = { workspace = true } reqwest = { workspace = true } reqwest-middleware = { workspace = true } rlimit = { workspace = true } rstest = { workspace = true } serde = { workspace = true } serde_json = { workspace = true } -serde_with = { workspace = true } shlex = { workspace = true } tabwriter = { workspace = true } tempfile = { workspace = true } thiserror = { workspace = true } tokio = { workspace = true } -toml-span = { workspace = true } toml_edit = { workspace = true } tracing = { workspace = true } typed-path = { workspace = true } @@ -118,7 +110,6 @@ uv-resolver = { workspace = true } uv-types = { workspace = true } uv-workspace = { workspace = true } xxhash-rust = { workspace = true } -zstd = { workspace = true } [target.'cfg(unix)'.dependencies] libc = { workspace = true } diff --git a/crates/pixi_core/src/lib.rs b/crates/pixi_core/src/lib.rs index d42b19150d..c9d470cfc6 100644 --- a/crates/pixi_core/src/lib.rs +++ b/crates/pixi_core/src/lib.rs @@ -3,11 +3,10 @@ pub mod activation; pub mod diff; pub mod environment; -pub mod global; mod install_pypi; pub mod lock_file; pub mod prompt; -pub(crate) mod repodata; +pub mod repodata; pub mod task; pub mod workspace; diff --git a/crates/pixi_core/src/repodata.rs b/crates/pixi_core/src/repodata.rs index 13ca54cabc..479939990e 100644 --- a/crates/pixi_core/src/repodata.rs +++ b/crates/pixi_core/src/repodata.rs @@ -1,6 +1,6 @@ use rattler_repodata_gateway::Gateway; -pub(crate) trait Repodata { +pub trait Repodata { /// Returns the [`Gateway`] used by this project. fn repodata_gateway(&self) -> miette::Result<&Gateway>; } diff --git a/crates/pixi_global/Cargo.toml b/crates/pixi_global/Cargo.toml new file mode 100644 index 0000000000..105ae528b4 --- /dev/null +++ b/crates/pixi_global/Cargo.toml @@ -0,0 +1,69 @@ +[package] +authors.workspace = true +edition.workspace = true +homepage.workspace = true +license.workspace = true +name = "pixi_global" +readme.workspace = true +repository.workspace = true +version = "0.1.0" + +[features] +slow_integration_tests = [] + +[dependencies] +ahash = { workspace = true } +console = { workspace = true } +dirs = { workspace = true } +dunce = { workspace = true } +fancy_display = { workspace = true } +fs-err = { workspace = true } +futures = { workspace = true } +indexmap = { workspace = true } +indicatif = { workspace = true } +is_executable = { workspace = true } +itertools = { workspace = true } +miette = { workspace = true } +once_cell = { workspace = true } +pixi_build_discovery = { workspace = true } +pixi_build_frontend = { workspace = true } +pixi_command_dispatcher = { workspace = true } +pixi_config = { workspace = true } +pixi_consts = { workspace = true } +pixi_core = { workspace = true } +pixi_manifest = { workspace = true } +pixi_progress = { workspace = true } +pixi_reporters = { workspace = true } +pixi_spec = { workspace = true } +pixi_spec_containers = { workspace = true } +pixi_toml = { workspace = true } +pixi_utils = { workspace = true, default-features = false } +rattler = { workspace = true } +rattler_conda_types = { workspace = true } +rattler_lock = { workspace = true } +rattler_menuinst = { workspace = true } +rattler_repodata_gateway = { workspace = true } +rattler_shell = { workspace = true } +rattler_virtual_packages = { workspace = true } +regex = { workspace = true } +reqwest = { workspace = true } +reqwest-middleware = { workspace = true } +rstest = { workspace = true } +serde = { workspace = true } +serde_json = { workspace = true } +serde_with = { workspace = true } +tempfile = { workspace = true } +thiserror = { workspace = true } +tokio = { workspace = true } +toml-span = { workspace = true } +toml_edit = { workspace = true } +tracing = { workspace = true } +url = { workspace = true } +zstd = { workspace = true } + +[target.'cfg(unix)'.dependencies] +libc = { workspace = true } + +[dev-dependencies] +fake = "4.0.0" +insta = { workspace = true, features = ["yaml", "glob", "filters"] } diff --git a/crates/pixi_core/src/global/common.rs b/crates/pixi_global/src/common.rs similarity index 99% rename from crates/pixi_core/src/global/common.rs rename to crates/pixi_global/src/common.rs index 93ba8e04f4..c32e96f5bd 100644 --- a/crates/pixi_core/src/global/common.rs +++ b/crates/pixi_global/src/common.rs @@ -179,7 +179,7 @@ pub(crate) fn is_binary(file_path: impl AsRef) -> miette::Result { } /// Finds the package record from the `conda-meta` directory. -pub(crate) async fn find_package_records(conda_meta: &Path) -> miette::Result> { +pub async fn find_package_records(conda_meta: &Path) -> miette::Result> { let read_dir = tokio_fs::read_dir(conda_meta).await; let mut records = Vec::new(); @@ -1094,7 +1094,7 @@ pub(crate) fn get_install_changes( #[cfg(test)] mod tests { - use crate::global::trampoline::Configuration; + use crate::trampoline::Configuration; use super::*; use rstest::rstest; @@ -1125,9 +1125,10 @@ mod tests { #[tokio::test] async fn test_find_package_record() { // Get meta file from test data folder relative to the current file - let dummy_conda_meta_path = PathBuf::from(env!("CARGO_MANIFEST_DIR")) + let dummy_conda_meta_path = PathBuf::from(env!("CARGO_WORKSPACE_DIR")) + .join("crates") + .join("pixi_global") .join("src") - .join("global") .join("test_data") .join("conda-meta"); // Find the package record diff --git a/crates/pixi_core/src/global/completions.rs b/crates/pixi_global/src/completions.rs similarity index 100% rename from crates/pixi_core/src/global/completions.rs rename to crates/pixi_global/src/completions.rs diff --git a/crates/pixi_core/src/global/install.rs b/crates/pixi_global/src/install.rs similarity index 99% rename from crates/pixi_core/src/global/install.rs rename to crates/pixi_global/src/install.rs index 99f7a00902..45ff54b3dd 100644 --- a/crates/pixi_core/src/global/install.rs +++ b/crates/pixi_global/src/install.rs @@ -1,5 +1,5 @@ use super::{EnvDir, EnvironmentName, ExposedName, StateChanges}; -use crate::global::{ +use crate::{ BinDir, StateChange, trampoline::{Configuration, Trampoline}, }; @@ -358,7 +358,7 @@ mod tests { use rattler_lock::LockFile; use rstest::{fixture, rstest}; - use crate::global::EnvRoot; + use crate::EnvRoot; use super::*; @@ -539,7 +539,7 @@ mod tests { #[cfg(windows)] #[tokio::test] async fn test_extract_executable_from_script_windows() { - use crate::global::trampoline::GlobalExecutable; + use crate::trampoline::GlobalExecutable; use std::path::Path; let script_without_quote = r#" @SET "PATH=C:\Users\USER\.pixi/envs\hyperfine\bin:%PATH%" @@ -577,7 +577,7 @@ mod tests { async fn test_extract_executable_from_script_unix() { use std::path::Path; - use crate::global::trampoline::GlobalExecutable; + use crate::trampoline::GlobalExecutable; let script = r#"#!/bin/sh export PATH="/home/user/.pixi/envs/nushell/bin:${PATH}" diff --git a/crates/pixi_core/src/global/mod.rs b/crates/pixi_global/src/lib.rs similarity index 100% rename from crates/pixi_core/src/global/mod.rs rename to crates/pixi_global/src/lib.rs diff --git a/crates/pixi_core/src/global/list.rs b/crates/pixi_global/src/list.rs similarity index 98% rename from crates/pixi_core/src/global/list.rs rename to crates/pixi_global/src/list.rs index 40a97fe1f5..79a8b199cd 100644 --- a/crates/pixi_core/src/global/list.rs +++ b/crates/pixi_global/src/list.rs @@ -1,18 +1,14 @@ use fancy_display::FancyDisplay; use indexmap::{IndexMap, IndexSet}; use itertools::Itertools; +use miette::{IntoDiagnostic, miette}; use pixi_consts::consts; +use pixi_core::environment::list::{PackageToOutput, print_package_table}; use pixi_spec::PixiSpec; use rattler_conda_types::{PackageName, PrefixRecord, Version}; -use miette::{IntoDiagnostic, miette}; - -use crate::{ - environment::list::{PackageToOutput, print_package_table}, - global::common::find_package_records, -}; - use super::{EnvChanges, EnvState, EnvironmentName, Mapping, Project, project::ParsedEnvironment}; +use crate::common::find_package_records; /// Creating the ASCII art representation of a section. pub fn format_asciiart_section(label: &str, content: String, last: bool, more: bool) -> String { diff --git a/crates/pixi_core/src/global/project/environment.rs b/crates/pixi_global/src/project/environment.rs similarity index 96% rename from crates/pixi_core/src/global/project/environment.rs rename to crates/pixi_global/src/project/environment.rs index 595f666766..d85c533bc0 100644 --- a/crates/pixi_core/src/global/project/environment.rs +++ b/crates/pixi_global/src/project/environment.rs @@ -1,4 +1,4 @@ -use crate::global::install::local_environment_matches_spec; +use crate::install::local_environment_matches_spec; use console::StyledObject; use fancy_display::FancyDisplay; use indexmap::IndexSet; @@ -103,7 +103,7 @@ pub(crate) async fn environment_specs_in_sync( mod tests { use super::*; - use crate::global::{EnvDir, EnvRoot}; + use crate::{EnvDir, EnvRoot}; use fs_err::tokio as tokio_fs; use pixi_utils::prefix::Prefix; use rattler_conda_types::ParseStrictness; @@ -153,8 +153,8 @@ mod tests { let target_dir = PathBuf::from(env_dir.path()).join("conda-meta"); tokio_fs::create_dir_all(&target_dir).await.unwrap(); let test_data_target = target_dir.join(file_name); - let test_data_source = PathBuf::from(env!("CARGO_MANIFEST_DIR")) - .join("src/global/test_data/conda-meta") + let test_data_source = PathBuf::from(env!("CARGO_WORKSPACE_DIR")) + .join("crates/pixi_global/src/test_data/conda-meta") .join(file_name); tokio_fs::copy(test_data_source, test_data_target) .await diff --git a/crates/pixi_core/src/global/project/global_spec.rs b/crates/pixi_global/src/project/global_spec.rs similarity index 100% rename from crates/pixi_core/src/global/project/global_spec.rs rename to crates/pixi_global/src/project/global_spec.rs diff --git a/crates/pixi_core/src/global/project/manifest.rs b/crates/pixi_global/src/project/manifest.rs similarity index 99% rename from crates/pixi_core/src/global/project/manifest.rs rename to crates/pixi_global/src/project/manifest.rs index 985a6a03de..6a2c8dc285 100644 --- a/crates/pixi_core/src/global/project/manifest.rs +++ b/crates/pixi_global/src/project/manifest.rs @@ -22,7 +22,7 @@ use super::{ global_spec::GlobalSpec, parsed_manifest::{ManifestParsingError, ManifestVersion, ParsedManifest}, }; -use crate::global::project::ParsedEnvironment; +use crate::project::ParsedEnvironment; /// Handles the global project's manifest file. /// This struct is responsible for reading, parsing, editing, and saving the diff --git a/crates/pixi_core/src/global/project/mod.rs b/crates/pixi_global/src/project/mod.rs similarity index 99% rename from crates/pixi_core/src/global/project/mod.rs rename to crates/pixi_global/src/project/mod.rs index bbc5ef78cd..fabec55c99 100644 --- a/crates/pixi_core/src/global/project/mod.rs +++ b/crates/pixi_global/src/project/mod.rs @@ -27,6 +27,7 @@ use pixi_command_dispatcher::{ }; use pixi_config::{Config, RunPostLinkScripts, default_channel_config, pixi_home}; use pixi_consts::consts::{self}; +use pixi_core::repodata::Repodata; use pixi_manifest::PrioritizedChannel; use pixi_progress::global_multi_progress; use pixi_reporters::TopLevelProgress; @@ -58,16 +59,13 @@ use super::{ trampoline::{self, GlobalExecutable}, }; use crate::{ - global::{ - EnvDir, - common::{ - channel_url_to_prioritized_channel, expose_scripts_sync_status, find_package_records, - }, - find_executables, find_executables_for_many_records, - install::{create_executable_trampolines, script_exec_mapping}, - project::environment::environment_specs_in_sync, + EnvDir, + common::{ + channel_url_to_prioritized_channel, expose_scripts_sync_status, find_package_records, }, - repodata::Repodata, + find_executables, find_executables_for_many_records, + install::{create_executable_trampolines, script_exec_mapping}, + project::environment::environment_specs_in_sync, }; mod environment; @@ -1263,7 +1261,7 @@ impl Project { .map(|exec| exec.name) .collect(); - let completions_dir = crate::global::completions::CompletionsDir::from_env().await?; + let completions_dir = crate::completions::CompletionsDir::from_env().await?; let (completions_to_remove, completions_to_add) = super::completions::completions_sync_status( environment.exposed.clone(), @@ -1446,7 +1444,7 @@ mod tests { use url::Url; use super::*; - use crate::global::trampoline::{Configuration, Trampoline}; + use crate::trampoline::{Configuration, Trampoline}; const SIMPLE_MANIFEST: &str = r#" [envs.python] diff --git a/crates/pixi_core/src/global/project/parsed_manifest.rs b/crates/pixi_global/src/project/parsed_manifest.rs similarity index 99% rename from crates/pixi_core/src/global/project/parsed_manifest.rs rename to crates/pixi_global/src/project/parsed_manifest.rs index 3d910402eb..e2739a8475 100644 --- a/crates/pixi_core/src/global/project/parsed_manifest.rs +++ b/crates/pixi_global/src/project/parsed_manifest.rs @@ -16,7 +16,7 @@ use thiserror::Error; use toml_span::{DeserError, Deserialize, Value, de_helpers::TableHelper}; use super::{ExposedData, environment::EnvironmentName}; -use crate::global::{Mapping, project::manifest::TomlMapping}; +use crate::{Mapping, project::manifest::TomlMapping}; pub const GLOBAL_MANIFEST_VERSION: i64 = 1; diff --git a/crates/pixi_core/src/global/project/snapshots/pixi_core__global__project__manifest__tests__add_dependency.snap b/crates/pixi_global/src/project/snapshots/pixi_global__project__manifest__tests__add_dependency.snap similarity index 100% rename from crates/pixi_core/src/global/project/snapshots/pixi_core__global__project__manifest__tests__add_dependency.snap rename to crates/pixi_global/src/project/snapshots/pixi_global__project__manifest__tests__add_dependency.snap diff --git a/crates/pixi_core/src/global/project/snapshots/pixi_core__global__project__manifest__tests__remove_dependency.snap b/crates/pixi_global/src/project/snapshots/pixi_global__project__manifest__tests__remove_dependency.snap similarity index 100% rename from crates/pixi_core/src/global/project/snapshots/pixi_core__global__project__manifest__tests__remove_dependency.snap rename to crates/pixi_global/src/project/snapshots/pixi_global__project__manifest__tests__remove_dependency.snap diff --git a/crates/pixi_core/src/global/project/snapshots/pixi_core__global__project__parsed_manifest__tests__duplicate_dependency.snap b/crates/pixi_global/src/project/snapshots/pixi_global__project__parsed_manifest__tests__duplicate_dependency.snap similarity index 100% rename from crates/pixi_core/src/global/project/snapshots/pixi_core__global__project__parsed_manifest__tests__duplicate_dependency.snap rename to crates/pixi_global/src/project/snapshots/pixi_global__project__parsed_manifest__tests__duplicate_dependency.snap diff --git a/crates/pixi_core/src/global/project/snapshots/pixi_core__global__project__parsed_manifest__tests__duplicate_exposed.snap b/crates/pixi_global/src/project/snapshots/pixi_global__project__parsed_manifest__tests__duplicate_exposed.snap similarity index 100% rename from crates/pixi_core/src/global/project/snapshots/pixi_core__global__project__parsed_manifest__tests__duplicate_exposed.snap rename to crates/pixi_global/src/project/snapshots/pixi_global__project__parsed_manifest__tests__duplicate_exposed.snap diff --git a/crates/pixi_core/src/global/project/snapshots/pixi_core__global__project__parsed_manifest__tests__expose_pixi.snap b/crates/pixi_global/src/project/snapshots/pixi_global__project__parsed_manifest__tests__expose_pixi.snap similarity index 100% rename from crates/pixi_core/src/global/project/snapshots/pixi_core__global__project__parsed_manifest__tests__expose_pixi.snap rename to crates/pixi_global/src/project/snapshots/pixi_global__project__parsed_manifest__tests__expose_pixi.snap diff --git a/crates/pixi_core/src/global/project/snapshots/pixi_core__global__project__parsed_manifest__tests__invalid_key.snap b/crates/pixi_global/src/project/snapshots/pixi_global__project__parsed_manifest__tests__invalid_key.snap similarity index 100% rename from crates/pixi_core/src/global/project/snapshots/pixi_core__global__project__parsed_manifest__tests__invalid_key.snap rename to crates/pixi_global/src/project/snapshots/pixi_global__project__parsed_manifest__tests__invalid_key.snap diff --git a/crates/pixi_core/src/global/test_data/conda-meta/_r-mutex-1.0.1-anacondar_1.json b/crates/pixi_global/src/test_data/conda-meta/_r-mutex-1.0.1-anacondar_1.json similarity index 100% rename from crates/pixi_core/src/global/test_data/conda-meta/_r-mutex-1.0.1-anacondar_1.json rename to crates/pixi_global/src/test_data/conda-meta/_r-mutex-1.0.1-anacondar_1.json diff --git a/crates/pixi_core/src/global/test_data/conda-meta/non_conda_meta_data_file b/crates/pixi_global/src/test_data/conda-meta/non_conda_meta_data_file similarity index 100% rename from crates/pixi_core/src/global/test_data/conda-meta/non_conda_meta_data_file rename to crates/pixi_global/src/test_data/conda-meta/non_conda_meta_data_file diff --git a/crates/pixi_core/src/global/test_data/conda-meta/python-3.12.3-hab00c5b_0_cpython.json b/crates/pixi_global/src/test_data/conda-meta/python-3.12.3-hab00c5b_0_cpython.json similarity index 100% rename from crates/pixi_core/src/global/test_data/conda-meta/python-3.12.3-hab00c5b_0_cpython.json rename to crates/pixi_global/src/test_data/conda-meta/python-3.12.3-hab00c5b_0_cpython.json diff --git a/crates/pixi_core/src/global/test_data/lockfiles/ripgrep.lock b/crates/pixi_global/src/test_data/lockfiles/ripgrep.lock similarity index 100% rename from crates/pixi_core/src/global/test_data/lockfiles/ripgrep.lock rename to crates/pixi_global/src/test_data/lockfiles/ripgrep.lock diff --git a/crates/pixi_core/src/global/test_data/lockfiles/ripgrep_bat.lock b/crates/pixi_global/src/test_data/lockfiles/ripgrep_bat.lock similarity index 100% rename from crates/pixi_core/src/global/test_data/lockfiles/ripgrep_bat.lock rename to crates/pixi_global/src/test_data/lockfiles/ripgrep_bat.lock diff --git a/crates/pixi_core/src/global/trampoline.rs b/crates/pixi_global/src/trampoline.rs similarity index 94% rename from crates/pixi_core/src/global/trampoline.rs rename to crates/pixi_global/src/trampoline.rs index f56a6cd138..ea82ff20e7 100644 --- a/crates/pixi_core/src/global/trampoline.rs +++ b/crates/pixi_global/src/trampoline.rs @@ -36,53 +36,49 @@ use super::ExposedName; #[cfg(target_arch = "aarch64")] #[cfg(target_os = "macos")] const TRAMPOLINE_BIN: &[u8] = - include_bytes!("../../../../trampoline/binaries/pixi-trampoline-aarch64-apple-darwin.zst"); + include_bytes!("../../../trampoline/binaries/pixi-trampoline-aarch64-apple-darwin.zst"); #[cfg(target_arch = "aarch64")] #[cfg(target_os = "windows")] -const TRAMPOLINE_BIN: &[u8] = include_bytes!( - "../../../../trampoline/binaries/pixi-trampoline-aarch64-pc-windows-msvc.exe.zst" -); +const TRAMPOLINE_BIN: &[u8] = + include_bytes!("../../../trampoline/binaries/pixi-trampoline-aarch64-pc-windows-msvc.exe.zst"); #[cfg(target_arch = "aarch64")] #[cfg(target_os = "linux")] -const TRAMPOLINE_BIN: &[u8] = include_bytes!( - "../../../../trampoline/binaries/pixi-trampoline-aarch64-unknown-linux-musl.zst" -); +const TRAMPOLINE_BIN: &[u8] = + include_bytes!("../../../trampoline/binaries/pixi-trampoline-aarch64-unknown-linux-musl.zst"); #[cfg(target_arch = "x86_64")] #[cfg(target_os = "macos")] const TRAMPOLINE_BIN: &[u8] = - include_bytes!("../../../../trampoline/binaries/pixi-trampoline-x86_64-apple-darwin.zst"); + include_bytes!("../../../trampoline/binaries/pixi-trampoline-x86_64-apple-darwin.zst"); #[cfg(target_arch = "x86_64")] #[cfg(target_os = "windows")] -const TRAMPOLINE_BIN: &[u8] = include_bytes!( - "../../../../trampoline/binaries/pixi-trampoline-x86_64-pc-windows-msvc.exe.zst" -); +const TRAMPOLINE_BIN: &[u8] = + include_bytes!("../../../trampoline/binaries/pixi-trampoline-x86_64-pc-windows-msvc.exe.zst"); #[cfg(target_arch = "powerpc64")] #[cfg(target_endian = "little")] #[cfg(target_os = "linux")] const TRAMPOLINE_BIN: &[u8] = include_bytes!( - "../../../../trampoline/binaries/pixi-trampoline-powerpc64le-unknown-linux-gnu.zst" + "../../../trampoline/binaries/pixi-trampoline-powerpc64le-unknown-linux-gnu.zst" ); #[cfg(target_arch = "riscv64")] #[cfg(target_os = "linux")] -const TRAMPOLINE_BIN: &[u8] = include_bytes!( - "../../../../trampoline/binaries/pixi-trampoline-riscv64gc-unknown-linux-gnu.zst" -); +const TRAMPOLINE_BIN: &[u8] = + include_bytes!("../../../trampoline/binaries/pixi-trampoline-riscv64gc-unknown-linux-gnu.zst"); #[cfg(target_arch = "x86_64")] #[cfg(target_os = "linux")] const TRAMPOLINE_BIN: &[u8] = - include_bytes!("../../../../trampoline/binaries/pixi-trampoline-x86_64-unknown-linux-musl.zst"); + include_bytes!("../../../trampoline/binaries/pixi-trampoline-x86_64-unknown-linux-musl.zst"); #[cfg(target_arch = "loongarch64")] #[cfg(target_os = "linux")] const TRAMPOLINE_BIN: &[u8] = include_bytes!( - "../../../../trampoline/binaries/pixi-trampoline-loongarch64-unknown-linux-gnu.zst" + "../../../trampoline/binaries/pixi-trampoline-loongarch64-unknown-linux-gnu.zst" ); // trampoline configuration folder name