prefix-dev / pixi

Package management made easy

Home Page:https://pixi.sh

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support multiple constraints pypi dependencies

zen-xu opened this issue · comments

Checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pixi, using pixi --version.

Reproducible example

# pyproject.toml
[project]
authors = [{ name = "ZhengYu, Xu", email = "zen-xu@outlook.com" }]
description = "Add a short description here"
name = "playground"
requires-python = ">=3.7,<3.12"
version = "0.1.0"
dependencies = [
    'pyarrow >=11.0.0; python_version >= "3.7" and python_version < "3.8"',
    'pyarrow ==16.1.0; python_version >= "3.8" and python_version < "3.12"',
]

[tool.pixi.project]
channels = ["conda-forge"]
platforms = ["osx-64"]

[tool.pixi.feature.py311.dependencies]
python = "3.11.*"

[tool.pixi.feature.py37.dependencies]
python = "3.7.*"

[tool.pixi.tasks]

[tool.pixi.environments]
default = { features = ["py311"], solve-group = "py311" }
py311 = { features = ["py311"], solve-group = "py311" }
py37 = { features = ["py37"], solve-group = "py37" }

Issue description

I am installing different versions of pyarrow by restricting the python_version, but it seems that pixi fail to resolve it.

image

Expected behavior

Correctly resolve the dependencies.

// Add pyproject dependencies as pypi dependencies
if let Some(deps) = item.project().and_then(|p| p.dependencies.clone()) {
for requirement in deps.iter() {
target.add_pypi_dependency(requirement, None);
}
}

pub fn add_pypi_dependency(
&mut self,
requirement: &pep508_rs::Requirement,
editable: Option<bool>,
) {
// TODO: add proper error handling for this
let mut pypi_requirement = PyPiRequirement::try_from(requirement.clone())
.expect("could not convert pep508 requirement");
if let Some(editable) = editable {
pypi_requirement.set_editable(editable);
}
self.pypi_dependencies
.get_or_insert_with(Default::default)
.insert(
PyPiPackageName::from_normalized(requirement.name.clone()),
pypi_requirement,
);
}

Version {
version: VersionOrStar,
#[serde(default)]
extras: Vec<ExtraName>,
},

It seems that pixi only considers the package version and extras in pyproject dependency.

image

I think pixi.pypi-dependencies should support multiple constraints dependencies like Poetry does

Indeed, we have to add env marker support.