pypi dependency replaces and violates conda dependency
Checks
-
[x] I have checked that this issue has not already been reported.
-
[x] I have confirmed this bug exists on the latest version of pixi, using
pixi --version.
Reproducible example
# pixi --version
pixi 0.43.0
# cat pixi.toml
[workspace]
channels = ["https://software.repos.intel.com/python/conda", "conda-forge"]
name = "example"
platforms = ["linux-64"]
[tasks]
[dependencies]
numpy = "1.26.*"
python = "3.11.*"
[pypi-dependencies]
tensorflow = "~=2.18.1"
# pixi install
WARN These conda-packages will be overridden by pypi:
numpy-base
✔ The default environment has been installed.
# pixi list | grep numpy
numpy 1.26.4 py311h689b997_11 6 KiB conda https://software.repos.intel.com/python/conda/
numpy 2.0.2 66.7 MiB pypi numpy-2.0.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
numpy-base 1.26.4 py311h23d403b_11 8.7 MiB conda https://software.repos.intel.com/python/conda/
Issue description
Installing tensorflow via pypi causes a newer version of numpy to be installed on top of the existing numpy package installed via conda. Interestingly, this only seems to happen when using Intel's conda channel. If I omit Intel's channel from the pixi.toml file, it results in the expected behavior.
Expected behavior
There should only be one version of numpy installed, and it should obey the version constraint of 1.26.*.
Experiencing similar behavior with networkx.
This is most likely caused by the pypi mapping not being available for packages from that channel. Pixi then doesnt know about which pypi package is installed by a conda package. This then results in conda packages being overwritten by pypi packages.
The solution is to add a custom mapping for packages from the intel channel. See https://pixi.sh/latest/reference/pixi_manifest/#conda-pypi-map-optional
This is most likely caused by the pypi mapping not being available for packages from that channel. Pixi then doesnt know about which pypi package is installed by a conda package. This then results in conda packages being overwritten by pypi packages.The solution is to add a custom mapping for packages from the intel channel. See https://pixi.sh/latest/reference/pixi_manifest/#conda-pypi-map-optional
Yep, that fixed it:
# cat pixi.toml
[workspace]
channels = ["https://software.repos.intel.com/python/conda", "conda-forge"]
name = "example"
platforms = ["linux-64"]
conda-pypi-map = { "https://software.repos.intel.com/python/conda" = "intel-mapping.json" }
[tasks]
[dependencies]
numpy = "1.26.*"
python = "3.11.*"
[pypi-dependencies]
tensorflow = "~=2.18.1"
# cat intel-mapping.json
{
"numpy": "numpy"
}
# pixi install
✔ The default environment has been installed.
# pixi list | grep numpy
numpy 1.26.4 py311h689b997_11 6 KiB conda https://software.repos.intel.com/python/conda/
numpy-base 1.26.4 py311h23d403b_11 8.7 MiB conda https://software.repos.intel.com/python/conda/
Thanks @baszalmstra! Out of curiosity, is there an existing conda-forge mapping I can reference?
Glad that helped! Yeah for conda-forge (and some other channels) we have an automated process to extract the pypi mapping. The result can be found here: https://github.com/prefix-dev/parselmouth/tree/main/files/v0/conda-forge
Lovely, thanks again!
@baszalmstra / @nichmor shouldn't we use the package name as fallback?
We only do that for conda-forge where we are relatively sure that the names match. Weve had issues with this in the past. We could enable this behavior for other channels too, or we could add the intel channel to our automatic mapping.
Wdyt @nichmor ?
package name fallback is only enabled for conda-forge based channels.
As a proper solution, I would like to add intel channel to our automatic mapping.
lmk @baszalmstra
Following up on this one - consider this manifest:
[workspace]
channels = ["anaconda", "conda-forge"]
name = "conda-pypi-conflicts"
platforms = ["linux-64"]
version = "0.1.0"
[dependencies]
numpy = "1.26.*"
[pypi-dependencies]
torch = { version = "==2.4.1", index = "https://download.pytorch.org/whl/cu121" }
torchvision = { version = "==0.19.1", index = "https://download.pytorch.org/whl/cu121" }
Notice that anaconda comes before conda-forge - that's just for reproducing the issue.
Indeed, I get dual numpy
❯ pixi install
WARN These conda-packages will be overridden by pypi:
numpy-base
❯ pixi list numpy
Package Version Build Size Kind Source
numpy 1.26.4 py312h2809609_0 10.5 KiB conda https://conda.anaconda.org/anaconda/
numpy 2.2.6 55.1 MiB pypi numpy-2.2.6-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
numpy-base 1.26.4 py312he1a6c75_0 7.7 MiB conda https://conda.anaconda.org/anaconda/
In my real case, I have many internal channels that are used.
My question (or suggestion?) is whether one can use one mapping for multiple channels (without duplicating the conda-pypi-map entries for each channel)
@baszalmstra @nichmor would like to hear from you on that, thanks!