Skip to content
Open
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
49 changes: 26 additions & 23 deletions Cargo.lock

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

22 changes: 11 additions & 11 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -117,23 +117,23 @@ pypi_mapping = { path = "crates/pypi_mapping" }
pypi_modifiers = { path = "crates/pypi_modifiers" }
pyproject-toml = "0.13.7"
rand = { version = "0.9.1", default-features = false }
rattler = { version = "0.39.1", default-features = false }
rattler_cache = { version = "0.6.0", default-features = false }
rattler_conda_types = { version = "0.41.1", default-features = false, features = [
rattler = { version = "0.39.3", default-features = false }
rattler_cache = { version = "0.6.2", default-features = false }
rattler_conda_types = { version = "0.42.0", default-features = false, features = [
"rayon",
] }
rattler_digest = { version = "1.2.0", default-features = false }
rattler_lock = { version = "0.26.1", default-features = false }
rattler_menuinst = { version = "0.2.23", default-features = false }
rattler_networking = { version = "0.25.21", default-features = false, features = [
rattler_lock = { version = "0.26.5", default-features = false }
rattler_menuinst = { version = "0.2.38", default-features = false }
rattler_networking = { version = "0.25.25", default-features = false, features = [
"dirs",
"google-cloud-auth",
] }
rattler_package_streaming = { version = "0.23.13", default-features = false }
rattler_repodata_gateway = { version = "0.25.1", default-features = false }
rattler_shell = { version = "0.25.7", default-features = false }
rattler_solve = { version = "3.1.1", default-features = false }
rattler_virtual_packages = { version = "2.2.5", default-features = false }
rattler_package_streaming = { version = "0.23.17", default-features = false }
rattler_repodata_gateway = { version = "0.25.3", default-features = false }
rattler_shell = { version = "0.25.11", default-features = false }
rattler_solve = { version = "4.0.0", default-features = false }
rattler_virtual_packages = { version = "2.3.0", default-features = false }
rayon = "1.10.0"
regex = "1.11.1"
reqwest = { version = "0.12.12", default-features = false }
Expand Down
1 change: 1 addition & 0 deletions crates/pixi_api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ indexmap = { workspace = true }
itertools = { workspace = true }
miette = { workspace = true }
minijinja = { workspace = true }
pep508_rs = { workspace = true }
pixi_config = { workspace = true }
pixi_consts = { workspace = true }
pixi_core = { workspace = true }
Expand Down
128 changes: 88 additions & 40 deletions crates/pixi_api/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,29 @@ use std::collections::HashMap;

use indexmap::{IndexMap, IndexSet};
use miette::IntoDiagnostic;
use pixi_core::workspace::WorkspaceMut;
use pixi_core::workspace::{PypiDeps, UpdateDeps, WorkspaceMut};
use pixi_core::{Workspace, environment::LockFileUsage};
use pixi_manifest::{
EnvironmentName, Feature, FeatureName, PrioritizedChannel, TargetSelector, Task, TaskName,
EnvironmentName, Feature, FeatureName, PrioritizedChannel, SpecType, TargetSelector, Task,
TaskName,
};
use pixi_pypi_spec::{PixiPypiSpec, PypiPackageName};
use pixi_spec::PixiSpec;
use rattler_conda_types::{Channel, MatchSpec, PackageName, Platform, RepoDataRecord};

use crate::interface::Interface;
use crate::workspace::{InitOptions, ReinstallOptions};
use crate::workspace::add::GitOptions;
use crate::workspace::{DependencyOptions, InitOptions, ReinstallOptions};

pub struct DefaultContext<I: Interface> {
interface: I,
_interface: I,
}

impl<I: Interface> DefaultContext<I> {
pub fn new(interface: I) -> Self {
Self { interface }
Self {
_interface: interface,
}
}

/// Returns all matching package versions sorted by version
Expand All @@ -30,14 +34,7 @@ impl<I: Interface> DefaultContext<I> {
channels: IndexSet<Channel>,
platform: Platform,
) -> miette::Result<Option<Vec<RepoDataRecord>>> {
crate::workspace::search::search_exact(
&self.interface,
None,
match_spec,
channels,
platform,
)
.await
crate::workspace::search::search_exact(None, match_spec, channels, platform).await
}

/// Returns all matching packages with their latest versions
Expand All @@ -47,8 +44,7 @@ impl<I: Interface> DefaultContext<I> {
channels: IndexSet<Channel>,
platform: Platform,
) -> miette::Result<Option<Vec<RepoDataRecord>>> {
crate::workspace::search::search_wildcard(&self.interface, None, search, channels, platform)
.await
crate::workspace::search::search_wildcard(None, search, channels, platform).await
}
}

Expand Down Expand Up @@ -140,11 +136,85 @@ impl<I: Interface> WorkspaceContext<I> {
.await
}

pub async fn add_conda_deps(
&self,
specs: IndexMap<PackageName, MatchSpec>,
spec_type: SpecType,
dep_options: DependencyOptions,
git_options: GitOptions,
) -> miette::Result<Option<UpdateDeps>> {
Box::pin(crate::workspace::add::add_conda_dep(
self.workspace_mut()?,
specs,
spec_type,
dep_options,
git_options,
))
.await
}

pub async fn add_pypi_deps(
&self,
pypi_deps: PypiDeps,
editable: bool,
options: DependencyOptions,
) -> miette::Result<Option<UpdateDeps>> {
Box::pin(crate::workspace::add::add_pypi_dep(
self.workspace_mut()?,
pypi_deps,
editable,
options,
))
.await
}

pub async fn remove_conda_deps(
&self,
specs: IndexMap<PackageName, MatchSpec>,
spec_type: SpecType,
dep_options: DependencyOptions,
) -> miette::Result<()> {
Box::pin(crate::workspace::remove::remove_conda_deps(
self.workspace_mut()?,
specs,
spec_type,
dep_options,
))
.await
}

pub async fn remove_pypi_deps(
&self,
pypi_deps: PypiDeps,
options: DependencyOptions,
) -> miette::Result<()> {
Box::pin(crate::workspace::remove::remove_pypi_deps(
self.workspace_mut()?,
pypi_deps,
options,
))
.await
}

pub async fn reinstall(
&self,
options: ReinstallOptions,
lock_file_usage: LockFileUsage,
) -> miette::Result<()> {
crate::workspace::reinstall::reinstall(
&self.interface,
&self.workspace,
options,
lock_file_usage,
)
.await
}

pub async fn list_tasks(
&self,
environment: Option<EnvironmentName>,
) -> miette::Result<HashMap<EnvironmentName, HashMap<TaskName, Task>>> {
crate::workspace::task::list_tasks(&self.interface, &self.workspace, environment).await
crate::workspace::task::list_tasks(&self.workspace, environment).await
}

pub async fn add_task(
Expand Down Expand Up @@ -197,29 +267,13 @@ impl<I: Interface> WorkspaceContext<I> {
.await
}

pub async fn reinstall(
&self,
options: ReinstallOptions,
lock_file_usage: LockFileUsage,
) -> miette::Result<()> {
crate::workspace::reinstall::reinstall(
&self.interface,
&self.workspace,
options,
lock_file_usage,
)
.await
}

/// Returns all matching package versions sorted by version
pub async fn search_exact(
&self,
match_spec: MatchSpec,
channels: IndexSet<Channel>,
platform: Platform,
) -> miette::Result<Option<Vec<RepoDataRecord>>> {
crate::workspace::search::search_exact(
&self.interface,
Some(&self.workspace),
match_spec,
channels,
Expand All @@ -235,13 +289,7 @@ impl<I: Interface> WorkspaceContext<I> {
channels: IndexSet<Channel>,
platform: Platform,
) -> miette::Result<Option<Vec<RepoDataRecord>>> {
crate::workspace::search::search_wildcard(
&self.interface,
Some(&self.workspace),
search,
channels,
platform,
)
.await
crate::workspace::search::search_wildcard(Some(&self.workspace), search, channels, platform)
.await
}
}
Loading
Loading