An extremely fast Python package and project manager, written in Rust.
Find a file
konsti 71964ec7a8
Switch to msgpack in the cached client (#662)
This gives a 1.23 speedup on transformers-extras. We could change to
msgpack for the entire cache if we want. I only tried this format and
postcard so far, where postcard was much slower (like 1.6s).

I don't actually want to merge it like this, i wanted to figure out the
ballpark of improvement for switching away from json.

```
hyperfine --warmup 3 --runs 10 "target/profiling/puffin pip-compile --cache-dir cache-msgpack scripts/requirements/transformers-extras.in" "target/profiling/branch pip-compile scripts/requirements/transformers-extras.in"
Benchmark 1: target/profiling/puffin pip-compile --cache-dir cache-msgpack scripts/requirements/transformers-extras.in
  Time (mean ± σ):     179.1 ms ±   4.8 ms    [User: 157.5 ms, System: 48.1 ms]
  Range (min … max):   174.9 ms … 188.1 ms    10 runs

Benchmark 2: target/profiling/branch pip-compile scripts/requirements/transformers-extras.in
  Time (mean ± σ):     221.1 ms ±   6.7 ms    [User: 208.1 ms, System: 46.5 ms]
  Range (min … max):   213.5 ms … 235.5 ms    10 runs

Summary
  target/profiling/puffin pip-compile --cache-dir cache-msgpack scripts/requirements/transformers-extras.in ran
    1.23 ± 0.05 times faster than target/profiling/branch pip-compile scripts/requirements/transformers-extras.in
```

Disadvantage: We can't manually look into the cache anymore to debug
things

- [ ] Check more formats, i currently only tested json, msgpack and
postcard, there should be other formats, too
- [x] Switch over `CachedByTimestamp` serialization (for the interpreter
caching)
- [x] Switch over error handling and make sure puffin is still resilient
to cache failure
2023-12-16 21:01:35 +00:00
.github/workflows Filter out incompatible dists (#398) 2023-11-13 17:14:07 +01:00
crates Switch to msgpack in the cached client (#662) 2023-12-16 21:01:35 +00:00
scripts Add transformers extra requirements (#618) 2023-12-12 16:18:05 +00:00
workers/pypi-metadata Handle dist info casing mismatch in worker (#273) 2023-11-02 11:04:28 +00:00
.dockerignore Add docker builder (#238) 2023-11-02 12:03:56 +01:00
.gitignore Filter out incompatible dists (#398) 2023-11-13 17:14:07 +01:00
builder.dockerfile Add source to failing metadata parsing (#387) 2023-11-10 18:33:49 +00:00
Cargo.lock Switch to msgpack in the cached client (#662) 2023-12-16 21:01:35 +00:00
Cargo.toml Switch to msgpack in the cached client (#662) 2023-12-16 21:01:35 +00:00
CONTRIBUTING.md Add docker builder (#238) 2023-11-02 12:03:56 +01:00
LICENSE-APACHE Add README and LICENSE files 2023-10-05 12:45:38 -04:00
LICENSE-MIT Add README and LICENSE files 2023-10-05 12:45:38 -04:00
README.md Add support for path dependencies (#471) 2023-11-21 11:49:42 +00:00
ruff.toml Test requirements script (#382) 2023-11-17 18:26:55 +00:00
rust-toolchain.toml Use Clippy lint table over Cargo config (#490) 2023-11-22 15:10:27 +00:00

puffin

An experimental Python packaging tool.

Motivation

Puffin is an extremely fast (experimental) Python package resolver and installer, intended to replace pip and pip-tools (pip-compile and pip-sync).

Puffin itself is not a complete "package manager", but rather a tool for locking dependencies (similar to pip-compile) and installing them (similar to pip-sync). Puffin can be used to generate a set of locked dependencies from a requirements.txt file, and then install those locked dependencies into a virtual environment.

Puffin represents an intermediary goal in our pursuit of building a "Cargo for Python": a Python package manager that is extremely fast, reliable, and easy to use -- capable of replacing not only pip, but also pipx, pip-tools, virtualenv, tox, setuptools, and even pyenv, by way of managing the Python installation itself.

Puffin's limited scope allows us to solve many of the low-level problems that are required to build such a package manager (like package installation) while shipping an immediately useful tool with a minimal barrier to adoption. Try it today in lieu of pip and pip-tools.

Features

  • Extremely fast dependency resolution and installation: install dependencies in sub-second time.
  • Disk-space efficient: Puffin uses a global cache to deduplicate dependencies, and uses Copy-on-Write on supported filesystems to reduce disk usage.

Limitations

Puffin does not yet support:

  • Windows
  • Editable installs (pip install -e ...)
  • Package-less requirements (pip install https://...)
  • --find-links
  • ...

Like pip-compile, Puffin generates a platform-specific requirements.txt file (unlike, e.g., poetry, which generates a platform-agnostic poetry.lock file). As such, Puffin's requirements.txt files are not portable across platforms and Python versions.

Usage

To resolve a requirements.in file:

cargo run -p puffin-cli -- pip-compile requirements.in

To install from a resolved requirements.txt file:

cargo run -p puffin-cli -- pip-sync requirements.txt

For more, see cargo run -p puffin-cli -- --help:

Usage: puffin [OPTIONS] <COMMAND>

Commands:
  pip-compile    Compile a `requirements.in` file to a `requirements.txt` file
  pip-sync       Sync dependencies from a `requirements.txt` file
  pip-uninstall  Uninstall packages from the current environment
  clean          Clear the cache
  freeze         Enumerate the installed packages in the current environment
  venv           Create a virtual environment
  add            Add a dependency to the workspace
  remove         Remove a dependency from the workspace
  help           Print this message or the help of the given subcommand(s)

Options:
  -q, --quiet                  Do not print any output
  -v, --verbose                Use verbose output
  -n, --no-cache               Avoid reading from or writing to the cache
      --cache-dir <CACHE_DIR>  Path to the cache directory [env: PUFFIN_CACHE_DIR=]
  -h, --help                   Print help
  -V, --version                Print version

License

Puffin is licensed under either of

at your option.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in Puffin by you, as defined in the Apache-2.0 license, shall be dually licensed as above, without any additional terms or conditions.