Skip to content

Commit

Permalink
Support for sdists in pixi (#664)
Browse files Browse the repository at this point in the history
  • Loading branch information
tdejager authored Jan 18, 2024
1 parent 6746b43 commit bd4e26d
Show file tree
Hide file tree
Showing 36 changed files with 1,109 additions and 591 deletions.
36 changes: 12 additions & 24 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ rattler_solve = { version = "0.16.2", default-features = false, features = ["res
rattler_virtual_packages = { version = "0.16.2", default-features = false }
regex = "1.10.2"
reqwest = { version = "0.11.23", default-features = false }
rip = { package = "rattler_installs_packages", version = "0.1.0", default-features = false }
rip = { package = "rattler_installs_packages", version = "0.4.0", default-features = false }
self-replace = "1.3.7"
serde = "1.0.195"
serde-untagged = "0.1.5"
Expand Down
386 changes: 288 additions & 98 deletions examples/pypi/pixi.lock

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions examples/pypi/pixi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,22 @@ channels = ["conda-forge"]
platforms = ["win-64", "linux-64", "osx-64", "osx-arm64"]

[tasks]
start = "python pycosat_example.py"

[dependencies]
python = "~=3.11.0"
numpy = "*"
libclang = "~=16.0.6"
scipy = "~=1.11.4"

[pypi-dependencies]
pyboy = "==1.6.6"
tensorflow = "==2.14.0"
flask = "*"
black = {version = "~=23.10", extras = ["jupyter"]}
# sdists:
pyliblzfse = "*"
pycosat = "*"

[system-requirements]
# Tensorflow on macOS arm64 requires macOS 12.0 or higher
Expand Down
5 changes: 5 additions & 0 deletions examples/pypi/pycosat_example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Extremely simple example of using pycosat to show we can run sdist packages
import pycosat
cnf = [[1, -5, 4], [-1, 5, 3, 4], [-3, -4]]
result = pycosat.solve(cnf)
print(result)
21 changes: 19 additions & 2 deletions src/cli/add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use rattler_conda_types::{
};
use rattler_repodata_gateway::sparse::SparseRepoData;
use rattler_solve::{resolvo, SolverImpl};
use rip::resolve::SDistResolution;
use std::{
collections::{HashMap, HashSet},
path::PathBuf,
Expand Down Expand Up @@ -83,6 +84,10 @@ pub struct Args {
/// The platform(s) for which the dependency should be added
#[arg(long, short)]
pub platform: Vec<Platform>,

/// Resolution scheme to use
#[arg(skip)]
pub sdist_resolution: SDistResolution,
}

impl DependencyType {
Expand Down Expand Up @@ -137,6 +142,7 @@ pub async fn execute(args: Args) -> miette::Result<()> {
args.no_install,
args.no_lockfile_update,
spec_platforms,
args.sdist_resolution,
)
.await
}
Expand Down Expand Up @@ -166,6 +172,7 @@ pub async fn execute(args: Args) -> miette::Result<()> {
spec_platforms,
args.no_lockfile_update,
args.no_install,
args.sdist_resolution,
)
.await
}
Expand Down Expand Up @@ -207,6 +214,7 @@ pub async fn add_pypi_specs_to_project(
specs_platforms: &Vec<Platform>,
no_update_lockfile: bool,
no_install: bool,
sdist_resolution: SDistResolution,
) -> miette::Result<()> {
for (name, spec) in &specs {
// TODO: Get best version
Expand All @@ -227,7 +235,7 @@ pub async fn add_pypi_specs_to_project(
LockFileUsage::Update
};

get_up_to_date_prefix(project, lock_file_usage, no_install, None).await?;
get_up_to_date_prefix(project, lock_file_usage, no_install, None, sdist_resolution).await?;

project.save()?;

Expand All @@ -241,6 +249,7 @@ pub async fn add_conda_specs_to_project(
no_install: bool,
no_update_lockfile: bool,
specs_platforms: &Vec<Platform>,
sdist_resolution: SDistResolution,
) -> miette::Result<()> {
// Split the specs into package name and version specifier
let new_specs = specs
Expand Down Expand Up @@ -318,7 +327,15 @@ pub async fn add_conda_specs_to_project(
} else {
LockFileUsage::Update
};
get_up_to_date_prefix(project, lock_file_usage, no_install, Some(sparse_repo_data)).await?;

get_up_to_date_prefix(
project,
lock_file_usage,
no_install,
Some(sparse_repo_data),
sdist_resolution,
)
.await?;
project.save()?;

Ok(())
Expand Down
9 changes: 8 additions & 1 deletion src/cli/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,14 @@ pub struct Args {
pub async fn execute(args: Args) -> miette::Result<()> {
let project = Project::load_or_else_discover(args.manifest_path.as_deref())?;

get_up_to_date_prefix(&project, args.lock_file_usage.into(), false, None).await?;
get_up_to_date_prefix(
&project,
args.lock_file_usage.into(),
false,
None,
Default::default(),
)
.await?;

// Emit success
eprintln!(
Expand Down
9 changes: 8 additions & 1 deletion src/cli/project/channel/add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,14 @@ pub async fn execute(mut project: Project, args: Args) -> miette::Result<()> {
.manifest
.add_channels(missing_channels.iter().map(|(name, _channel)| name))?;

get_up_to_date_prefix(&project, LockFileUsage::Update, args.no_install, None).await?;
get_up_to_date_prefix(
&project,
LockFileUsage::Update,
args.no_install,
None,
Default::default(),
)
.await?;
project.save()?;
// Report back to the user
for (name, channel) in missing_channels {
Expand Down
9 changes: 8 additions & 1 deletion src/cli/project/channel/remove.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,14 @@ pub async fn execute(mut project: Project, args: Args) -> miette::Result<()> {
.remove_channels(channels_to_remove.iter().map(|(name, _channel)| name))?;

// Try to update the lock-file without the removed channels
get_up_to_date_prefix(&project, LockFileUsage::Update, args.no_install, None).await?;
get_up_to_date_prefix(
&project,
LockFileUsage::Update,
args.no_install,
None,
Default::default(),
)
.await?;
project.save()?;

// Report back to the user
Expand Down
9 changes: 8 additions & 1 deletion src/cli/project/platform/add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,14 @@ pub async fn execute(mut project: Project, args: Args) -> miette::Result<()> {
project.manifest.add_platforms(missing_platforms.iter())?;

// Try to update the lock-file with the new channels
get_up_to_date_prefix(&project, LockFileUsage::Update, args.no_install, None).await?;
get_up_to_date_prefix(
&project,
LockFileUsage::Update,
args.no_install,
None,
Default::default(),
)
.await?;
project.save()?;

// Report back to the user
Expand Down
9 changes: 8 additions & 1 deletion src/cli/project/platform/remove.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,14 @@ pub async fn execute(mut project: Project, args: Args) -> miette::Result<()> {
.manifest
.remove_platforms(platforms_to_remove.iter().map(|p| p.to_string()))?;

get_up_to_date_prefix(&project, LockFileUsage::Update, args.no_install, None).await?;
get_up_to_date_prefix(
&project,
LockFileUsage::Update,
args.no_install,
None,
Default::default(),
)
.await?;
project.save()?;

// Report back to the user
Expand Down
9 changes: 8 additions & 1 deletion src/cli/remove.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,14 @@ pub async fn execute(args: Args) -> miette::Result<()> {
eprintln!("{}", sucessful_output.join("\n"));

// updating prefix after removing from toml
let _ = get_up_to_date_prefix(&project, LockFileUsage::Update, false, None).await?;
let _ = get_up_to_date_prefix(
&project,
LockFileUsage::Update,
false,
None,
Default::default(),
)
.await?;

Ok(())
}
3 changes: 2 additions & 1 deletion src/cli/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,8 @@ pub async fn get_task_env(
lock_file_usage: LockFileUsage,
) -> miette::Result<HashMap<String, String>> {
// Get the prefix which we can then activate.
let prefix = get_up_to_date_prefix(project, lock_file_usage, false, None).await?;
let prefix =
get_up_to_date_prefix(project, lock_file_usage, false, None, Default::default()).await?;

// Get environment variables from the activation
let activation_env = run_activation_async(project, prefix).await?;
Expand Down
3 changes: 2 additions & 1 deletion src/cli/shell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,8 @@ pub async fn get_shell_env(
lock_file_usage: LockFileUsage,
) -> miette::Result<HashMap<String, String>> {
// Get the prefix which we can then activate.
let prefix = get_up_to_date_prefix(project, lock_file_usage, false, None).await?;
let prefix =
get_up_to_date_prefix(project, lock_file_usage, false, None, Default::default()).await?;

// Get environment variables from the activation
let activation_env = run_activation_async(project, prefix).await?;
Expand Down
Loading

0 comments on commit bd4e26d

Please sign in to comment.