Skip to content

Commit daf227e

Browse files
pavelzwdelsner
andauthored
feat: Validate environment after injecting packages (#57)
* feat: Validate environment after injecting packages * Fix clippy * Add tests * Review * bump version --------- Co-authored-by: Daniel Elsner <[email protected]>
1 parent c84abb8 commit daf227e

12 files changed

+116
-8
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "pixi-pack"
33
description = "A command line tool to pack and unpack conda environments for easy sharing"
4-
version = "0.1.8"
4+
version = "0.2.0"
55
edition = "2021"
66

77
[features]

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ pixi-pack pack --inject local-package-1.0.0-hbefa133_0.conda --manifest-pack pix
131131
```
132132

133133
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.
134+
Before creating the pack, `pixi-pack` will ensure that the injected packages' dependencies and constraints are compatible with the packages in the environment.
134135

135136
### Unpacking without `pixi-pack`
136137

examples/webserver/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,8 @@ pixi-pack pack -e prod --platform win-64 --inject output/noarch/my-webserver-*.c
1212
> [!NOTE]
1313
> The files `my-webserver-0.1.0-pyh4616a5c_0.conda` and `my-webserver-0.1.0-pyh4616a5c_0.tar.bz2` are only for testing, in a real scenario it would be in the `output/noarch` directory generated by `rattler-build`.
1414
> They were generated using `rattler-build build -r recipe/recipe.yaml --package-format conda` and `rattler-build build -r recipe/recipe.yaml --package-format tar-bz2`.
15+
16+
## Failure for invalid dependencies/constraints
17+
18+
In case the recipe of the package is incompatible with the packed pixi environment, `pixi-pack` should raise a validation error.
19+
To generate the incompatible package, run `rattler-build build -r recipe/recipe-broken.yaml --package-format conda`.
96 Bytes
Binary file not shown.
196 Bytes
Binary file not shown.
6.44 KB
Binary file not shown.

examples/webserver/pixi.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ dev = "uvicorn my_project:app --reload"
88
start = "uvicorn my_project:app --host 0.0.0.0"
99

1010
[dependencies]
11-
fastapi = "*"
11+
fastapi = ">=0.111,<0.112"
1212
uvicorn = "*"
1313

1414
[feature.dev.dependencies]
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# yaml-language-server: $schema=https://raw.githubusercontent.com/prefix-dev/recipe-format/main/schema.json
2+
3+
package:
4+
name: my-webserver-broken
5+
version: "0.1.0"
6+
7+
source:
8+
path: ../
9+
10+
build:
11+
number: 0
12+
noarch: python
13+
script:
14+
- python -m pip install . --no-deps --ignore-installed -vv --no-build-isolation --disable-pip-version-check
15+
16+
requirements:
17+
host:
18+
- python >=3.12
19+
- pip
20+
- hatchling
21+
run:
22+
- python >=3.12
23+
- fastapi >=0.112
24+
run_constraints:
25+
- pydantic >=2,<3
26+
27+
tests:
28+
- python:
29+
imports:
30+
- my_webserver
31+
- package_contents:
32+
site_packages:
33+
- my_webserver/__init__.py

examples/webserver/recipe/recipe.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ requirements:
2121
run:
2222
- python >=3.12
2323
- fastapi
24+
run_constraints:
25+
- pydantic >=2,<3
2426

2527
tests:
2628
- python:

0 commit comments

Comments
 (0)