Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Noarch python packages not installable #6

Merged
merged 2 commits into from
Dec 2, 2024
Merged
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
21 changes: 19 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -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::{
Expand Down Expand Up @@ -123,7 +123,24 @@ pub async fn pixi_inject(target_prefix: PathBuf, packages: Vec<PathBuf>) -> 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 {
Expand Down
25 changes: 25 additions & 0 deletions tests/integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>) {
Expand Down
Binary file not shown.