From b336d21c25831f2c6ccc914de519674effaa17f8 Mon Sep 17 00:00:00 2001 From: Daniel Elsner Date: Wed, 5 Jun 2024 15:55:55 +0200 Subject: [PATCH] feat: Add 'ignore_pypi_errors' flag --- src/main.rs | 7 +++++++ src/pack.rs | 7 ++++++- tests/integration_test.rs | 4 ++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index f951af9..c119e00 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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 @@ -92,6 +97,7 @@ async fn main() -> Result<()> { auth_file, manifest_path, output_file, + ignore_pypi_errors, } => { let options = PackOptions { environment, @@ -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? diff --git a/src/pack.rs b/src/pack.rs index 29f2ff7..1033dcf 100644 --- a/src/pack.rs +++ b/src/pack.rs @@ -34,6 +34,7 @@ pub struct PackOptions { pub manifest_path: PathBuf, pub metadata: PixiPackMetadata, pub level: Option, + pub ignore_pypi_errors: bool, } /// Pack a pixi environment. @@ -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"); + } } } } diff --git a/tests/integration_test.rs b/tests/integration_test.rs index da6828e..f0b21b4 100644 --- a/tests/integration_test.rs +++ b/tests/integration_test.rs @@ -1,3 +1,5 @@ +#![allow(clippy::too_many_arguments)] + use std::{path::PathBuf, process::Command}; use async_compression::Level; @@ -23,6 +25,7 @@ fn options( #[default(PixiPackMetadata::default())] metadata: PixiPackMetadata, #[default(Some(Level::Best))] level: Option, #[default(Some(ShellEnum::Bash(Bash)))] shell: Option, + #[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"); @@ -35,6 +38,7 @@ fn options( manifest_path, metadata, level, + ignore_pypi_errors, }, unpack_options: UnpackOptions { pack_file,