Skip to content

Latest commit

 

History

History
69 lines (45 loc) · 2.91 KB

File metadata and controls

69 lines (45 loc) · 2.91 KB

Experimenting with pixi

Tested with pixi 0.62.1.

Seems really fast to install packages and it seems to integrate the python environment with VS Code just fine.

Keep in mind most of the pixi management process is automated with high level commands. Adding/removing packages via the cli auto-updates the .toml file.

After further testing, I believe one of pixi's greatest assets is it's interoperability with pip. I was able to use pixi on a repo that used pip, venv, and pyproject.toml. I simply applied pixi init and it just added a few more lines to the original pyproject.toml without making breaking changes to the structure. I could install to the venv with pip install . as well as pixi shell which is a huge benefit for existing pip python projects.

Useful commands

Install with: curl -fsSL https://pixi.sh/install.sh | sh

This creates a whole directory with a pyproject.toml file. pixi init pixi_hello_world --format pyproject

Similar, to python venv -m python3.x you can specify python versions for your virtual environment like this

cd pixi_project
pixi add python==3.11.0
python -V # should confirm that it's correct

# Switch to latest
pixi add python
python -V
# Pretty impressive how fast it is and how easily you can switch between them

Enter your virtual environment by entering a directory with a pixi.toml or pyproject.toml or specifying the location to the toml file

cd pixi_project
pixi shell

# Or
pixi shell --manifest-path /path/to/your/project/<pixi/pyproject>.toml

You can see the current list of installed packages in the virtual env for that project by cd'-ing in the directory and running pixi list or by specifying the pixi or pyproject.toml from elsewhere

cd pixi_project
pixi list

# Or
pixi list --manifest-file /path/to/your/project/<pixi/pyproject>.toml

You can add dependencies to the pixi venv with cd'ing to a directory with a pixi or pyproject.toml and then install them like you would with pip

# either enter the pixi shell to activate the environment
pixi shell

pixi add numpy scipy loguru matplotlib tqdm

# Remove them the same way
pixi remove numpy scipy loguru matplotlib tqdm

If the package still appears in the pixi list despite removing it, it's because another package is using it as a transitive dependency. Transitive dependencies, I think, are not highlighted in the pixi list whereas properly trued installed packages are.

pixi clean <cache> will delete all of the installed packages in physically in .pixi directories but will not remove it from the pyproject.toml.

Other Notes

The pyproject.toml is the source of truth for packages. If you clean the env, and pixi install it will rebuild the lock file and reinstall the packages that have been added in pyproject.toml. To truly remove a package from the venv, remove it manually from pyproject.toml or use pixi remove which updates the .toml