mirror of
https://github.com/astral-sh/uv
synced 2026-01-23 14:30:14 -05:00
Add a `--compile` option to `pip install` and `pip sync`. I chose to implement this as a separate pass over the entire venv. If we wanted to compile during installation, we'd have to make sure that writing is exclusive, to avoid concurrent processes writing broken `.pyc` files. Additionally, this ensures that the entire site-packages are bytecode compiled, even if there are packages that aren't from this `uv` invocation. The disadvantage is that we do not update RECORD and rely on this comment from [PEP 491](https://peps.python.org/pep-0491/): > Uninstallers should be smart enough to remove .pyc even if it is not mentioned in RECORD. If this is a problem we can change it to run during installation and write RECORD entries. Internally, this is implemented as an async work-stealing subprocess worker pool. The producer is a directory traversal over site-packages, sending each `.py` file to a bounded async FIFO queue/channel. Each worker has a long-running python process. It pops the queue to get a single path (or exists if the channel is closed), then sends it to stdin, waits until it's informed that the compilation is done through a line on stdout, and repeat. This is fast, e.g. installing `jupyter plotly` on Python 3.12 it processes 15876 files in 319ms with 32 threads (vs. 3.8s with a single core). The python processes internally calls `compileall.compile_file`, the same as pip. Like pip, we ignore and silence all compilation errors (https://github.com/astral-sh/uv/issues/1559). There is a 10s timeout to handle the case when the workers got stuck. For the reviewers, please check if i missed any spots where we could deadlock, this is the hardest part of this PR. I've added `uv-dev compile <dir>` and `uv-dev clear-compile <dir>` commands, mainly for my own benchmarking. I don't want to expose them in `uv`, they almost certainly not the correct workflow and we don't want to support them. Fixes #1788 Closes #1559 Closes #1928
72 lines
2.6 KiB
TOML
72 lines
2.6 KiB
TOML
[package]
|
|
name = "uv-dev"
|
|
version = "0.0.1"
|
|
description = "Build wheels from source distributions"
|
|
publish = false
|
|
|
|
edition = { workspace = true }
|
|
rust-version = { workspace = true }
|
|
homepage = { workspace = true }
|
|
documentation = { workspace = true }
|
|
repository = { workspace = true }
|
|
authors = { workspace = true }
|
|
license = { workspace = true }
|
|
|
|
[lints]
|
|
workspace = true
|
|
|
|
[dependencies]
|
|
distribution-filename = { path = "../distribution-filename" }
|
|
distribution-types = { path = "../distribution-types" }
|
|
install-wheel-rs = { path = "../install-wheel-rs" }
|
|
pep440_rs = { path = "../pep440-rs" }
|
|
pep508_rs = { path = "../pep508-rs" }
|
|
platform-host = { path = "../platform-host" }
|
|
platform-tags = { path = "../platform-tags" }
|
|
pypi-types = { path = "../pypi-types" }
|
|
uv-build = { path = "../uv-build" }
|
|
uv-cache = { path = "../uv-cache", features = ["clap"] }
|
|
uv-client = { path = "../uv-client" }
|
|
uv-dispatch = { path = "../uv-dispatch" }
|
|
uv-distribution = { path = "../uv-distribution" }
|
|
uv-installer = { path = "../uv-installer" }
|
|
uv-interpreter = { path = "../uv-interpreter" }
|
|
uv-normalize = { path = "../uv-normalize" }
|
|
uv-resolver = { path = "../uv-resolver" }
|
|
uv-traits = { path = "../uv-traits" }
|
|
uv-virtualenv = { path = "../uv-virtualenv" }
|
|
|
|
# Any dependencies that are exclusively used in `uv-dev` should be listed as non-workspace
|
|
# dependencies, to ensure that we're forced to think twice before including them in other crates.
|
|
anstream = { workspace = true }
|
|
anyhow = { workspace = true }
|
|
chrono = { workspace = true }
|
|
clap = { workspace = true, features = ["derive"] }
|
|
fs-err = { workspace = true, features = ["tokio"] }
|
|
futures = { workspace = true }
|
|
indicatif = { workspace = true }
|
|
itertools = { workspace = true }
|
|
owo-colors = { workspace = true }
|
|
petgraph = { workspace = true }
|
|
poloto = { version = "19.1.2" }
|
|
resvg = { version = "0.29.0" }
|
|
rustc-hash = { workspace = true }
|
|
serde = { workspace = true }
|
|
serde_json = { workspace = true }
|
|
tagu = { version = "0.1.6" }
|
|
tempfile = { workspace = true }
|
|
tokio = { workspace = true }
|
|
tracing = { workspace = true }
|
|
tracing-durations-export = { workspace = true, features = ["plot"] }
|
|
tracing-indicatif = { workspace = true }
|
|
tracing-subscriber = { workspace = true }
|
|
url = { workspace = true }
|
|
walkdir = { workspace = true }
|
|
which = { workspace = true }
|
|
|
|
[target.'cfg(target_os = "windows")'.dependencies]
|
|
mimalloc = { version = "0.1.39" }
|
|
|
|
[target.'cfg(all(not(target_os = "windows"), not(target_os = "openbsd"), any(target_arch = "x86_64", target_arch = "aarch64", target_arch = "powerpc64")))'.dependencies]
|
|
tikv-jemallocator = { version = "0.5.4" }
|