Git Product home page Git Product logo

pixi-pack's Introduction

banner banner

License CI Status Conda Platform Project Chat Pixi Badge

pixi-pack demo pixi-pack demo

πŸ—‚ Table of Contents

πŸ“– Introduction

Starting with a pixi lockfile pixi.lock, you can create a packed environment that can be shared with others. This environment can be unpacked on any system using pixi-pack to recreate the original environment.

In contrast to conda-pack, pixi-pack does not require the original conda environment to be present on the system for packing. Instead, it uses the lockfile to download the required packages and puts them into a .tar archive. This archive can then be shared with others and installed using pixi-pack unpack to recreate the original environment.

The original motivation behind pixi-pack was to create a conda-pack alternative that does not have the same reproducibility issues as conda-pack. It also aims to allow cross-platform building packs, so you can create a pack for win-64 on a linux-64 system.

πŸ’Ώ Installation

You can install pixi-pack using pixi:

pixi global install pixi-pack

Or using cargo:

cargo install --locked --git https://github.com/quantco/pixi-pack.git

Or by downloading our pre-built binaries from the releases page.

Instead of installing pixi-pack globally, you can also use pixi exec to run pixi-pack in a temporary environment:

pixi exec pixi-pack pack
pixi exec pixi-pack unpack environment.tar

🎯 Usage

pixi-pack pack: Packing an environment

With pixi-pack pack, you can pack a conda environment into a environment.tar file:

pixi-pack pack --manifest-file pixi.toml --environment prod --platform linux-64

This will create a environment.tar file that contains all conda packages required to create the environment.

# environment.tar
| pixi-pack.json
| environment.yml
| channel
|    β”œβ”€β”€ noarch
|    |    β”œβ”€β”€ tzdata-2024a-h0c530f3_0.conda
|    |    β”œβ”€β”€ ...
|    |    └── repodata.json
|    └── linux-64
|         β”œβ”€β”€ ca-certificates-2024.2.2-hbcca054_0.conda
|         β”œβ”€β”€ ...
|         └── repodata.json

pixi-pack unpack: Unpacking an environment

With pixi-pack unpack environment.tar, you can unpack the environment on your target system. This will create a new conda environment in ./env that contains all packages specified in your pixi.toml. It also creates an activate.sh (or activate.bat on Windows) file that lets you activate the environment without needing to have conda or micromamba installed.

$ pixi-pack unpack environment.tar
$ ls
env/
activate.sh
environment.tar
$ cat activate.sh
export PATH="/home/user/project/env/bin:..."
export CONDA_PREFIX="/home/user/project/env"
. "/home/user/project/env/etc/conda/activate.d/activate_custom_package.sh"

Cross-platform packs

Since pixi-pack just downloads the .conda and .tar.bz2 files from the conda repositories, you can trivially create packs for different platforms.

pixi-pack pack --platform win-64

Note

You can only unpack a pack on a system that has the same platform as the pack was created for.

Inject additional packages

You can inject additional packages into the environment that are not specified in pixi.lock by using the --inject flag:

pixi-pack pack --inject local-package-1.0.0-hbefa133_0.conda --manifest-pack pixi.toml

This can be particularly useful if you build the project itself and want to include the built package in the environment but still want to use pixi.lock from the project.

Unpacking without pixi-pack

If you don't have pixi-pack available on your target system, you can still install the environment if you have conda or micromamba available. Just unarchive the environment.tar, then you have a local channel on your system where all necessary packages are available. Next to this local channel, you will find an environment.yml file that contains the environment specification. You can then install the environment using conda or micromamba:

tar -xvf environment.tar
micromamba create -p ./env --file environment.yml
# or
conda env create -p ./env --file environment.yml

Note

The environment.yml and repodata.json files are only for this use case, pixi-pack unpack does not use them.

pixi-pack's People

Contributors

pavelzw avatar 0xbe7a avatar delsner avatar dependabot[bot] avatar quant-ranger[bot] avatar

Stargazers

ChrisliebΓ€r avatar Yury Gorishniy avatar  avatar Pablo Vela avatar Jamie C avatar Travis Hathaway avatar FloLangenfeld avatar Vishal avatar Gregory Power avatar Marnix avatar Joeri van Engelen avatar  avatar Bas Zalmstra avatar Ruben Arts avatar Sandalots avatar Silvio Traversaro avatar Wes Turner avatar Tony Fast avatar Moritz Wilksch avatar Tim Paine avatar Ignacio Vergara Kausel avatar  avatar  avatar

Watchers

Lucian avatar Uwe L. Korn avatar Jan Tilly avatar  avatar Jan Jagusch avatar

Forkers

prsabahrami

pixi-pack's Issues

pixi-pack doesn't fail when downloading packages that return 401

When downloading packages from protected channels, pixi-pack just puts the http response in the corresponding file which can lead to .tar.bz2 or .conda files that just have

{"detail":"Not logged in"}

in their contents.

It should fail in these cases instead.

`pixi-pack` writes outdated `repodata.json` that doesn't include repodata patches

error message and environment.yml

image

Currently, pixi-pack uses the package metadata and rattler_index::index(&channel_dir, None) to generate the repodata.json.

entry in repodata.json generated by pixi-pack

image

This is not the same repodata.json (i mean the corresponding subset) of the upstream repodata.json if there were repodata patches.

repodata patched that lead to this error

image

We can generate an up-to-date patched repodata.json from pixi.lock

"repodata-like" entry in pixi.lock that we can use to generate the fixed repodata.json

image


We should include a test that rattler can solve the environment.yml as well.

We can use

name: python
version: 3.12.3
build: h2628c8c_0_cpython
subdir: win-64
url: https://conda.anaconda.org/conda-forge/win-64/python-3.12.3-h2628c8c_0_cpython.conda
sha256: 1a95494abe572a8819c933f978df89f00bde72ea9432d46a70632599e8029ea4
md5: f07c8c5dd98767f9a652de5d039b284e
depends:
- bzip2 >=1.0.8,<2.0a0
- libexpat >=2.6.2,<3.0a0
- libffi >=3.4,<4.0a0
- libsqlite >=3.45.2,<4.0a0
- libzlib >=1.2.13,<2.0.0a0
as an example where repodata patches occured.

Allow to `pixi-pack pack` conda prefixes

Instead of reading pixi.lock, we could provide another frontend to also create a pack from a conda prefix (or actually solve it from an environment.yml, but I'm not sure about that yet).

pixi-pack pack --prefix /path/to/conda-env could read the conda-meta folder and gather the exact packages from there

Self-extracting files

It would be interesting to explore self-extracting files as an optional feature similar to how conda-constructor does it.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.