mirror of
https://github.com/astral-sh/uv.git
synced 2025-08-31 07:47:27 +00:00
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: https://github.com/rust-lang/cargo/issues/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)) ```
This commit is contained in:
parent
8ca8de8eaa
commit
2f5a64a8b3
5 changed files with 13 additions and 13 deletions
|
@ -39,7 +39,7 @@ clap = { workspace = true, optional = true }
|
|||
configparser = { workspace = true }
|
||||
fs-err = { workspace = true, features = ["tokio"] }
|
||||
futures = { workspace = true }
|
||||
goblin = { workspace = true }
|
||||
goblin = { workspace = true, default-features = false }
|
||||
itertools = { workspace = true }
|
||||
owo-colors = { workspace = true }
|
||||
regex = { workspace = true }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue