跳到主要内容

pixi

安装

curl -fsSL https://pixi.sh/install.sh | sh or wget -qO- https://pixi.sh/install.sh | sh

autoload -Uz compinit && compinit  # redundant with Oh My Zsh
eval "$(pixi completion --shell zsh)"

卸载

pixi clean cache
cd path/to/workspace && pixi clean
rm -r ~/.pixi
# remove `~/.pixi/bin` from your `PATH` in your shell configuration file (e.g., `~/.bashrc`, `~/.zshrc`).

配置: https://pixi.sh/latest/reference/pixi_configuration/

概念

https://pixi.sh/latest/reference/pixi_manifest/

  • workspace | 工作区可包含多个环境. 支持两种清单格式:pyproject.tomlpixi.toml
  • environments | 环境是功能的集合. Pixi 始终为您的工作区创建一个 default 环境,其中包含您的依赖项并在其中运行您的任务。您还可以在一个工作区中包含多个环境 。这些环境位于工作区根目录的 .pixi/envs 目录中。环境由一个或多个功能构建。
  • feature
  • dependencies
  • tasks
  • activation
  • target
  • package
  • system-requirements
  • pypi-options

[!NOTE] Conda has a base environment, which is the default environment when you start a new shell. Pixi does not have a base environment. And requires you to install the tools you need in the workspace or globally. Using pixi global install bat will install bat in a global environment, which is not the same as the base environment in conda.

[!NOTE] Environment vs Workspace Conda and mamba focus on managing environments, while pixi emphasizes workspaces. In pixi, a workspace is a folder containing a manifest (pixi.toml / pyproject.toml) file that describes the workspace, a pixi.lock lock-file that describes the exact dependencies, and a .pixi folder that contains the environment.

This workspace-centric approach allows for easy sharing and collaboration, as the workspace folder contains all the necessary information to recreate the environment. It manages more than one environment for more than one platform in a single workspace, and allows for easy switching between them. (See multiple environments)

[!NOTE] Global environments conda installs all environments in one global location. When this is important to you for filesystem reasons, you can use the detached-environments feature of pixi.

pixi config set detached-environments true
# or a specific location
pixi config set detached-environments /path/to/envs

This doesn't allow you to activate the environments using pixi shell -n but it will make the installation of the environments go to the same folder.

pixi does have the pixi global command to install tools on your machine. (See global) This is not a replacement for conda but works the same as pipx and condax. It creates a single isolated environment for the given requirement and installs the binaries into the global path.

用法

https://pixi.sh/latest/getting_started/

命令描述
add向工作区添加依赖项
auth登录 prefix.dev 或 anaconda.org 服务器以访问私人频道
build工作区配置
clean清理环境
completion为 shell 生成完成脚本
config配置管理
exec运行命令并将其安装在临时环境中
global用于全局包管理作的子命令
info有关当前计算机的系统、工作区和环境的信息
init创建新工作区
import将文件导入到现有工作区中的环境中。
install安装环境,同时更新锁文件和安装环境
list列出工作区的包
lock在不安装环境的情况下解决环境并更新锁定文件
reinstall重新安装环境,更新锁文件和重新安装环境
remove从工作区中删除依赖项
run在 pixi 环境中运行任务
search搜索 conda 包
self-update将 pixi 更新到最新版本或特定版本
shell在 pixi 环境中启动 shell,运行 exit 离开 shell
shell-hook打印 pixi 环境激活脚本
task与工作区中的任务交互
tree显示工作区依赖项树
updateupdate 命令检查是否有较新版本的依赖项,并相应地更新 pixi.lock 文件和环境
upgrade检查是否有较新版本的依赖项,并在锁定文件和清单文件中升级它们
upload上传 conda 包
workspace通过命令行修改工作空间配置文件