### Pixi Update Examples Source: https://pixi.prefix.dev/latest/reference/cli/pixi/update Provides practical examples of using the `pixi update` command with various options. These examples cover updating single or multiple packages, specifying manifest paths, targeting specific environments and platforms, performing dry runs, and skipping installations. ```bash pixi update numpy pixi update numpy pandas pixi update --manifest-path ~/myworkspace/pixi.toml numpy pixi update --environment lint python pixi update -e lint -e schema -e docs pre-commit pixi update --platform osx-arm64 mlx pixi update -p linux-64 -p osx-64 numpy pixi update --dry-run numpy pixi update --no-install boto3 ``` -------------------------------- ### Docker Example: Activate Pixi Environment without Pixi Executable Source: https://pixi.prefix.dev/latest/reference/cli/pixi/shell-hook An example use-case demonstrating how to integrate Pixi environment activation into a Docker container's startup scripts. This allows the environment to be activated upon container startup without needing the 'pixi' executable installed. ```bash #!/bin/bash # Generate and save the activation script pixi shell-hook --shell bash > /etc/profile.d/pixi.sh # Optionally remove the pixi executable if no longer needed # rm ~/.pixi/bin/pixi # Source the activation script to activate the environment in the current shell source /etc/profile.d/pixi.sh # Now you can run commands within the activated environment # For example: python your_script.py ``` -------------------------------- ### Install Package with Shortcut Support (Shell) Source: https://pixi.prefix.dev/latest/global_tools/manifest Installs a package globally that supports shortcut creation. Pixi automatically handles the creation of system shortcuts (e.g., in the start menu) if the package is marked for shortcut support. ```shell pixi global install mss ``` -------------------------------- ### Basic pixi install Usage Source: https://pixi.prefix.dev/latest/reference/cli/pixi/install Demonstrates the fundamental usage of the 'pixi install' command to install the default environment. This command updates the lockfile if necessary and installs all packages for the environment. ```bash pixi install ``` -------------------------------- ### Test C++ Package Build and Execution with Pixi Source: https://pixi.prefix.dev/latest/build/cpp Executes the 'start' task defined in pixi.toml to build the C++ package, install the Python bindings, and run a Python script that imports and uses the 'add' function. ```bash $ pixi run start 3 ``` -------------------------------- ### Install Keyring for PyPI Authentication Source: https://pixi.prefix.dev/latest/deployment/authentication Installs the keyring package for PyPI authentication. Additional flags can be used to install specific keyring backends for different artifact registries. ```bash pixi global install keyring ``` ```bash pixi global install keyring --with keyrings.google-artifact-registry-auth ``` ```bash pixi global install keyring --with keyrings.artifacts ``` ```bash pixi global install keyring --with keyrings.codeartifact ``` -------------------------------- ### Multi-stage Docker Build with Pixi Source: https://pixi.prefix.dev/latest/deployment/container This example demonstrates a multi-stage Docker build process for a Pixi package. It utilizes the `pixi-docker` image to install dependencies in a build stage and then copies the production environment and application code to a minimal production image. It also sets up an entrypoint script to activate the Pixi environment before running the application. ```dockerfile FROM ghcr.io/prefix-dev/pixi:0.41.4 AS build # copy source code, pixi.toml and pixi.lock to the container WORKDIR /app COPY . . # install dependencies to `/app/.pixi/envs/prod` # use `--locked` to ensure the lockfile is up to date with pixi.toml RUN pixi install --locked -e prod # create the shell-hook bash script to activate the environment RUN pixi shell-hook -e prod -s bash > /shell-hook RUN echo "#!/bin/bash" > /app/entrypoint.sh RUN cat /shell-hook >> /app/entrypoint.sh # extend the shell-hook script to run the command passed to the container RUN echo 'exec "$@"' >> /app/entrypoint.sh FROM ubuntu:24.04 AS production WORKDIR /app # only copy the production environment into prod container # please note that the "prefix" (path) needs to stay the same as in the build container COPY --from=build /app/.pixi/envs/prod /app/.pixi/envs/prod COPY --from=build --chmod=0755 /app/entrypoint.sh /app/entrypoint.sh # copy your project code into the container as well COPY ./my_project /app/my_project EXPOSE 8000 ENTRYPOINT [ "/app/entrypoint.sh" ] # run your app inside the pixi environment CMD [ "uvicorn", "my_project:app", "--host", "0.0.0.0" ] ``` -------------------------------- ### Add Pixi Tasks using CLI Source: https://pixi.prefix.dev/latest/workspace/advanced_tasks This example demonstrates how to add tasks to Pixi using the command-line interface. It shows adding a 'configure' task, a 'build' task that depends on 'configure', and a 'start' task that depends on 'build'. This approach is useful for setting up task pipelines. ```bash pixi task add configure "cmake -G Ninja -S . -B .build" pixi task add build "ninja -C .build" --depends-on configure pixi task add start ".build/bin/sdl_example" --depends-on build ``` -------------------------------- ### Pixi Self-Update Examples Source: https://pixi.prefix.dev/latest/reference/cli/pixi/self-update Provides practical examples of how to use the pixi self-update command. These examples show updating to the latest version and to a specific version. ```bash pixi self-update pixi self-update --version 0.46.0 ``` -------------------------------- ### Define Pixi Task for Testing C++ Package Source: https://pixi.prefix.dev/latest/build/advanced_cpp This TOML snippet defines a 'start' task within the `pixi.toml` file. This task executes a Python command to import the `cpp_math` package and call its `add` function, verifying the build and installation process. ```toml [tasks] start = "python -c 'import cpp_math as b; print(b.add(1, 2))'" ``` -------------------------------- ### pixi install Specific Environment Source: https://pixi.prefix.dev/latest/reference/cli/pixi/install Shows how to install a specific named environment using the '--environment' or '-e' flag. If no environment is specified, 'pixi install' defaults to the 'default' environment. ```bash pixi install --environment lint ``` ```bash pixi install -e lint ``` -------------------------------- ### Force Pixi installation architecture (Linux/macOS) Source: https://pixi.prefix.dev/latest/installation Installs a specific architecture version of Pixi on Linux or macOS using the installation script. This example forces the x86_64 architecture, useful for Apple Silicon Macs needing to run x86 binaries. ```shell curl -fsSL https://pixi.sh/install.sh | PIXI_ARCH=x86_64 bash ``` -------------------------------- ### Project Setup and Execution with Pixi Source: https://pixi.prefix.dev/latest/index Demonstrates the basic workflow of setting up a new project, adding Python, and running a simple Python command using Pixi. ```bash pixi init hello-world cd hello-world pixi add python pixi run python -c 'print("Hello World!")' ``` -------------------------------- ### Install Pixi using Homebrew Source: https://pixi.prefix.dev/latest/installation Installs Pixi on macOS and Linux systems that have Homebrew package manager installed. This is an alternative installation method recommended for Homebrew users. ```shell brew install pixi ``` -------------------------------- ### Initialize Pixi Project for Development Environments Source: https://pixi.prefix.dev/latest/tutorials/multi_environment This command sequence initializes a new Pixi project named 'production_project' and navigates into its directory. This serves as a starting point for setting up distinct development, testing, and production environments. ```bash pixi init production_project cd production_project ``` -------------------------------- ### Install and Run with Specific Environment Source: https://pixi.prefix.dev/latest/python/tutorial These commands demonstrate how to install dependencies for a specific environment ('test') and run a command ('pytest') within that environment. Omitting the environment name defaults to 'default'. ```bash pixi install --environment test pixi run --environment test pytest ``` -------------------------------- ### Install Pixi using Winget Source: https://pixi.prefix.dev/latest/installation Installs Pixi on Windows using the Windows Package Manager (winget). This command fetches Pixi from the winget repository and installs it. ```shell winget install prefix-dev.pixi ``` -------------------------------- ### List packages in 'test' environment (Pixi CLI) Source: https://pixi.prefix.dev/latest/python/tutorial Lists all installed packages in the 'test' environment, showing their versions, build details, sizes, kinds, and sources. This helps in understanding the exact composition of a specific environment. ```bash pixi list --explicit ``` -------------------------------- ### Remove Pixi Installation Directory Source: https://pixi.prefix.dev/latest/installation Deletes the global Pixi installation directory and its contents. This is a manual step as part of the uninstallation process. ```bash rm -r ~/.pixi ``` -------------------------------- ### Install Pixi using Scoop Source: https://pixi.prefix.dev/latest/installation Installs Pixi on Windows using the Scoop package manager. This command adds Pixi to your system via the Scoop repository. ```shell scoop install main/pixi ``` -------------------------------- ### Pixi pyproject.toml Configuration Example Source: https://pixi.prefix.dev/latest/python/tutorial An example of a `pyproject.toml` file generated by Pixi. It includes project metadata, build system configuration, Pixi workspace settings (channels, platforms), and PyPI dependencies. ```toml [project] dependencies = [] name = "pixi-py" requires-python = ">= 3.11" version = "0.1.0" [build-system] build-backend = "hatchling.build" requires = ["hatchling"] [tool.pixi.workspace] channels = ["conda-forge"] platforms = ["osx-arm64"] [tool.pixi.pypi-dependencies] pixi_py = { path = ".", editable = true } [tool.pixi.tasks] ``` -------------------------------- ### Configure Workspace to Use Keyring for PyPI Source: https://pixi.prefix.dev/latest/deployment/authentication Demonstrates how to set up keyring for PyPI authentication by storing credentials and configuring the Pixi manifest. This includes examples for generic, Google Artifact Registry, Azure DevOps, and AWS CodeArtifact registries. ```bash keyring set https://my-index/simple your_username # prompt will appear for your password ``` ```ini [pypi-options] index-url = "https://your_username@custom-registry.com/simple" ``` ```ini [pypi-options] extra-index-urls = ["https://oauth2accesstoken@-python.pkg.dev///simple"] ``` ```bash gcloud artifacts print-settings python --project= --repository= --location= ``` ```ini [pypi-options] extra-index-urls = ["https://VssSessionToken@pkgs.dev.azure.com/{organization}/{project}/_packaging/{feed}/pypi/simple/"] ``` ```ini [pypi-options] extra-index-urls = ["https://aws@-.d.codeartifact..amazonaws.com/pypi//simple/"] ``` -------------------------------- ### Set Pixi installation version (Linux/macOS) Source: https://pixi.prefix.dev/latest/installation Installs a specific version of Pixi on Linux or macOS using the installation script by setting the PIXI_VERSION environment variable. Replace 'v0.18.0' with the desired version tag. ```shell curl -fsSL https://pixi.sh/install.sh | PIXI_VERSION=v0.18.0 bash ``` -------------------------------- ### Install Multiple Pixi Environments using Matrix Strategy Source: https://pixi.prefix.dev/latest/integration/ci/github_actions Demonstrates how to use GitHub Actions matrix strategy to install and test different pixi environments ('py311', 'py312') in separate jobs. This is useful for ensuring compatibility across various configurations. ```yaml test: runs-on: ubuntu-latest strategy: matrix: environment: [py311, py312] steps: - uses: actions/checkout@v4 - uses: prefix-dev/setup-pixi@v0.9.4 with: environments: ${{ matrix.environment }} ``` -------------------------------- ### Install PyTorch from PyPI using pyproject.toml Source: https://pixi.prefix.dev/latest/python/pytorch This configuration achieves the same as the `pixi.toml` example but uses the `pyproject.toml` format. It defines PyTorch and Torchvision installations from PyPI with platform-specific settings. ```toml [project] name = "pytorch-pypi" # We need a python version that is compatible with pytorch requires-python = ">= 3.11,<3.13" [tool.pixi.workspace] channels = ["https://prefix.dev/conda-forge"] platforms = ["osx-arm64", "linux-64", "win-64"] [tool.pixi.pypi-dependencies] torch = { version = ">=2.5.1", index = "https://download.pytorch.org/whl/cu124" } torchvision = { version = ">=0.20.1", index = "https://download.pytorch.org/whl/cu124" } [tool.pixi.target.osx.pypi-dependencies] # OSX has no CUDA support so use the CPU here torch = { version = ">=2.5.1", index = "https://download.pytorch.org/whl/cpu" } torchvision = { version = ">=0.20.1", index = "https://download.pytorch.org/whl/cpu" } ``` -------------------------------- ### Pixi Install Script Automation Source: https://pixi.prefix.dev/latest/CHANGELOG Details the automation of the install script in `pixi.sh`, ensuring that the installation process is kept up-to-date. This contributes to a smoother and more reliable setup experience for users. ```bash # Example of how the install script might be updated automatically # This is an internal process and not directly invoked by the user. ``` -------------------------------- ### Pixi Search Examples Source: https://pixi.prefix.dev/latest/reference/cli/pixi/search Illustrates various ways to use the 'pixi search' command, including basic package searches, limiting results, searching specific channels and platforms, and filtering by version or build number. ```bash pixi search pixi pixi search --limit 30 "py*" # search in a different channel and for a specific platform pixi search -c robostack --platform linux-64 "*plotjuggler*" # search for a specific version of a package pixi search "rattler-build<=0.35.4" pixi search "rattler-build[build_number=h2d22210_0]" --platform linux-64 ``` -------------------------------- ### Set Pixi Version (PowerShell) Source: https://pixi.prefix.dev/latest/installation Sets a specific version of Pixi to be installed using PowerShell. This is achieved by setting the PIXI_VERSION environment variable before executing the installation script. ```powershell $env:PIXI_VERSION='v0.18.0'; powershell -ExecutionPolicy Bypass -Command "iwr -useb https://pixi.sh/install.ps1 | iex" ``` -------------------------------- ### Pixi Authentication Examples Source: https://pixi.prefix.dev/latest/deployment/authentication These examples demonstrate how to use the `pixi auth login` command with different authentication methods for various services. They cover logging into prefix.dev with a token, anaconda.org with a conda token, a basic HTTP secured server with username and password, and an S3 bucket using access keys and optionally a session token. ```bash # Login to prefix.dev: pixi auth login prefix.dev --token pfx_jj8WDzvnuTHEGdAhwRZMC1Ag8gSto8 # Login to anaconda.org: pixi auth login anaconda.org --conda-token xy-72b914cc-c105-4ec7-a969-ab21d23480ed # Login to a basic HTTP secured server: pixi auth login myserver.com --username user --password password # Login to an S3 bucket: pixi auth login s3://my-bucket --s3-access-key-id --s3-secret-access-key # if your key uses a session token, you can also use: pixi auth login s3://my-bucket --s3-access-key-id --s3-secret-access-key --s3-session-token ``` -------------------------------- ### Custom Pixi binary directory installation (Linux/macOS) Source: https://pixi.prefix.dev/latest/installation Installs Pixi on Linux or macOS with a custom binary directory and disables automatic PATH updates. This allows for a 'drop-in' installation where the user manages the PATH manually. ```shell curl -fsSL https://pixi.sh/install.sh | PIXI_BIN_DIR=/usr/local/bin PIXI_NO_PATH_UPDATE=1 bash ``` -------------------------------- ### List Pixi Environment Dependencies Source: https://pixi.prefix.dev/latest/tutorials/multi_environment This command displays the installed packages and their versions for different Pixi environments. The output demonstrates that due to the use of '--solve-group prod', the 'production', 'test', and 'default' environments share identical dependency versions, ensuring consistency. ```bash # Default environment Package Version Build Size Kind Source jupyterlab 4.3.4 pyhd8ed1ab_0 6.9 MiB conda jupyterlab numpy 2.2.1 py313ha4a2180_0 6.2 MiB conda numpy pytest 8.3.4 pyhd8ed1ab_1 253.1 KiB conda pytest python 3.13.1 h4f43103_105_cp313 12.3 MiB conda python Environment: test Package Version Build Size Kind Source numpy 2.2.1 py313ha4a2180_0 6.2 MiB conda numpy pytest 8.3.4 pyhd8ed1ab_1 253.1 KiB conda pytest python 3.13.1 h4f43103_105_cp313 12.3 MiB conda python Environment: production Package Version Build Size Kind Source numpy 2.2.1 py313ha4a2180_0 6.2 MiB conda numpy python 3.13.1 h4f43103_105_cp313 12.3 MiB conda python ``` -------------------------------- ### Install Pixi using wget (Linux/macOS) Source: https://pixi.prefix.dev/latest/installation Installs the latest version of Pixi on Linux and macOS using wget. This is an alternative if curl is not available. It performs the same actions as the curl installation: downloading, extracting, and updating the PATH. ```shell wget -qO- https://pixi.sh/install.sh | sh ``` -------------------------------- ### Pixi Task Alias Examples Source: https://pixi.prefix.dev/latest/reference/cli/pixi/task/alias Provides practical examples of using the 'pixi task alias' command. These examples illustrate how to create aliases for multiple tasks, specify platforms, and define simple aliases. ```bash pixi task alias test-all test-py test-cpp test-rust pixi task alias --platform linux-64 test test-linux pixi task alias moo cow ``` -------------------------------- ### Install a Global Tool with Pixi Source: https://pixi.prefix.dev/latest/switching_from/conda Installs the 'bat' command-line tool into a global isolated environment using Pixi. This is similar to `pipx` or `condax` for installing standalone binaries. ```bash pixi global install bat ``` -------------------------------- ### Initialize Pixi Workspace and Add Python Source: https://pixi.prefix.dev/latest/tutorials/multi_environment Initializes a new Pixi workspace and adds the Python package. This sets up the basic project structure and the default environment. ```bash pixi init workspace cd workspace pixi add python ``` -------------------------------- ### Install Pixi using PowerShell (Windows) Source: https://pixi.prefix.dev/latest/installation Installs the latest version of Pixi on Windows using PowerShell. This command downloads the installation script, executes it, and adds Pixi to the user's PATH. Requires PowerShell with ExecutionPolicy Bypass. ```powershell powershell -ExecutionPolicy Bypass -c "irm -useb https://pixi.sh/install.ps1 | iex" ``` -------------------------------- ### Install Global Pixi Environments Source: https://pixi.prefix.dev/latest/integration/ci/github_actions Configures the setup-pixi action to install specified global pixi environments, such as 'google-cloud-sdk' and 'keyring'. This is useful for installing necessary executables or tools required by pixi or your project. ```yaml - uses: prefix-dev/setup-pixi@v0.9.4 with: global-environments: | google-cloud-sdk keyring --with keyrings.google-artifactregistry-auth - run: | gcloud --version keyring --list-backends ``` -------------------------------- ### Update Pixi to the latest version Source: https://pixi.prefix.dev/latest/installation Updates the installed Pixi version to the latest available release using the built-in self-update command. This command should be used if Pixi was installed via the official script. ```shell pixi self-update ``` -------------------------------- ### Add PyPI Package with Optional Extras using Pixi Source: https://pixi.prefix.dev/latest/python/tutorial Adds the 'flask' package from PyPI, including the 'async' optional dependencies and specifying a version. This demonstrates how to handle packages with extras. ```bash pixi add "flask[async]==3.1.0" --pypi ``` -------------------------------- ### Add a Package with Pixi Source: https://pixi.prefix.dev/latest/switching_from/conda Installs the 'numpy' package into the current Pixi environment. This command is the direct equivalent of `conda install numpy`. ```bash pixi add numpy ``` -------------------------------- ### Install Pixi with Embedded Credentials (PowerShell) Source: https://pixi.prefix.dev/latest/installation Installs Pixi using PowerShell by embedding authentication credentials directly into the PIXI_DOWNLOAD_URL. The script automatically masks these credentials in output for security. This method is useful for private repositories when a .netrc file is not preferred. ```powershell $env:PIXI_DOWNLOAD_URL='https://username:token@private.example.com/pixi-latest.zip'; powershell -ExecutionPolicy Bypass -Command "iwr -useb https://pixi.sh/install.ps1 | iex" ``` -------------------------------- ### Install Pixi from source using Cargo Source: https://pixi.prefix.dev/latest/installation Installs Pixi by building it directly from its source code repository on GitHub using Cargo, Rust's package manager. This method is suitable for developers who want the latest changes or need to build from source. ```rust cargo install --locked --git https://github.com/prefix-dev/pixi.git pixi ``` -------------------------------- ### Global Tool Installation with Pixi Source: https://pixi.prefix.dev/latest/index Shows how to install multiple global tools simultaneously using a single Pixi command. ```bash pixi global install gh nvim ipython btop ripgrep ``` -------------------------------- ### Start pixi shell in locked mode Source: https://pixi.prefix.dev/latest/reference/cli/pixi/shell Starts a shell session in a pixi environment with the locked option. This checks if the lockfile is up-to-date with the manifest file before installing, aborting if it's not. ```bash pixi shell --locked ``` -------------------------------- ### pixi run with options Source: https://pixi.prefix.dev/latest/reference/cli/pixi/run Demonstrates running a pixi task with various options such as specifying the manifest path, using frozen or locked environments, and skipping dependencies. ```bash pixi run --manifest-path ~/myworkspace/pixi.toml python pixi run --frozen python pixi run --locked python pixi run --skip-deps task ``` -------------------------------- ### Install Pixi with .netrc Authentication (Bash) Source: https://pixi.prefix.dev/latest/installation Installs Pixi using a .netrc file for authentication with private repositories via curl. It supports using the default ~/.netrc or a custom path specified by the NETRC environment variable. The PIXI_DOWNLOAD_URL can be overridden for custom builds or mirrors. ```bash # Use the default ~/.netrc file curl -fsSL https://pixi.sh/install.sh | PIXI_DOWNLOAD_URL=https://private.example.com/pixi-latest.tar.gz bash ``` ```bash # Use a custom .netrc file curl -fsSL https://pixi.sh/install.sh | NETRC=/path/to/custom/.netrc PIXI_DOWNLOAD_URL=https://private.example.com/pixi-latest.tar.gz bash ``` -------------------------------- ### Complete pixi.toml Example with Dev Table Source: https://pixi.prefix.dev/latest/build/dev This is a full example of a `pixi.toml` file that includes the `[dev]` table. It demonstrates how to define workspace settings, build backend, build, host, and run dependencies, and tasks. It shows how the `[dev]` table allows the inclusion of development dependencies without explicitly defining them in the main dependencies section. ```toml [workspace] channels = ["https://prefix.dev/conda-forge"] platforms = ["linux-64", "win-64", "osx-64", "osx-arm64"] preview = ['pixi-build'] [package.build.backend] name = "pixi-build-rust" version = "0.4.*" [package.build-dependencies] cmake = "*" [package.host-dependencies] python = "*" [package.run-dependencies] bat = "*" [dev] dev-package = { path = "." } [dependencies] cargo-insta = "*" [tasks] build = "cargo build --release" start = "cargo run" test = "cargo test" ``` -------------------------------- ### Initialize Pixi Project with pyproject.toml Source: https://pixi.prefix.dev/latest/python/tutorial Initializes a new Pixi project named 'pixi-py' using the 'pyproject.toml' format. This command sets up the basic project structure and configuration file. ```bash pixi init pixi-py --format pyproject ``` -------------------------------- ### pixi tree Example Output Source: https://pixi.prefix.dev/latest/reference/cli/pixi/tree Provides an example of the output generated by the 'pixi tree' command, illustrating the hierarchical structure of dependencies, package versioning, and coloring conventions. ```text ➜ pixi tree ├── pre-commit v3.3.3 │ ├── cfgv v3.3.1 │ │ └── python v3.12.2 │ │ ├── bzip2 v1.0.8 │ │ ├── libexpat v2.6.2 │ │ ├── libffi v3.4.2 │ │ ├── libsqlite v3.45.2 │ │ │ └── libzlib v1.2.13 │ │ ├── libzlib v1.2.13 (*) │ │ ├── ncurses v6.4.20240210 │ │ ├── openssl v3.2.1 │ │ ├── readline v8.2 │ │ │ └── ncurses v6.4.20240210 (*) │ │ ├── tk v8.6.13 │ │ │ └── libzlib v1.2.13 (*) │ │ └── xz v5.2.6 │ ├── identify v2.5.35 │ │ └── python v3.12.2 (*) ... └── tbump v6.9.0 ... └── tomlkit v0.12.4 └── python v3.12.2 (*) ``` -------------------------------- ### Clean Pixi Environments in Workspace Source: https://pixi.prefix.dev/latest/installation Removes Pixi environments associated with a specific workspace. This is typically done before uninstalling or when managing project dependencies. ```bash cd path/to/workspace && pixi clean ``` -------------------------------- ### Control Pixi Install with --frozen or --locked Flags Source: https://pixi.prefix.dev/latest/integration/ci/github_actions Configures the `setup-pixi` action to run `pixi install --frozen` or `pixi install --locked` based on the `frozen` or `locked` input arguments. If neither is specified, it defaults to `--locked` if a `pixi.lock` file exists, otherwise it runs `pixi install`. ```yaml - uses: prefix-dev/setup-pixi@v0.9.4 with: locked: true # or frozen: true ``` -------------------------------- ### Clean Pixi Cache Source: https://pixi.prefix.dev/latest/installation Removes cached data managed by Pixi. This command helps free up disk space and can resolve issues related to corrupted caches. ```bash pixi clean cache ``` -------------------------------- ### Pixi Run Command Output Source: https://pixi.prefix.dev/latest/reference/environment_variables Shows the output of running the `start` task in Pixi, demonstrating that the `task.env` variable `APP_CONFIG` has the highest priority and is the one that gets used. ```bash pixi run start ``` -------------------------------- ### Basic pixi.toml Configuration for Mojo Backend Source: https://pixi.prefix.dev/latest/build/backends/pixi-build-mojo A minimal pixi.toml configuration demonstrating the use of the pixi-build-mojo backend. It includes workspace settings, package information, build backend specification, and dependency declarations. ```toml [workspace] authors = ["J. Doe "] platforms = ["linux-64"] preview = ["pixi-build"] channels = [ "https://prefix.dev/conda-forge", "https://conda.modular.com/max-nightly", "https://prefix.dev/modular-community" ] [package] name = "greetings" version = "0.1.0" [package.build] backend = { name = "pixi-build-mojo", version = "0.1.*" } [tasks] [package.host-dependencies] mojo-compiler = "=25.5.0" [package.build-dependencies] mojo-compiler = "=25.5.0" small_time = ">=25.4.1,<26" extramojo = ">=0.16.0,<0.17" [package.run-dependencies] mojo-compiler = "=25.5.0" [dependencies] # For running `mojo test` while developing add all dependencies under # `[package.build-dependencies]` here as well. greetings = { path = "." } ``` -------------------------------- ### Pixi Utility Commands Source: https://pixi.prefix.dev/latest/getting_started A collection of utility commands for debugging, managing configuration, and getting help with Pixi. These tools assist in understanding and maintaining your Pixi setup. ```bash pixi info pixi config pixi tree pixi list pixi clean pixi help pixi help pixi auth pixi search pixi completion ``` -------------------------------- ### Example pyproject.toml for Dependency Mapping Source: https://pixi.prefix.dev/latest/build/backends/pixi-build-python This example demonstrates a typical pyproject.toml file structure used by the Pixi Python backend. It includes project metadata like name, version, and dependencies, as well as build system requirements. The backend uses 'project.dependencies' for run dependencies and 'build-system.requires' for host dependencies. ```toml [project] name = "my-package" version = "1.0.0" dependencies = [ "requests>=2.28", "pydantic>=2.0,<3.0", ] [build-system] requires = ["hatchling"] build-backend = "hatchling.build" ``` -------------------------------- ### Configure Fish Autocompletion for Pixi Source: https://pixi.prefix.dev/latest/installation Integrates Pixi command autocompletion into the Fish shell by sourcing the output of `pixi completion --shell fish` into the `~/.config/fish/config.fish` file. ```fish pixi completion --shell fish | source ``` -------------------------------- ### Download Pixi from Custom URL with Headers Source: https://pixi.prefix.dev/latest/integration/ci/github_actions Demonstrates how to download the Pixi binary from a custom URL using the `pixi-url` input. It also shows how to provide custom headers, such as an Authorization bearer token, via the `pixi-url-headers` input. This is useful for accessing private or mirrored Pixi releases. ```yaml - uses: prefix-dev/setup-pixi@v0.9.4 with: pixi-url: https://pixi-mirror.example.com/releases/download/v0.48.0/pixi-x86_64-unknown-linux-musl pixi-url-headers: '{"Authorization": "Bearer ${{ secrets.PIXI_MIRROR_BEARER_TOKEN }}"}' ``` -------------------------------- ### Configure PowerShell Autocompletion for Pixi Source: https://pixi.prefix.dev/latest/installation Enables Pixi command autocompletion in PowerShell by invoking the `pixi completion --shell powershell` command, capturing its output, and executing it. ```powershell (& pixi completion --shell powershell) | Out-String | Invoke-Expression ``` -------------------------------- ### Pixi Commands for Local Development and CI Source: https://pixi.prefix.dev/latest/workspace/multi_environment These commands illustrate how to run tasks and install dependencies for local development and continuous integration pipelines using Pixi. 'pixi run postinstall-e && pixi run test' is for CI, while 'pixi run postinstall-e && pixi run dev' is for local development. ```bash # In ci you would run the following commands: pixi run postinstall-e && pixi run test # Locally you would run the following command: pixi run postinstall-e && pixi run dev ``` -------------------------------- ### Build and test Pixi from source Source: https://pixi.prefix.dev/latest/installation Commands to build and test Pixi when working with its source code. This is typically used by developers contributing to Pixi or needing a custom build. ```rust cargo build cargo test ``` -------------------------------- ### Define Pixi Project Structure and Environments Source: https://pixi.prefix.dev/latest/integration/ci/github_actions A sample pixi.toml file defining project metadata, dependencies, and multiple named environments ('py311', 'py312'). This structure allows for managing different sets of dependencies for various use cases. ```toml [workspace] name = "my-package" channels = ["conda-forge"] platforms = ["linux-64"] [dependencies] python = ">=3.11" pip = "*" polars = ">=0.14.24,<0.21" [feature.py311.dependencies] python = "3.11.*" [feature.py312.dependencies] python = "3.12.*" [environments] py311 = ["py311"] py312 = ["py312"] ``` -------------------------------- ### Configure Run Dependencies in Pixi Source: https://pixi.prefix.dev/latest/reference/pixi_manifest Lists packages that are installed and required when the package is executed. This typically includes libraries and data files. Example includes 'rich' with version constraints. ```toml [package.run-dependencies] rich = ">=13.9.4,<14" ``` -------------------------------- ### Install Multiple Pixi Environments in a Single Job Source: https://pixi.prefix.dev/latest/integration/ci/github_actions Shows how to install multiple pixi environments ('py311', 'py312') within a single GitHub Actions job using the setup-pixi action. This is efficient when you need to run tests or tasks against several environments concurrently. ```yaml - uses: prefix-dev/setup-pixi@v0.9.4 with: environments: >- py311 py312 - run: | pixi run -e py311 test pixi run -e py312 test ``` -------------------------------- ### Run Pytest Version in 'test' Environment Source: https://pixi.prefix.dev/latest/tutorials/multi_environment Executes the 'pytest --version' command within the 'test' environment. This verifies the setup of the test environment and the installed 'pytest' package. ```bash pixi run --environment test pytest --version ``` -------------------------------- ### Configure Bash Autocompletion for Pixi Source: https://pixi.prefix.dev/latest/installation Adds Pixi command autocompletion to the Bash shell by evaluating the output of `pixi completion --shell bash` and appending it to the ~/.bashrc file. ```bash eval "$(pixi completion --shell bash)" ``` -------------------------------- ### Update Pixi to a specific version Source: https://pixi.prefix.dev/latest/installation Updates or downgrades Pixi to a specific version using the self-update command with the --version flag. Replace 'x.y.z' with the desired version number. ```shell pixi self-update --version x.y.z ``` -------------------------------- ### Configure Mojo Package for Pixi Build Source: https://pixi.prefix.dev/latest/build/backends/pixi-build-mojo Sets up the configuration for creating a Mojo package, which will be placed in the `$PREFIX/lib/mojo` directory. If not specified, the package can be auto-derived by searching for `__init__.mojo` or `__init__.🔥`. The name defaults to the project name, and the path defaults to the auto-derived directory. ```toml [package.build.config.pkg] name = "greetings" ``` ```toml [package.build.config.pkg] path = "greetings" ``` ```toml [package.build.config.pkg] extra-args = ["-I", "special-thing"] ``` -------------------------------- ### Pixi Breaking Change: depends_on to depends-on Source: https://pixi.prefix.dev/latest/CHANGELOG Illustrates a breaking change in Pixi where the 'depends_on' field has been renamed to 'depends-on' for consistency. The example shows the error message guiding the user to update their manifest. ```text Error: × field 'depends_on' is deprecated, 'depends-on' has replaced it ╭─[pixi.toml:22:51] 21 │ install = "cargo install --path . --locked" 22 │ install-as = { cmd = "python scripts/install.py", depends_on = [ · ─────┬──── · ╰── replace this with 'depends-on' 23 │ "build-release", ╰──── ``` -------------------------------- ### Pixi Global Update Examples Source: https://pixi.prefix.dev/latest/reference/cli/pixi/global/update Provides practical examples of how to use the pixi global update command, from a general update to updating specific environments. ```bash pixi global update pixi global update pixi-pack pixi global update bat rattler-build ``` -------------------------------- ### Configure Elvish Autocompletion for Pixi Source: https://pixi.prefix.dev/latest/installation Enables Pixi command autocompletion for the Elvish shell by evaluating the output of `pixi completion --shell elvish` and slurping it into the `~/.elvish/rc.elv` configuration file. ```elvish eval (pixi completion --shell elvish | slurp) ```