Skip to content

Commit

Permalink
feat: Add 'ignore_pypi_errors' flag
Browse files Browse the repository at this point in the history
  • Loading branch information
delsner committed Jun 5, 2024
1 parent 6aa38d9 commit b336d21
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ enum Commands {
/// Output file to write the pack to
#[arg(short, long, default_value = cwd().join("environment.tar.zstd").into_os_string())]
output_file: PathBuf,

/// Pypi dependencies are not supported yet.
/// This flag allows the pack to continue even if pypi dependencies are present.
#[arg(short, long, default_value = "false")]
ignore_pypi_errors: bool,
},

/// Unpack a pixi environment
Expand Down Expand Up @@ -92,6 +97,7 @@ async fn main() -> Result<()> {
auth_file,
manifest_path,
output_file,
ignore_pypi_errors,
} => {
let options = PackOptions {
environment,
Expand All @@ -104,6 +110,7 @@ async fn main() -> Result<()> {
platform,
},
level: None,
ignore_pypi_errors,
};
tracing::debug!("Running pack command with options: {:?}", options);
pack(options).await?
Expand Down
7 changes: 6 additions & 1 deletion src/pack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ pub struct PackOptions {
pub manifest_path: PathBuf,
pub metadata: PixiPackMetadata,
pub level: Option<Level>,
pub ignore_pypi_errors: bool,
}

/// Pack a pixi environment.
Expand Down Expand Up @@ -71,7 +72,11 @@ pub async fn pack(options: PackOptions) -> Result<()> {
match package {
Package::Conda(p) => conda_packages.push(p),
Package::Pypi(_) => {
anyhow::bail!("pypi packages are not supported in pixi-pack");
if options.ignore_pypi_errors {
tracing::warn!("pypi packages are not supported in pixi-pack");
} else {
anyhow::bail!("pypi packages are not supported in pixi-pack");
}
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions tests/integration_test.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(clippy::too_many_arguments)]

use std::{path::PathBuf, process::Command};

use async_compression::Level;
Expand All @@ -23,6 +25,7 @@ fn options(
#[default(PixiPackMetadata::default())] metadata: PixiPackMetadata,
#[default(Some(Level::Best))] level: Option<Level>,
#[default(Some(ShellEnum::Bash(Bash)))] shell: Option<ShellEnum>,
#[default(true)] ignore_pypi_errors: bool,
) -> Options {
let output_dir = tempdir().expect("Couldn't create a temp dir for tests");
let pack_file = output_dir.path().join("environment.tar.zstd");
Expand All @@ -35,6 +38,7 @@ fn options(
manifest_path,
metadata,
level,
ignore_pypi_errors,
},
unpack_options: UnpackOptions {
pack_file,
Expand Down

0 comments on commit b336d21

Please sign in to comment.