Skip to content

Commit fb35784

Browse files
committed
wip: also works with variants
1 parent 766555b commit fb35784

File tree

10 files changed

+757
-159
lines changed

10 files changed

+757
-159
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/pixi/tests/integration_rust/develop_dependencies_tests.rs

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ fn create_test_package_database() -> PackageDatabase {
2323
db.add_package(Package::build("openssl", "3.0.0").finish());
2424
db.add_package(Package::build("zlib", "1.2.11").finish());
2525
db.add_package(Package::build("python", "3.9.0").finish());
26+
db.add_package(Package::build("python", "3.10.0").finish());
27+
db.add_package(Package::build("python", "3.11.0").finish());
28+
db.add_package(Package::build("python", "3.12.0").finish());
29+
db.add_package(Package::build("python", "3.13.0").finish());
2630
db.add_package(Package::build("numpy", "1.21.0").finish());
2731
db.add_package(Package::build("requests", "2.26.0").finish());
2832

@@ -622,3 +626,128 @@ platform-package = {{ path = "./platform-package" }}
622626
"platform-package should NOT be in the lock-file (it's a develop dependency)"
623627
);
624628
}
629+
630+
/// Test that variant selection chooses the highest matching version
631+
/// When python = "*" with variants [3.10, 3.12], should select 3.12 even though 3.13 exists
632+
#[tokio::test]
633+
async fn test_develop_dependency_variant_selection() {
634+
setup_tracing();
635+
let package_database = create_test_package_database();
636+
637+
let channel = package_database.into_channel().await.unwrap();
638+
639+
// Create the test directory
640+
let backend_override = BackendOverride::from_memory(PassthroughBackend::instantiator());
641+
let pixi = PixiControl::new()
642+
.unwrap()
643+
.with_backend_override(backend_override);
644+
645+
// Create the variant-python-package directory
646+
create_source_package(
647+
pixi.workspace_path(),
648+
"variant-python-package",
649+
"0.1.0",
650+
r#"
651+
[package.run-dependencies]
652+
python = "*"
653+
"#,
654+
);
655+
656+
// Create a manifest with develop dependencies and variants
657+
let manifest_content = format!(
658+
r#"
659+
[workspace]
660+
channels = ["{}"]
661+
platforms = ["{}"]
662+
preview = ["pixi-build"]
663+
664+
[dependencies]
665+
666+
[develop]
667+
variant-python-package = {{ path = "./variant-python-package" }}
668+
669+
[workspace.build-variants]
670+
python = ["3.10", "3.12"]
671+
"#,
672+
channel.url(),
673+
Platform::current()
674+
);
675+
676+
fs::write(pixi.manifest_path(), manifest_content).unwrap();
677+
678+
// Update the lock-file
679+
let lock_file = pixi.update_lock_file().await.unwrap();
680+
681+
// Verify that python 3.12 is in the lock-file (highest variant)
682+
assert!(
683+
lock_file.contains_match_spec(
684+
consts::DEFAULT_ENVIRONMENT_NAME,
685+
Platform::current(),
686+
"python ==3.12.0",
687+
),
688+
"Should select python 3.12 (highest available variant), not 3.13"
689+
);
690+
}
691+
692+
/// Test that variant selection is constrained by regular dependencies
693+
/// When python = "*" with variants [3.10, 3.12], but dependencies require <3.12, should select 3.10
694+
#[tokio::test]
695+
async fn test_develop_dependency_variant_constrained_by_dependencies() {
696+
setup_tracing();
697+
let package_database = create_test_package_database();
698+
699+
let channel = package_database.into_channel().await.unwrap();
700+
701+
// Create the test directory
702+
let backend_override = BackendOverride::from_memory(PassthroughBackend::instantiator());
703+
let pixi = PixiControl::new()
704+
.unwrap()
705+
.with_backend_override(backend_override);
706+
707+
// Create the variant-python-package directory
708+
create_source_package(
709+
pixi.workspace_path(),
710+
"variant-python-package",
711+
"0.1.0",
712+
r#"
713+
[package.run-dependencies]
714+
python = "*"
715+
"#,
716+
);
717+
718+
// Create a manifest with develop dependencies, variants, and a constraining dependency
719+
let manifest_content = format!(
720+
r#"
721+
[workspace]
722+
channels = ["{}"]
723+
platforms = ["{}"]
724+
preview = ["pixi-build"]
725+
726+
[dependencies]
727+
python = "<3.12"
728+
729+
[develop]
730+
variant-python-package = {{ path = "./variant-python-package" }}
731+
732+
[workspace.build-variants]
733+
python = ["3.10", "3.12"]
734+
"#,
735+
channel.url(),
736+
Platform::current()
737+
);
738+
739+
fs::write(pixi.manifest_path(), manifest_content).unwrap();
740+
741+
// Update the lock-file
742+
let lock_file = pixi.update_lock_file().await.unwrap();
743+
744+
// Verify that python 3.10 is in the lock-file (constrained by dependency)
745+
assert!(
746+
lock_file.contains_match_spec(
747+
consts::DEFAULT_ENVIRONMENT_NAME,
748+
Platform::current(),
749+
"python ==3.10.0",
750+
),
751+
"Should select python 3.10 (constrained by dependency <3.12), not 3.12"
752+
);
753+
}

crates/pixi_build_backend_passthrough/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ version = "0.1.0"
1111

1212
[dependencies]
1313
fs-err = { workspace = true }
14+
itertools = { workspace = true }
1415
ordermap = { workspace = true }
1516
pixi_build_frontend = { workspace = true }
1617
pixi_build_types = { workspace = true }

0 commit comments

Comments
 (0)