Repository: prefix-dev/pixi

Issue #2411: pyproject.toml with duplicated PyPi and Conda deps still requires PyPi solving
Created: 2024-11-04T20:40:44Z
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
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 #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

Duplicate issue #3001: Help detecting dependencies in `pyproject.toml` that are only specified as conda-dependencies
Created: 2025-01-24T12:34:55Z
Problem description
Problem description
Let's assume the following script:
# __init__.py
import numpy as np
x = np.array([1,2,3])
and the following pyproject.toml
[project]
dependencies = []
name = "pypi-test"
requires-python = ">= 3.11"
version = "0.1.0"

[build-system]
build-backend = "hatchling.build"
requires = ["hatchling"]

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

[tool.pixi.pypi-dependencies]
pypi_test = { path = ".", editable = true }

[tool.pixi.dependencies]
numpy = ">=2.2.2,<3"
This works fine, when used with pixi, but when you publish it on PyPI, people will not be able to use it since numpy isn't added as dependency.
Suggested solutions
We already know which conda packages correspond to PyPI packages.
Therefore, we also know the list of packages that are missing in project.dependencies
We could:

warn, but only if pyproject.toml is both the package and the manifest
create pixi lint and add that as a lint rule
let that handle by an external lint tool

References
Discord discussion

Closing comment (2025-02-05T19:27:55Z): Also related to #2411 I think.
Would really like to not have to list (conda) dependencies in a bunch of places (recipe.yaml then twice in pyproject.toml), but would also like to stay PEP 621 compliant for ease of reading by other developers and whatever build backend I choose.