Skip to content

Commit 2f5a64a

Browse files
authored
Unify cargo features (#9267)
When building only a single crate in the workspace to run its tests, we often recompile a lot of other, unrelated crates. Whenever cargo has a different set of crate features, it needs to recompile. By moving some features (non-exhaustive for now) to the workspace level, we always activate them an avoid recompiling. The cargo docs mismatch the behavior of cargo around default-deps, so I filed that upstream and left most `default-features` mismatches: rust-lang/cargo#14841. Reference script: ```python import tomllib from collections import defaultdict from pathlib import Path uv = Path("/home/konsti/projects/uv") skip_list = ["uv-trampoline", "uv-dev", "uv-performance-flate2-backend", "uv-performance-memory-allocator"] root_feature_map = defaultdict(set) root_default_features = defaultdict(bool) cargo_toml = tomllib.loads(uv.joinpath("Cargo.toml").read_text()) for dep, declaration in cargo_toml["workspace"]["dependencies"].items(): root_default_features[dep] = root_default_features[dep] or declaration.get("default-features", True) root_feature_map[dep].update(declaration.get("features", [])) feature_map = defaultdict(set) default_features = defaultdict(bool) for crate in uv.joinpath("crates").iterdir(): if crate.name in skip_list: continue if not crate.joinpath("Cargo.toml").is_file(): continue cargo_toml = tomllib.loads(crate.joinpath("Cargo.toml").read_text()) for dep, declaration in cargo_toml.get("dependencies", {}).items(): # If any item uses default features, they are used everywhere default_features[dep] = default_features[dep] or declaration.get("default-features", True) feature_map[dep].update(declaration.get("features", [])) for dep, features in sorted(feature_map.items()): features = features - root_feature_map.get(dep, set()) if not features and default_features[dep] == root_default_features[dep]: continue print(dep, default_features[dep], sorted(features)) ```
1 parent 8ca8de8 commit 2f5a64a

File tree

5 files changed

+13
-13
lines changed

5 files changed

+13
-13
lines changed

Cargo.toml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ uv-distribution = { path = "crates/uv-distribution" }
3737
uv-distribution-filename = { path = "crates/uv-distribution-filename" }
3838
uv-distribution-types = { path = "crates/uv-distribution-types" }
3939
uv-extract = { path = "crates/uv-extract" }
40-
uv-fs = { path = "crates/uv-fs" }
40+
uv-fs = { path = "crates/uv-fs", features = ["serde", "tokio"] }
4141
uv-git = { path = "crates/uv-git" }
4242
uv-globfilter = { path = "crates/uv-globfilter" }
4343
uv-install-wheel = { path = "crates/uv-install-wheel", default-features = false }
@@ -72,7 +72,7 @@ uv-workspace = { path = "crates/uv-workspace" }
7272
anstream = { version = "0.6.15" }
7373
anyhow = { version = "1.0.89" }
7474
async-channel = { version = "2.3.1" }
75-
async-compression = { version = "0.4.12" }
75+
async-compression = { version = "0.4.12", features = ["bzip2", "gzip", "xz", "zstd"] }
7676
async-trait = { version = "0.1.82" }
7777
async_http_range_reader = { version = "0.9.1" }
7878
async_zip = { git = "https://github.com/charliermarsh/rs-async-zip", rev = "c909fda63fcafe4af496a07bfda28a5aae97e58d", features = ["deflate", "tokio"] }
@@ -84,7 +84,7 @@ boxcar = { version = "0.2.5" }
8484
bytecheck = { version = "0.8.0" }
8585
cachedir = { version = "0.3.1" }
8686
cargo-util = { version = "0.2.14" }
87-
clap = { version = "4.5.17" }
87+
clap = { version = "4.5.17", features = ["derive", "env", "string", "wrap_help"] }
8888
clap_complete_command = { version = "0.6.1" }
8989
configparser = { version = "3.1.0" }
9090
console = { version = "0.15.8", default-features = false }
@@ -98,7 +98,7 @@ either = { version = "1.13.0" }
9898
encoding_rs_io = { version = "0.1.7" }
9999
etcetera = { version = "0.8.0" }
100100
flate2 = { version = "1.0.33", default-features = false }
101-
fs-err = { version = "3.0.0" }
101+
fs-err = { version = "3.0.0", features = ["tokio"] }
102102
fs2 = { version = "0.4.3" }
103103
futures = { version = "0.3.30" }
104104
glob = { version = "0.3.1" }
@@ -120,7 +120,7 @@ krata-tokio-tar = { version = "0.4.2" }
120120
mailparse = { version = "0.15.0" }
121121
md-5 = { version = "0.10.6" }
122122
memchr = { version = "2.7.4" }
123-
miette = { version = "7.2.0" }
123+
miette = { version = "7.2.0", features = ["fancy-no-backtrace"] }
124124
nanoid = { version = "0.4.0" }
125125
nix = { version = "0.29.0" }
126126
owo-colors = { version = "4.1.0" }
@@ -136,7 +136,7 @@ rayon = { version = "1.10.0" }
136136
reflink-copy = { version = "0.1.19" }
137137
regex = { version = "1.10.6" }
138138
regex-automata = { version = "0.4.8", default-features = false, features = ["dfa-build", "dfa-search", "perf", "std", "syntax"] }
139-
reqwest = { version = "0.12.7", default-features = false, features = ["json", "gzip", "stream", "rustls-tls", "rustls-tls-native-roots", "socks", "multipart", "http2"] }
139+
reqwest = { version = "0.12.7", default-features = false, features = ["json", "gzip", "stream", "rustls-tls", "rustls-tls-native-roots", "socks", "multipart", "http2", "blocking"] }
140140
reqwest-middleware = { version = "0.4.0", features = ["multipart"] }
141141
reqwest-retry = { version = "0.7.0" }
142142
rkyv = { version = "0.8.8", features = ["bytecheck"] }
@@ -148,7 +148,7 @@ same-file = { version = "1.0.6" }
148148
schemars = { version = "0.8.21", features = ["url"] }
149149
seahash = { version = "4.1.0" }
150150
self-replace = { version = "1.5.0" }
151-
serde = { version = "1.0.210", features = ["derive"] }
151+
serde = { version = "1.0.210", features = ["derive", "rc"] }
152152
serde-untagged = { version = "0.1.6" }
153153
serde_json = { version = "1.0.128" }
154154
sha2 = { version = "0.10.8" }
@@ -164,7 +164,7 @@ thiserror = { version = "2.0.0" }
164164
tl = { git = "https://github.com/astral-sh/tl.git", rev = "6e25b2ee2513d75385101a8ff9f591ef51f314ec" }
165165
tokio = { version = "1.40.0", features = ["fs", "io-util", "macros", "process", "rt", "signal", "sync"] }
166166
tokio-stream = { version = "0.1.16" }
167-
tokio-util = { version = "0.7.12", features = ["compat"] }
167+
tokio-util = { version = "0.7.12", features = ["compat", "io"] }
168168
toml = { version = "0.8.19" }
169169
toml_edit = { version = "0.22.21", features = ["serde"] }
170170
tracing = { version = "0.1.40" }
@@ -173,7 +173,7 @@ tracing-subscriber = { version = "0.3.18", features = ["env-filter", "json", "re
173173
tracing-tree = { version = "0.4.0" }
174174
unicode-width = { version = "0.1.13" }
175175
unscanny = { version = "0.1.0" }
176-
url = { version = "2.5.2" }
176+
url = { version = "2.5.2", features = ["serde"] }
177177
urlencoding = { version = "2.1.3" }
178178
version-ranges = { git = "https://github.com/astral-sh/pubgrub", rev = "57afc831bf2551f164617a10383cf288bf5d190d" }
179179
walkdir = { version = "2.5.0" }

crates/uv-build-backend/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ uv-pypi-types = { workspace = true }
2323
uv-warnings = { workspace = true }
2424

2525
csv = { workspace = true }
26-
flate2 = { workspace = true }
26+
flate2 = { workspace = true, default-features = false }
2727
fs-err = { workspace = true }
2828
globset = { workspace = true }
2929
itertools = { workspace = true }

crates/uv-distribution-types/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ uv-fs = { workspace = true }
2424
uv-git = { workspace = true }
2525
uv-normalize = { workspace = true }
2626
uv-pep440 = { workspace = true }
27-
uv-pep508 = { workspace = true, features = ["serde"] }
27+
uv-pep508 = { workspace = true }
2828
uv-platform-tags = { workspace = true }
2929
uv-pypi-types = { workspace = true }
3030

crates/uv-python/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ clap = { workspace = true, optional = true }
3939
configparser = { workspace = true }
4040
fs-err = { workspace = true, features = ["tokio"] }
4141
futures = { workspace = true }
42-
goblin = { workspace = true }
42+
goblin = { workspace = true, default-features = false }
4343
itertools = { workspace = true }
4444
owo-colors = { workspace = true }
4545
regex = { workspace = true }

crates/uv/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ base64 = { version = "0.22.1" }
106106
byteorder = { version = "1.5.0" }
107107
etcetera = { workspace = true }
108108
filetime = { version = "0.2.25" }
109-
flate2 = { workspace = true }
109+
flate2 = { workspace = true, default-features = false }
110110
ignore = { version = "0.4.23" }
111111
indoc = { version = "2.0.5" }
112112
insta = { version = "1.40.0", features = ["filters", "json"] }

0 commit comments

Comments
 (0)