Skip to content

Commit 0867db5

Browse files
committed
Merge branch 'main' into add-tests
2 parents 9f36fcd + dc301c4 commit 0867db5

File tree

3 files changed

+137
-7
lines changed

3 files changed

+137
-7
lines changed

.pre-commit-config.yaml

+4-6
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,14 @@ repos:
3333
types: [text]
3434
require_serial: true
3535
# cargo fmt and clippy
36-
- id: cargo-fmt-conda
37-
name: cargo-fmt-conda
38-
description: "Run `cargo fmt` for formatting rust sources."
36+
- id: cargo-fmt
37+
name: cargo-fmt
3938
entry: pixi run -e default cargo fmt --
4039
language: system
4140
require_serial: false
4241
types: [rust]
43-
- id: clippy-conda
44-
name: clippy-conda
45-
description: "Run `clippy` to lint rust sources."
42+
- id: cargo-clippy
43+
name: cargo-clippy
4644
entry: pixi run -e default cargo clippy --all-targets --all-features --workspace -- -D warnings
4745
pass_filenames: false
4846
language: system

LICENSE

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Copyright 2023 QuantCo Inc., Pavel Zwerschke, Daniel Elsner, Bela Stoyan
2+
3+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
4+
5+
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
6+
7+
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8+
9+
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
10+
11+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

README.md

+122-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,122 @@
1-
# `pixi-pack` 📦
1+
# `pixi-pack`
2+
3+
<br />
4+
<p align="center">
5+
<h3 align="center">📦 A tool to pack and unpack conda environments created with pixi</h3>
6+
</p>
7+
8+
## 🗂 Table of Contents
9+
10+
- [Introduction](#-introduction)
11+
- [Installation](#-installation)
12+
- [Usage](#-usage)
13+
14+
## 📖 Introduction
15+
16+
Starting with a [pixi](https://pixi.sh) lockfile `pixi.lock`, you can create a packed environment that can be shared with others.
17+
This environment can be unpacked on any system using `pixi-pack` to recreate the original environment.
18+
19+
In contrast to [`conda-pack`](https://conda.github.io/conda-pack/), `pixi-pack` does not require the original conda environment to be present on the system for packing.
20+
Instead, it uses the lockfile to download the required packages and puts them into a `.tar.zstd` archive.
21+
This archive can then be shared with others and installed using `pixi-pack unpack` to recreate the original environment.
22+
23+
The original motivation behind `pixi-pack` was to create a `conda-pack` alternative that does not have the same reproducibility issues as `conda-pack`.
24+
It also aims to allow cross-platform building packs, so you can create a pack for `win-64` on a `linux-64` system.
25+
26+
## 💿 Installation
27+
28+
You can install `pixi-pack` using `pixi`:
29+
30+
```bash
31+
pixi global install pixi-pack
32+
```
33+
34+
Or using `cargo`:
35+
36+
```bash
37+
cargo install --locked --git https://github.com/quantco/pixi-pack.git
38+
```
39+
40+
## 🎯 Usage
41+
42+
### `pixi-pack pack`: Packing an environment
43+
44+
With `pixi-pack pack`, you can pack a conda environment into a `environment.tar.zstd` file:
45+
46+
```bash
47+
pixi-pack pack --manifest-file pixi.toml --environment prod --platform linux-64
48+
```
49+
50+
This will create a `environment.tar.zstd` file that contains all conda packages required to create the environment.
51+
52+
```
53+
# environment.tar.zstd
54+
| pixi-pack.json
55+
| environment.yml
56+
| channel
57+
| ├── noarch
58+
| | ├── tzdata-2024a-h0c530f3_0.conda
59+
| | ├── ...
60+
| | └── repodata.json
61+
| └── linux-64
62+
| ├── ca-certificates-2024.2.2-hbcca054_0.conda
63+
| ├── ...
64+
| └── repodata.json
65+
```
66+
67+
### `pixi-pack unpack`: Unpacking an environment
68+
69+
With `pixi-pack unpack environment.tar.zstd`, you can unpack the environment on your target system.
70+
This will create a new conda environment in `./env` that contains all packages specified in your `pixi.toml`.
71+
It also creates an `activate.sh` (or `activate.bat` on Windows) file that lets you activate the environment
72+
without needing to have `conda` or `micromamba` installed.
73+
74+
```bash
75+
$ pixi-pack unpack environment.tar.zstd
76+
$ ls
77+
env/
78+
activate.sh
79+
environment.tar.zstd
80+
$ cat activate.sh
81+
export PATH="/home/user/project/env/bin:..."
82+
export CONDA_PREFIX="/home/user/project/env"
83+
. "/home/user/project/env/etc/conda/activate.d/activate_custom_package.sh"
84+
```
85+
86+
### Cross-platform packs
87+
88+
Since `pixi-pack` just downloads the `.conda` and `.tar.bz2` files from the conda repositories, you can trivially create packs for different platforms.
89+
90+
```bash
91+
pixi-pack pack --platform win-64
92+
```
93+
94+
> [!NOTE]
95+
> You can only `unpack` a pack on a system that has the same platform as the pack was created for.
96+
97+
### Inject additional packages
98+
99+
You can inject additional packages into the environment that are not specified in `pixi.lock` by using the `--inject` flag:
100+
101+
```bash
102+
pixi-pack pack --inject local-package-1.0.0-hbefa133_0.conda --manifest-pack pixi.toml
103+
```
104+
105+
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.
106+
107+
### Unpacking without `pixi-pack`
108+
109+
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.
110+
Just decompress the `environment.tar.zstd`, then you have a local channel on your system where all necessary packages are available.
111+
Next to this local channel, you will find an `environment.yml` file that contains the environment specification.
112+
You can then install the environment using `conda` or `micromamba`:
113+
114+
```bash
115+
tar --zstd -xvf environment.tar.zstd
116+
micromamba create -p ./env --file environment.yml --override-channels -c "file://$(pwd)/channel"
117+
# or
118+
conda create -p ./env --file environment.yml --override-channels -c "file://$(pwd)/channel"
119+
```
120+
121+
> [!NOTE]
122+
> The `environment.yml` and `repodata.json` files are only for this use case, `pixi-pack unpack` does not use them.

0 commit comments

Comments
 (0)