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: satisfy when there is not pypi packages in the lockfile #1862

Merged
Show file tree
Hide file tree
Changes from 1 commit
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
55 changes: 55 additions & 0 deletions src/lock_file/satisfiability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,9 +258,14 @@ pub fn verify_environment_satisfiability(
let indexes = rattler_lock::PypiIndexes::from(grouped_env.pypi_options());
match locked_environment.pypi_indexes() {
None => {
// Mismatch when there should be an index but there is not
if locked_environment
.version()
.should_pypi_indexes_be_present()
&& locked_environment
.pypi_packages()
.iter()
.any(|(_platform, packages)| !packages.is_empty())
{
return Err(IndexesMismatch {
current: indexes,
Expand Down Expand Up @@ -1199,4 +1204,54 @@ mod tests {
// This should satisfy:
assert!(pypi_satifisfies_requirement(&spec, &locked_data));
}

// Test if the lockfile satisfies when pypi-dependencies are defined but all overwritten by conda deps.
#[test]
fn test_satisfiability_with_pypi_deps_no_pypi_install() {
ruben-arts marked this conversation as resolved.
Show resolved Hide resolved
let manifest = r#"
[project]
name = "test"
channels = ["https://fast.prefix.dev/conda-forge"]
platforms = ["linux-64"]

[dependencies]
ruff = "*"

[pypi-dependencies]
ruff = "*"
"#;

// Fake lockfile that satisfies the manifest
let lockfile = r#"
version: 5
environments:
default:
channels:
- url: https://fast.prefix.dev/conda-forge/
packages:
linux-64:
- conda: https://conda.anaconda.org/conda-forge/linux-64/ruff-0.5.7-py312hbe4c86d_0.conda
packages:
- kind: conda
name: ruff
version: 0.5.7
build: py312hbe4c86d_0
subdir: linux-64
url: https://conda.anaconda.org/conda-forge/linux-64/ruff-0.5.7-py312hbe4c86d_0.conda
sha256: b8cc83042471c5740f29a5f3ce1ef7116b892095591907929671fe4e33345026
md5: 8871e1b8e5ec1c57d3769adc0b9e5d68
constrains:
- __glibc >=2.17
license: MIT
license_family: MIT
purls:
- pkg:pypi/ruff?source=hash-mapping
size: 7184746
timestamp: 1723150552013
"#;

let project = Project::from_str(Path::new("pixi.toml"), manifest).unwrap();
let lock = LockFile::from_str(lockfile).unwrap();
verify_lockfile_satisfiability(&project, &lock).unwrap();
}
}
11 changes: 5 additions & 6 deletions tests/add_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ mod common;

use std::str::FromStr;

use crate::common::{
builders::{HasDependencyConfig, HasPrefixUpdateConfig},
package_database::{Package, PackageDatabase},
LockFileExt, PixiControl,
};
use pixi::{DependencyType, Project};
use pixi_consts::consts;
use pixi_manifest::{pypi::PyPiPackageName, FeaturesExt, SpecType};
Expand All @@ -10,12 +15,6 @@ use serial_test::serial;
use tempfile::TempDir;
use uv_normalize::ExtraName;

use crate::common::{
builders::{HasDependencyConfig, HasPrefixUpdateConfig},
package_database::{Package, PackageDatabase},
LockFileExt, PixiControl,
};

/// Test add functionality for different types of packages.
/// Run, dev, build
#[tokio::test]
Expand Down
Loading