diff --git a/src/lib.rs b/src/lib.rs index c27ffb5..19934e6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,5 +1,5 @@ use anyhow::Result; -use rattler::install::{link_package, InstallDriver, InstallOptions}; +use rattler::install::{link_package, InstallDriver, InstallOptions, PythonInfo}; use rattler_conda_types::{prefix_record::PathsEntry, PackageRecord, PrefixRecord, RepoDataRecord}; use rattler_package_streaming::fs::extract; use std::{ @@ -123,7 +123,24 @@ pub async fn pixi_inject(target_prefix: PathBuf, packages: Vec) -> Resu ); let driver = InstallDriver::default(); - let options = InstallOptions::default(); + let python_info = if installed_package_names.contains("python") { + Some(PythonInfo::from_python_record( + &installed_packages + .iter() + .find(|&p| p.repodata_record.package_record.name.as_normalized() == "python") + .context("Could not find python package in installed packages")? + .repodata_record + .package_record + .clone(), + Platform::current(), + )?) + } else { + None + }; + let options = InstallOptions { + python_info, + ..Default::default() + }; for (path, package_record) in injected_packages.iter() { let repodata_record = RepoDataRecord { diff --git a/tests/integration_test.rs b/tests/integration_test.rs index 66b8d4e..f9a3b40 100644 --- a/tests/integration_test.rs +++ b/tests/integration_test.rs @@ -75,6 +75,31 @@ fn required_fs_objects() -> Vec<&'static str> { ] } +#[rstest] +#[tokio::test] +async fn test_noarch_python(options: Options) { + pixi_inject::pixi_inject( + options.prefix.clone(), + vec!["tests/resources/packages/setuptools-75.6.0-pyhff2d567_1.conda".into()], + ) + .await + .unwrap(); + + #[cfg(not(unix))] + let required_fs_objects = vec![ + "Lib\\site-packages\\setuptools\\__init__.py", + "Lib\\site-packages\\pkg_resources\\__init__.py", + ]; + #[cfg(unix)] + let required_fs_objects = vec![ + "lib/python3.13/site-packages/setuptools/__init__.py", + "lib/python3.13/site-packages/pkg_resources/__init__.py", + ]; + for fs_object in required_fs_objects { + assert!(options.prefix.join(fs_object).exists()); + } +} + #[rstest] #[tokio::test] async fn test_simple_example(options: Options, required_fs_objects: Vec<&'static str>) { diff --git a/tests/resources/packages/setuptools-75.6.0-pyhff2d567_1.conda b/tests/resources/packages/setuptools-75.6.0-pyhff2d567_1.conda new file mode 100644 index 0000000..9bd95e4 Binary files /dev/null and b/tests/resources/packages/setuptools-75.6.0-pyhff2d567_1.conda differ