prefix-dev/pixi
GitHub: prefix-dev/pixi
基于 Conda 生态的跨平台多语言包管理器,提供类 Cargo 的开发工作流体验。
Stars: 6470 | Forks: 446
 [][chat-url] [![Pixi Badge][pixi-badge]][pixi-url]
# Pixi:让包管理变得简单 ## 概述 `pixi` 是一个跨平台、多语言的包管理器和工作流工具,构建于 conda 生态系统的基础之上。它为开发者提供了类似于 [`cargo`](https://doc.rust-lang.org/cargo/) 或 [`npm`](https://docs.npmjs.com) 等流行包管理器的卓越体验,但适用于任何语言。 由 [prefix.dev](https://prefix.dev) 团队用 ❤️ 开发。 [](https://asciinema.org/a/636482) ## 亮点 - 通过 Conda 包支持**多种语言**,包括 Python、C++ 和 R。您可以在 [prefix.dev](https://prefix.dev) 上找到可用的包。 - 兼容所有主流操作系统:Linux、Windows、macOS(包括 Apple Silicon)。 - 始终包含最新的 [**lock file**](https://pixi.sh/latest/workspace/lockfile/)。 - 提供简洁直观的类 Cargo **命令行界面**。 - 允许您**按项目**或**全局**安装工具。 - 完全使用 **Rust** 编写,并基于 **[rattler](https://github.com/conda/rattler)** 库构建。 ## 快速入门 - ⚡ [安装](#installation) - ⚙️ [示例](/examples) - 📚 [文档](https://pixi.sh/) - 😍 [贡献](#contributing) - 🔨 [使用 Pixi 构建](#built-using-pixi) - 🚀 [GitHub Action](https://github.com/prefix-dev/setup-pixi) ## 状态 Pixi 已准备好用于生产环境! 我们正在努力保持文件格式的更改与以前的版本兼容,以便您可以放心地依赖 Pixi。 我们为即将发布的版本设想的一些显著功能是: - 将您的项目**构建并发布**为 Conda 包。 - 支持**从源码安装依赖**。 - 更强大的包“全局安装”功能,以实现多台机器上全局包的确定性设置。 ## 安装 `pixi` 可以安装在 macOS、Linux 和 Windows 上。提供的脚本将自动下载最新版本的 `pixi`,将其解压,并将 `pixi` 二进制文件移动到 `~/.pixi/bin`。如果此目录不存在,脚本将创建它。 ### macOS 和 Linux 要在 macOS 和 Linux 上安装 Pixi,请打开终端并运行以下命令: ``` curl -fsSL https://pixi.sh/install.sh | sh # 或使用 brew brew install pixi ``` 该脚本还会更新您的 `~/.bashrc`,将 `~/.pixi/bin` 包含在您的 `PATH` 中,以便您可以从任何位置调用 `pixi` 命令。 您可能需要重启终端或重新加载 Shell 配置才能使更改生效。 从 macOS Catalina 开始,[zsh 是默认的登录 Shell 和交互式 Shell](https://support.apple.com/en-us/102360)。因此,您可能希望在安装命令中使用 `zsh` 而不是 `bash`: ``` curl -fsSL https://pixi.sh/install.sh | zsh ``` 该脚本还会更新您的 `~/.zshrc`,将 `~/.pixi/bin` 包含在您的 `PATH` 中,以便您可以从任何位置调用 `pixi` 命令。 ### Windows 要在 Windows 上安装 Pixi,请打开 PowerShell 终端(您可能需要以管理员身份运行)并运行以下命令: ``` powershell -ExecutionPolicy ByPass -c "irm -useb https://pixi.sh/install.ps1 | iex" ``` 更改 [执行策略](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_execution_policies?view=powershell-7.4#powershell-execution-policies) 允许运行来自互联网的脚本。 使用以下命令检查您将要运行的脚本: ``` powershell -c "irm -useb https://pixi.sh/install.ps1 | more" ``` 脚本会在安装成功后通知您,并将 `~/.pixi/bin` 目录添加到您的 `PATH` 中,这将允许您从任何位置运行 `pixi` 命令。 或者使用 `winget` ``` winget install prefix-dev.pixi ``` ### 自动补全 要获取自动补全功能,请按照您的 Shell 说明进行操作。 完成后,重启 Shell 或重新加载 Shell 配置文件。 #### Bash(大多数 Linux 系统上的默认 Shell) 将以下内容添加到 `~/.bashrc` 的末尾: ``` # ~/.bashrc eval "$(pixi completion --shell bash)" ``` #### Zsh(macOS 上的默认 Shell) 将以下内容添加到 `~/.zshrc` 的末尾: ``` # ~/.zshrc eval "$(pixi completion --shell zsh)" ``` #### PowerShell(所有 Windows 系统上预装) 将以下内容添加到 `Microsoft.PowerShell_profile.ps1` 的末尾。 您可以通过在 PowerShell 中查询 `$PROFILE` 变量来检查此文件的位置。 通常路径为 `~\Documents\PowerShell\Microsoft.PowerShell_profile.ps1` 或者在 -Nix 系统上为 `~/.config/powershell/Microsoft.PowerShell_profile.ps1`。 ``` (& pixi completion --shell powershell) | Out-String | Invoke-Expression ``` #### Fish 将以下内容添加到 `~/.config/fish/config.fish` 的末尾: ``` # ~/.config/fish/config.fish pixi completion --shell fish | source ``` #### Nushell 将以下内容添加到您的 Nushell 配置文件中(通过在 Nushell 中运行 `$nu.config-path` 找到它): ``` mkdir $"($nu.data-dir)/vendor/autoload" pixi completion --shell nushell | save --force $"($nu.data-dir)/vendor/autoload/pixi-completions.nu" ``` #### Elvish 将以下内容添加到 `~/.elvish/rc.elv` 的末尾: ``` # ~/.elvish/rc.elv eval (pixi completion --shell elvish | slurp) ``` ### 发行版软件包 [](https://repology.org/project/pixi/versions) #### Arch Linux 您可以使用 [pacman](https://wiki.archlinux.org/title/Pacman) 从 [extra 仓库](https://archlinux.org/packages/extra/x86_64/pixi/) 安装 `pixi`: ``` pacman -S pixi ``` #### Alpine Linux `pixi` 可在 [Alpine Edge](https://pkgs.alpinelinux.org/packages?name=pixi&branch=edge) 中获取。在启用 [testing 仓库](https://wiki.alpinelinux.org/wiki/Repositories) 后,可以通过 [apk](https://wiki.alpinelinux.org/wiki/Alpine_Package_Keeper) 安装。 ``` apk add pixi ``` ## 从源码构建/安装 `pixi` 100% 使用 Rust 编写,因此可以使用 cargo 进行安装、构建和测试。 要开始使用从源码构建的 `pixi`,请运行: ``` cargo install --locked --git https://github.com/prefix-dev/pixi.git pixi ``` 我们不再发布到 `crates.io`,因此您需要从仓库安装。 原因是我们要依赖一些未发布的 crate,这导致我们无法发布到 `crates.io`。 如果您通过这种方式安装 pixi,它不一定是 PATH 中的第一个。 通过安装脚本安装的版本可能具有更高的优先级。 因此,对于本地开发,我们建议改为运行以下任务: ``` pixi run install-as pixid ``` 这样,一个名为 `pixid` 的新二进制文件将可用,且不会与您系统上的其他 Pixi 安装发生名称冲突。 ## 卸载 要卸载,需要移除 Pixi 二进制文件。 从 `$PIXI_DIR`(默认为 `~/.pixi/bin/pixi`)中删除 `pixi` 在 Linux 上执行: ``` rm ~/.pixi/bin/pixi ``` 在 Windows 上执行: ``` $PIXI_BIN = "$Env:LocalAppData\pixi\bin\pixi"; Remove-Item -Path $PIXI_BIN ``` 执行此命令后,您仍然可以使用通过 `pixi` 安装的工具。 要同时移除这些工具,只需删除整个 `~/.pixi` 目录,并从您的路径中移除该目录。 # 用法 命令行界面(CLI)如下所示: ``` ➜ pixi Pixi [version 0.59.0] - Developer Workflow and Environment Management for Multi-Platform, Language-Agnostic Workspaces. Pixi is a versatile developer workflow tool designed to streamline the management of your workspace's dependencies, tasks, and environments. Built on top of the Conda ecosystem, Pixi offers seamless integration with the PyPI ecosystem. Basic Usage: Initialize pixi for a workspace: $ pixi init $ pixi add python numpy pytest Run a task: $ pixi task add test 'pytest -s' $ pixi run test Found a Bug or Have a Feature Request? Open an issue at: https://github.com/prefix-dev/pixi/issues Need Help? Ask a question on the Prefix Discord server: https://discord.gg/kKV8ZxyzY4 For more information, see the documentation at: https://pixi.sh Usage: pixi [OPTIONS] [COMMAND] Commands: add Adds dependencies to the workspace [aliases: a] auth Login to prefix.dev or anaconda.org servers to access private channels build Workspace configuration clean Cleanup the environments completion Generates a completion script for a shell config Configuration management exec Run a command and install it in a temporary environment [aliases: x] global Subcommand for global package management actions [aliases: g] info Information about the system, workspace and environments for the current machine init Creates a new workspace import Imports a file into an environment in an existing workspace. install Install an environment, both updating the lockfile and installing the environment [aliases: i] list List the packages of the current workspace [aliases: ls] lock Solve environment and update the lock file without installing the environments reinstall Re-install an environment, both updating the lockfile and re-installing the environment remove Removes dependencies from the workspace [aliases: rm] run Runs task in the pixi environment [aliases: r] search Search a conda package shell Start a shell in a pixi environment, run `exit` to leave the shell [aliases: s] shell-hook Print the pixi environment activation script task Interact with tasks in the workspace tree Show a tree of workspace dependencies [aliases: t] update The `update` command checks if there are newer versions of the dependencies and updates the `pixi.lock` file and environments accordingly upgrade Checks if there are newer versions of the dependencies and upgrades them in the lockfile and manifest file upload Upload a conda package workspace Modify the workspace configuration file through the command line help Print this message or the help of the given subcommand(s) Options: -V, --version Print version Global Options: -h, --help Display help information -v, --verbose... Increase logging verbosity (-v for warnings, -vv for info, -vvv for debug, -vvvv for trace) -q, --quiet... Decrease logging verbosity (quiet mode) --color标签:C++, Conda, DNS解析, LNA, Lockfile, pixi, prefix.dev, Python, Rust, R语言, 依赖管理, 包管理器, 可视化界面, 多语言支持, 威胁情报, 安全测试框架, 工作流, 开发者工具, 开源项目, 数据擦除, 无后门, 环境管理, 统一API, 网络流量审计, 软件供应链, 通知系统, 通知系统