prefix-dev / pixi

Package management made easy
https://pixi.sh
BSD 3-Clause "New" or "Revised" License
3.35k stars 190 forks source link

pyproject.toml with duplicated PyPi and Conda deps still requires PyPi solving #2411

Open srilman opened 2 weeks ago

srilman commented 2 weeks ago

Checks

Reproducible example

I'm working with the following Pixi configuration

[project]
name = "tester"
version = "0.1.0"
requires-python = ">=3.10,<3.13"

dependencies = [
    "numpy>=1.24,<1.27",
]

# -------------------------- Pixi Config --------------------------- #
[tool.pixi.project]
channels = ["conda-forge"]
platforms = ["linux-64", "osx-64", "osx-arm64"]

[tool.pixi.environments]
default = { features = ["py312"], solve-group = "312" }
dev311 = { features = ["py311"], solve-group = "311" }

[tool.pixi.dependencies]
numpy = "*"

[tool.pixi.feature.py312]
dependencies = { python = "3.12.*" }

[tool.pixi.feature.py311]
platforms = ["linux-64"]
dependencies = { python = "3.11.*" }

This unexpectedly raises the error:

× Unable to solve pypi dependencies for the dev311 environment because no compatible python interpreter can be installed for the current
  │ platform
...
  help: Try converting your [pypi-dependencies] to conda [dependencies]

Using Pixi 0.34.0 on a MacOS ARM machine.

Issue description

I'm aware of the error message provided. It is related to https://github.com/prefix-dev/pixi/issues/1051, and I understand the reasons behind it. I do not understand why this error appeared in this example, since I attempted to avoid using any PyPi dependencies.

From my understanding, any dependencies specified in project.dependencies will normally be treated as PyPi dependencies under the default feature. But based on the docs in https://pixi.sh/latest/advanced/pyproject_toml/#dependency-section, I expected that respecifying Numpy in tool.pixi.dependencies would override the requirement. But checking pixi info, I see:

Environments
------------
       Environment: default
          Features: py312, default
       Solve group: 312
          Channels: conda-forge
  Dependency count: 2
      Dependencies: python, numpy
 PyPI Dependencies: numpy
  Target platforms: osx-arm64, linux-64, osx-64

       Environment: dev311
          Features: py311, default
       Solve group: 311
          Channels: conda-forge
  Dependency count: 2
      Dependencies: python, numpy
 PyPI Dependencies: numpy
  Target platforms: linux-64

Numpy as specified as both a PyPi and Conda dependency. If I were to comment out the dev311 environment and run pixi install, I see that Pixi attempts to solve for PyPi deps, but the resulting lockfile doesn't contain any.

Is this a bug, or is there an edge case or scenario that I'm not considering where this makes sense? If so, is there a way to explicitly ignore the project dependencies, or should I just use a pixi.toml?

Expected behavior

My expectation is that Numpy would not be considered a PyPi dependency when running pixi info, and that the original Pixi configuration would solve on my existing system on Pixi 0.34.0

ruben-arts commented 2 weeks ago

Thanks for the input! This sounds like a good improvement! Since we have the mapping now we should be able to short circuit this.