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
221 changes: 124 additions & 97 deletions Cargo.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ 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_task = { path = "crates/pixi_task" }
pixi_test_utils = { path = "crates/pixi_test_utils" }
pixi_toml = { path = "crates/pixi_toml" }
pixi_utils = { path = "crates/pixi_utils", default-features = false }
Expand Down
1 change: 1 addition & 0 deletions crates/pixi_cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ pixi_pypi_spec = { workspace = true }
pixi_record = { workspace = true }
pixi_reporters = { workspace = true }
pixi_spec = { workspace = true }
pixi_task = { workspace = true }
pixi_utils = { workspace = true, default-features = false }
pixi_uv_conversions = { workspace = true }
pypi_mapping = { workspace = true }
Expand Down
3 changes: 2 additions & 1 deletion crates/pixi_cli/src/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ use itertools::Itertools;
use miette::IntoDiagnostic;
use pixi_config;
use pixi_consts::consts;
use pixi_core::{WorkspaceLocator, task::TaskName};
use pixi_core::WorkspaceLocator;
use pixi_global::{BinDir, EnvRoot};
use pixi_manifest::{EnvironmentName, FeatureName, SystemRequirements};
use pixi_manifest::{FeaturesExt, HasFeaturesIter};
use pixi_progress::await_in_progress;
use pixi_task::TaskName;
use rattler_conda_types::{GenericVirtualPackage, Platform};
use rattler_networking::authentication_storage;
use rattler_virtual_packages::{VirtualPackage, VirtualPackageOverrides};
Expand Down
19 changes: 9 additions & 10 deletions crates/pixi_cli/src/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,21 @@ use fancy_display::FancyDisplay;
use itertools::Itertools;
use miette::{Diagnostic, IntoDiagnostic};
use pixi_config::{ConfigCli, ConfigCliActivation};
use pixi_manifest::{FeaturesExt, TaskName};
use rattler_conda_types::Platform;
use thiserror::Error;
use tokio_util::sync::CancellationToken;
use tracing::Level;

use pixi_core::{
Workspace, WorkspaceLocator,
environment::sanity_check_workspace,
lock_file::{ReinstallPackages, UpdateLockFileOptions, UpdateMode},
task::{
AmbiguousTask, CanSkip, ExecutableTask, FailedToParseShellScript, InvalidWorkingDirectory,
SearchEnvironments, TaskAndEnvironment, TaskGraph, get_task_env,
},
workspace::{Environment, errors::UnsupportedPlatformError},
};
use pixi_manifest::{FeaturesExt, TaskName};
use pixi_task::{
AmbiguousTask, CanSkip, ExecutableTask, FailedToParseShellScript, InvalidWorkingDirectory,
SearchEnvironments, TaskAndEnvironment, TaskGraph, get_task_env,
};
use rattler_conda_types::Platform;
use thiserror::Error;
use tokio_util::sync::CancellationToken;
use tracing::Level;

use crate::cli_config::{LockAndInstallConfig, WorkspaceConfig};

Expand Down
5 changes: 0 additions & 5 deletions crates/pixi_core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,13 @@ slow_integration_tests = []

[dependencies]
ahash = { workspace = true }
anyhow = { workspace = true }
assert_matches = { workspace = true }
async-once-cell = { workspace = true }
barrier_cell = { workspace = true }
chrono = { workspace = true }
console = { workspace = true }
crossbeam-channel = { workspace = true }
csv = { workspace = true }
dashmap = { workspace = true }
deno_task_shell = { workspace = true }
dialoguer = { workspace = true }
dunce = { workspace = true }
fancy_display = { workspace = true }
Expand Down Expand Up @@ -68,14 +65,12 @@ rattler_repodata_gateway = { workspace = true }
rattler_shell = { workspace = true }
rattler_solve = { workspace = true }
rattler_virtual_packages = { workspace = true }
rayon = { workspace = true }
reqwest = { workspace = true }
reqwest-middleware = { workspace = true }
rlimit = { workspace = true }
rstest = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
shlex = { workspace = true }
tabwriter = { workspace = true }
tempfile = { workspace = true }
thiserror = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion crates/pixi_core/src/activation.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::{Workspace, workspace::Environment};
use crate::{task::EnvironmentHash, workspace::HasWorkspaceRef};
use crate::{environment::EnvironmentHash, workspace::HasWorkspaceRef};
use fs_err::tokio as tokio_fs;
use indexmap::IndexMap;
use itertools::Itertools;
Expand Down
64 changes: 63 additions & 1 deletion crates/pixi_core/src/environment/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ use pixi_utils::{prefix::Prefix, rlimit::try_increase_rlimit_to_sensible};
pub use pypi_prefix::{ContinuePyPIPrefixUpdate, on_python_interpreter_change};
pub use python_status::PythonStatus;
use rattler_conda_types::Platform;
use rattler_lock::LockedPackageRef;
use rattler_lock::{LockFile, LockedPackageRef};
use serde::{Deserialize, Serialize};
use std::collections::HashSet;
use std::fmt::{Display, Formatter};
use std::{
collections::HashMap,
hash::{Hash, Hasher},
Expand All @@ -28,6 +29,7 @@ use std::{
};
use xxhash_rust::xxh3::Xxh3;

use crate::workspace;
use crate::{
Workspace,
lock_file::{LockFileDerivedData, ReinstallPackages, UpdateLockFileOptions, UpdateMode},
Expand Down Expand Up @@ -104,6 +106,66 @@ async fn prefix_location_changed(
}
}

#[derive(Debug, Eq, PartialEq, Hash, Serialize, Deserialize)]
pub struct EnvironmentHash(String);

impl EnvironmentHash {
pub fn from_environment(
run_environment: &workspace::Environment<'_>,
input_environment_variables: &HashMap<String, Option<String>>,
lock_file: &LockFile,
) -> Self {
let mut hasher = Xxh3::new();

// Hash the environment variables
let mut sorted_input_environment_variables: Vec<_> =
input_environment_variables.iter().collect();
sorted_input_environment_variables.sort_by_key(|(key, _)| *key);
for (key, value) in sorted_input_environment_variables {
key.hash(&mut hasher);
value.hash(&mut hasher);
}

// Hash the activation scripts
let activation_scripts =
run_environment.activation_scripts(Some(run_environment.best_platform()));
for script in activation_scripts {
script.hash(&mut hasher);
}

// Hash the environment variables
let project_activation_env =
run_environment.activation_env(Some(run_environment.best_platform()));
let mut env_vars: Vec<_> = project_activation_env.iter().collect();
env_vars.sort_by_key(|(key, _)| *key);

for (key, value) in env_vars {
key.hash(&mut hasher);
value.hash(&mut hasher);
}

// Hash the packages
let mut urls = Vec::new();
if let Some(env) = lock_file.environment(run_environment.name().as_str()) {
if let Some(packages) = env.packages(run_environment.best_platform()) {
for package in packages {
urls.push(package.location().to_string())
}
}
}
urls.sort();
urls.hash(&mut hasher);

EnvironmentHash(format!("{:x}", hasher.finish()))
}
}

impl Display for EnvironmentHash {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.0)
}
}

#[derive(Debug, Hash, Serialize, Deserialize, PartialEq, Eq)]
pub struct LockedEnvironmentHash(String);
impl LockedEnvironmentHash {
Expand Down
1 change: 0 additions & 1 deletion crates/pixi_core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ mod install_pypi;
pub mod lock_file;
pub mod prompt;
pub mod repodata;
pub mod task;
pub mod workspace;

pub mod signals;
Expand Down
3 changes: 0 additions & 3 deletions crates/pixi_global/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ readme.workspace = true
repository.workspace = true
version = "0.1.0"

[features]
slow_integration_tests = []

[dependencies]
ahash = { workspace = true }
console = { workspace = true }
Expand Down
37 changes: 37 additions & 0 deletions crates/pixi_task/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[package]
authors.workspace = true
description = "Task execution with dependency graphs and caching"
edition.workspace = true
homepage.workspace = true
license.workspace = true
name = "pixi_task"
readme.workspace = true
repository.workspace = true
version = "0.1.0"

[dependencies]
anyhow = { workspace = true }
assert_matches = { workspace = true }
crossbeam-channel = { workspace = true }
deno_task_shell = { workspace = true }
fancy_display = { workspace = true }
fs-err = { workspace = true }
itertools = { workspace = true }
miette = { workspace = true }
pixi_consts = { workspace = true }
pixi_core = { workspace = true }
pixi_glob = { workspace = true }
pixi_manifest = { workspace = true, features = ["rattler_lock"] }
pixi_progress = { workspace = true }
rattler_conda_types = { workspace = true }
rattler_lock = { workspace = true }
rayon = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
shlex = { workspace = true }
tempfile = { workspace = true }
thiserror = { workspace = true }
tokio = { workspace = true }
tracing = { workspace = true }
uv-configuration = { workspace = true }
xxhash-rust = { workspace = true }
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,20 @@ use fs_err::tokio as tokio_fs;
use itertools::Itertools;
use miette::{Context, Diagnostic};
use pixi_consts::consts;
use pixi_core::{
Workspace,
activation::CurrentEnvVarBehavior,
workspace::get_activated_environment_variables,
workspace::{Environment, HasWorkspaceRef},
};
use pixi_manifest::{Task, TaskName, task::ArgValues, task::TemplateStringError};
use pixi_progress::await_in_progress;
use rattler_lock::LockFile;
use thiserror::Error;
use tokio::task::JoinHandle;

use super::task_hash::{InputHashesError, NameHash, TaskCache, TaskHash};
use crate::{
Workspace,
activation::CurrentEnvVarBehavior,
task::task_graph::{TaskGraph, TaskId},
workspace::get_activated_environment_variables,
workspace::{Environment, HasWorkspaceRef},
};
use crate::task_graph::{TaskGraph, TaskId};
use crate::task_hash::{InputHashesError, NameHash, TaskCache, TaskHash};

/// Runs task in project.
#[derive(Default, Debug)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ mod task_hash;

pub use file_hashes::{FileHashes, FileHashesError};
pub use pixi_manifest::{Task, TaskName};
pub use task_hash::{ComputationHash, EnvironmentHash, InputHashes, TaskHash};
pub use task_hash::{ComputationHash, InputHashes, TaskHash};

pub use executable_task::{
CanSkip, ExecutableTask, FailedToParseShellScript, InvalidWorkingDirectory, RunOutput,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
use miette::Diagnostic;
use pixi_core::{
Workspace,
workspace::{Environment, virtual_packages::verify_current_platform_can_run_environment},
};
use pixi_manifest::{Task, TaskName};
use rattler_conda_types::Platform;
use thiserror::Error;

use crate::{
Workspace,
task::error::{AmbiguousTaskError, MissingTaskError},
workspace::{Environment, virtual_packages::verify_current_platform_can_run_environment},
};
use crate::error::{AmbiguousTaskError, MissingTaskError};

/// Defines where the task was defined when looking for a task.
#[derive(Debug, Clone)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use std::{

use itertools::Itertools;
use miette::Diagnostic;
use pixi_core::{Workspace, workspace::Environment};
use pixi_manifest::{
EnvironmentName, Task, TaskName,
task::{
Expand All @@ -18,13 +19,9 @@ use pixi_manifest::{
use thiserror::Error;

use crate::{
Workspace,
task::{
TaskDisambiguation,
error::{AmbiguousTaskError, MissingTaskError},
task_environment::{FindTaskError, FindTaskSource, SearchEnvironments},
},
workspace::Environment,
TaskDisambiguation,
error::{AmbiguousTaskError, MissingTaskError},
task_environment::{FindTaskError, FindTaskSource, SearchEnvironments},
};

/// A task ID is a unique identifier for a [`TaskNode`] in a [`TaskGraph`].
Expand Down Expand Up @@ -570,13 +567,11 @@ pub enum TaskGraphError {
mod test {
use std::path::Path;

use pixi_core::Workspace;
use pixi_manifest::EnvironmentName;
use rattler_conda_types::Platform;

use crate::{
Workspace,
task::{task_environment::SearchEnvironments, task_graph::TaskGraph},
};
use crate::{task_environment::SearchEnvironments, task_graph::TaskGraph};

fn commands_in_order(
project_str: &str,
Expand Down
Loading
Loading