![]() It looks like using _either_ async Rust with a `JoinSet` _or_ parallelizing a fixed threadpool with Rayon provide about a ~5% speed-up over our current serial approach: ```console ❯ hyperfine --runs 30 --warmup 5 --prepare "./target/release/puffin venv .venv" \ "./target/release/rayon sync ./scripts/benchmarks/requirements-large.txt" \ "./target/release/async sync ./scripts/benchmarks/requirements-large.txt" \ "./target/release/main sync ./scripts/benchmarks/requirements-large.txt" Benchmark 1: ./target/release/rayon sync ./scripts/benchmarks/requirements-large.txt Time (mean ± σ): 295.7 ms ± 16.9 ms [User: 28.6 ms, System: 263.3 ms] Range (min … max): 249.2 ms … 315.9 ms 30 runs Benchmark 2: ./target/release/async sync ./scripts/benchmarks/requirements-large.txt Time (mean ± σ): 296.2 ms ± 20.2 ms [User: 36.1 ms, System: 340.1 ms] Range (min … max): 258.0 ms … 359.4 ms 30 runs Benchmark 3: ./target/release/main sync ./scripts/benchmarks/requirements-large.txt Time (mean ± σ): 306.6 ms ± 19.5 ms [User: 25.3 ms, System: 220.5 ms] Range (min … max): 269.6 ms … 332.2 ms 30 runs Summary './target/release/rayon sync ./scripts/benchmarks/requirements-large.txt' ran 1.00 ± 0.09 times faster than './target/release/async sync ./scripts/benchmarks/requirements-large.txt' 1.04 ± 0.09 times faster than './target/release/main sync ./scripts/benchmarks/requirements-large.txt' ``` It's much easier to just parallelize with Rayon and avoid async in the underlying wheel code, so this PR takes that approach for now. |
||
---|---|---|
.cargo | ||
.github/workflows | ||
crates | ||
scripts/benchmarks | ||
.gitignore | ||
Cargo.lock | ||
Cargo.toml | ||
LICENSE-APACHE | ||
LICENSE-MIT | ||
README.md | ||
rust-toolchain.toml |
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:
- Source distributions
- VCS dependencies
- URL dependencies
- Uninstalling packages
- Windows
- ...
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 -- compile requirements.in
To install from a resolved requirements.txt
file:
cargo run -p puffin-cli -- sync requirements.txt
For more, see cargo run -p puffin-cli -- --help
:
Usage: puffin-cli <COMMAND>
Commands:
compile Compile a `requirements.in` file to a `requirements.txt` file
sync Sync dependencies from a `requirements.txt` file
clean Clear the cache
freeze Enumerate the installed packages in the current environment
help Print this message or the help of the given subcommand(s)
Options:
-h, --help Print help
-V, --version Print version
License
Puffin is licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or https://opensource.org/licenses/MIT)
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.