Conda & PyPI
Pixi is built on top of both the conda and PyPI ecosystems.
Conda is a cross-platform, cross-language package ecosystem that allows users to install packages and manage environments. It is widely used in the data science and machine learning community, but it is also used in other fields. It’s power comes from the fact that it always installs binary packages, meaning that it doesn’t need to compile anything. This makes the ecosystem very fast and easy to use.
PyPI is the Python Package Index, which is the main package index for Python packages. It is a much larger ecosystem than conda, especially because the boundary to upload packages is lower. This means that there are a lot of packages available, but it also means that the quality of the packages is not always as high as in the conda ecosystem.
Pixi can install packages from both ecosystems, but it uses a conda-first approach.
The simplified process is as follows:
- Resolve the conda dependencies.
- Map the conda packages to PyPI packages.
- Resolve the remaining PyPI dependencies.
Tool Comparison#
Here is a non-exhaustive comparison of the features of conda and PyPI ecosystems.
Feature | Conda | PyPI |
---|---|---|
Package format | Binary | Source & Binary (wheel) |
Package managers | conda , mamba , micromamba , pixi |
pip , poetry , uv , pdm , hatch , rye , pixi |
Environment management | conda , mamba , micromamba , pixi |
venv , virtualenv , pipenv , pyenv , uv , poetry , pixi |
Package building | conda-build , pixi |
setuptools , poetry , flit , hatch , uv , rye |
Package index | conda-forge , bioconda , and more |
pypi.org |
uv
by Astral#
Pixi uses the uv
library to handle PyPI packages.
Pixi doesn't install uv
the tool itself, because both tools are build in Rust it is used as a library.
We're extremely grateful to the Astral team for their work on uv
, which is a great library that allows us to handle PyPI packages in a much better way than before.
Initially, next to pixi
were building a library called rip
which had the same goals as uv
, but we decided to switch to uv
because it quickly became a more mature library, and it has a lot of features that we need.
Solvers#
Because Pixi supports both ecosystems, it currently needs two different solvers to handle the dependencies.
- The
resolvo
library is used to solve the conda dependencies. Implemented inrattler
. - The
PubGrub
library is used to solve the PyPI dependencies. Implemented inuv
.
Note
The holy grail of Pixi is to have a single solver that can handle both ecosystems. Because resolvo is written to support both ecosystems, it is possible to use it for PyPI packages as well, but this is not yet implemented.
Because of these two solvers, we need to make a decision which solver to run first. This is the conda-first approach, which means that we first solve the conda dependencies and then the PyPI dependencies.
Pixi first run the conda (rattler
) solver, which will resolve the conda dependencies.
Then it maps the conda packages to PyPI packages, using parselmouth
Then it runs the PyPI (uv
) solver, which will resolve the remaining PyPI dependencies.
The consequence is that Pixi will install the conda
package if both are available.
Here is an example of how this works in practice:
Which results in the following output:
➜ pixi list -x
Package Version Build Size Kind Source
numpy 2.3.1 43.8 MiB pypi numpy-2.3.1-cp313-cp313-macosx_11_0_arm64.whl
python 3.13.5 hf3f3da0_102_cp313 12.3 MiB conda https://conda.anaconda.org/conda-forge/
In this example, Pixi will first resolve the conda dependencies and install the numpy
and python
conda packages.
Then it will map the numpy
conda package to the numpy
PyPI package and resolve the remaining PyPI dependencies.
Which is non as it was already installed as a conda package. Thus, no additional PyPI packages will be installed.
Another example is when you have a PyPI package that is not available as a conda package:
Which results in the following output:> pixi list --explicit
Package Version Build Size Kind Source
numpy 2.3.1 43.8 MiB pypi numpy-2.3.1-cp313-cp313-macosx_11_0_arm64.whl
python 3.13.5 hf3f3da0_102_cp313 12.3 MiB conda https://conda.anaconda.org/conda-forge/
python
conda package.
Then since numpy
is not available as a conda package, it will resolve the PyPI dependencies and install the numpy
PyPI package.
To override or change the mapping of conda packages to PyPI packages, you can use the conda-pypi-map
field in the pixi.toml
file.