Repository navigation
Conversation
Merging this PR will improve performance by 14.72%
|
| Mode | Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|---|
| ⚡ |
Simulation | discover_workspace_from_all_members |
151.5 ms | 132.1 ms | +14.72% |
Tip
Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.
Comparing zb/split-uv-crate (f0541ca) with main (64e2ac8)
Footnotes
-
35 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩
uv
c059bbf to
b99d3ad
Compare
b99d3ad to
8283b76
Compare
| uv-help-command = { version = "0.0.90", path = "crates/uv-help-command" } | ||
| uv-init-command = { version = "0.0.90", path = "crates/uv-init-command" } | ||
| uv-lock-command = { version = "0.0.90", path = "crates/uv-lock-command" } | ||
| uv-pip-command = { version = "0.0.90", path = "crates/uv-pip-command" } |
There was a problem hiding this comment.
[P3] Remove the superseded command and support crates
The new command crates copy implementations while leaving uv-pip-commands, uv-python-commands, uv-tool-commands, and uv-workspace-commands intact. Cargo metadata shows those four crates have no consumers, and their old support crates form a dependency graph unreachable from uv. Because workspace membership uses crates/*, workspace checks still maintain both implementations. Remove the superseded crates and their workspace dependency entries so each workflow has one owner.
|
|
||
| anyhow = { workspace = true } | ||
| fs-err = { workspace = true } | ||
| insta = { workspace = true } |
There was a problem hiding this comment.
[P3] Keep snapshot dependencies limited to test builds
insta is used only inside the #[cfg(test)] module in installation.rs and is already declared under [dev-dependencies]. Adding it here unnecessarily brings snapshot infrastructure into ordinary uv builds. The new uv-publish-command manifest also moves its test-only insta dependency into production dependencies. Keep both declarations under [dev-dependencies].
| let build_result = build_impl( | ||
| project_dir, | ||
| skip_dependency_check, | ||
| src.as_deref(), | ||
| package.as_ref(), |
There was a problem hiding this comment.
[P3] Avoid duplicating the complete build entry point
build_impl is private and has only this caller; it still performs CLI reporting and error rendering. The wrapper forwards the entire argument list and converts a new two-variant BuildResult directly into ExitStatus, so every future build option must now be maintained across two signatures and another forwarding call without establishing a separate reusable operation. Keep the implementation in build_frontend and return ExitStatus directly.
| let package_name = serde_json::to_string(&final_version.package_name)?; | ||
| let version = serde_json::to_string(&final_version.version)?; | ||
| let commit_info = serde_json::to_string(&final_version.commit_info)?; | ||
| writeln!( | ||
| printer.stdout_important(), | ||
| "{{\n \"package_name\": {package_name},\n \"version\": {version},\n \"commit_info\": {commit_info}\n}}" |
There was a problem hiding this comment.
[P3] Retain derived serialization for project version output
Replacing ProjectVersionInfo's Serialize implementation with separately serialized fields and a handwritten JSON object creates a second definition of the output schema. Field additions or removals must now be synchronized with this format string, although the previous serde_json::to_string_pretty(&final_version) already produced the output covered by version_get_json. Restore the derive and serialize the struct directly in the new crate.
8283b76 to
e321664
Compare
| uv_virtualenv::Seed::Disabled, | ||
| upgradeable, | ||
| )?; | ||
|
|
||
| if centralized { |
There was a problem hiding this comment.
[P2] Restore interpreter caching after environment creation
The moved project and script creation paths omit environment.cache_virtualenv(false, cache)?. create_venv does not populate that cache, so the next invocation queries Python again and executes startup hooks. The existing sync_caches_interpreter test explicitly checks this contract with a sitecustomize.py marker. Restore the cache writes after creating both environments.
| let has_editable = requirements | ||
| .iter() | ||
| .any(|source| matches!(source, RequirementsSource::Editable(_))); | ||
| return Err(anyhow::Error::new(ExtrasWithoutSourceError { has_editable }).into()); |
There was a problem hiding this comment.
[P3] Keep the extras validation failure in the operation error enum
read_requirements already returns this crate's closed Error enum. Erasing this known failure into Anyhow now requires Error::hints to walk and downcast its own nested error, plus another registration in the central hint registry. Retain the original ExtrasWithoutSource { has_editable } variant and handle its hint directly, keeping this validation path statically typed.
| let state = UniversalState::default(); | ||
|
|
||
| // Lock and sync the environment, if necessary. | ||
| let lock = match Box::pin( | ||
| uv_lock_command::lock::LockOperation::new( | ||
| LockMode::Frozen(frozen_source.into()), |
There was a problem hiding this comment.
[P3] Read the frozen version directly from the lock target
LockOperation::execute handles Frozen by calling target.read_frozen(source) directly. This wrapper therefore adds shared state, a logger, boxed futures, and resolver/client configuration parameters without adding validation. Restore the direct read_frozen(...).await.map_err(UvError::from)? call so the read-only version path requires only the state it uses.
| trait InitProjectKindExt { | ||
| fn init( | ||
| self, | ||
| name: &PackageName, | ||
| path: &Path, | ||
| requires_python: &RequiresPython, |
There was a problem hiding this comment.
[P3] Keep project initialization as a free function
InitProjectKindExt has one implementation and one caller, with no generic or dynamic consumer. It duplicates the long initialization signature solely to provide method syntax, making each future initialization option require changes to both declarations. Keep init_project_kind in this command crate and pass the closed enum explicitly.
e321664 to
3926262
Compare
| @@ -1,28 +1,24 @@ | |||
| [package] | |||
| name = "uv-publish-commands" | |||
| name = "uv-publish-command" | |||
There was a problem hiding this comment.
[P2] Update publish-test routing for the renamed crate
The publish implementation now lives under crates/uv-publish-command, but .github/workflows/plan.yml:197 still matches crates/uv-publish-commands/. A PR changing only the new directory will therefore skip the dedicated trusted-publishing tests unless explicitly enabled by a label. Update the path predicate alongside this rename.
| writeln!( | ||
| printer.stderr_important(), | ||
| printer.stderr(), |
There was a problem hiding this comment.
[P2] Restore the pip-check output priorities
The stream swaps change uv pip check -q: incompatible environments lose the Found … incompatibilities summary, while compatible environments now print a success message. The existing check_incompatible_packages_quiet snapshot explicitly requires that summary. Keep the success message on stderr() and the incompatibility summary on stderr_important() so the crate move retains the command's output policy.
| write_error_chain_with_options( | ||
| err.as_ref(), | ||
| &hints, | ||
| ErrorOptions::default().with_stream(printer.stderr_important()), | ||
| )?; |
There was a problem hiding this comment.
[P3] Keep build failures using the shared error renderer
This duplicates uv::diagnostics::write_error_chain, including its default options and output-stream selection. Future changes to the shared rendering policy would need a separate update here, while tool upgrades still use the existing renderer callback. Retain the fn(&anyhow::Error, Printer) -> std::fmt::Result callback and pass diagnostics::write_error_chain from the dispatcher to keep that policy in one place.
| } | ||
| } | ||
|
|
||
| /// Update a [`PythonEnvironment`] to satisfy a set of [`RequirementsSource`]s. |
There was a problem hiding this comment.
[P3] Document the actual environment-update input type
This function still consumes a RequirementsSpecification. RequirementsSource is neither used in the signature nor imported, leaving the new rustdoc link unresolved and the API description misleading. Restore the RequirementsSpecification wording here and on EnvironmentUpdate.
| [package] | ||
| name = "uv-cli-types" | ||
| version = "0.0.93" | ||
| edition = { workspace = true } |
There was a problem hiding this comment.
[P2] Add required descriptions to the new publishable crates
Cargo metadata reports no package.description for 28 new crates, including this one. scripts/publish-crates.py selects all publishable workspace members, but crates.io requires a nonempty description, so the next workspace publication will fail. Release preparation only updates versions and READMEs; it does not supply this metadata. Add descriptions to these manifests, following the existing component crates.
| Self::Python(err) => err.hints(), | ||
| Self::Operation(err) => err.hints(), | ||
| Self::Client(err) => uv_errors::Hinted::hints(err), | ||
| _ => uv_errors::Hints::none(), |
There was a problem hiding this comment.
[P3] Keep project-error hint dispatch exhaustive
The merged Hinted implementation replaces exhaustive matches in the original error types with this wildcard. Adding a ProjectError variant now silently selects no hints unless its author remembers to update this separate match, including variants that should delegate to an inner error. Enumerate the intentional hint-free variants so additions require an explicit hint policy, following the original implementations and repository convention.
| #[cfg(test)] | ||
| mod error_tests { | ||
| use std::io::{Error, ErrorKind}; | ||
|
|
||
| // Command context retains the lockfile's regeneration hint. | ||
| let error = anyhow::Error::new(error).context("Failed to check the lockfile"); | ||
| use anyhow::bail; | ||
| use insta::{allow_duplicates, assert_snapshot}; | ||
|
|
||
| let hints = hints_for_error(&error); | ||
| assert_debug_snapshot!(hints.iter().collect::<Vec<_>>(), @r#" | ||
| [ | ||
| "To regenerate the lockfile, run `uv lock --refresh --preview-features lockfile-format-check`.", | ||
| ] | ||
| "#); | ||
| } | ||
| use uv_cli_error::UvError; |
There was a problem hiding this comment.
[P3] Keep error-conversion tests in their owning crates
This new module tests error conversions without calling either diagnostic-rendering function. Consequently, focused tests for uv-cli-error or uv-project miss this coverage, while exercising it requires building the application and all command crates. Move the two operation-classification tests into uv-cli-error and the ProjectError conversion test into uv-project; keep tests of the central hint registry here.
| version = "0.103.14" | ||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| checksum = "4443b1b6d39d7c663139942cc4558262562d2c84123bb6282ef177009ca8b281" | ||
| checksum = "0527518605e68109d875e248ea259b6758801cf165e4b2c2733ae3b51f12535a" |
There was a problem hiding this comment.
[P3] Keep the TLS dependency downgrade separate from the crate split
This also downgrades rustls-webpki from 0.103.16 to 0.103.14. The workspace’s webpki constraint and all other external lockfile records are unchanged, so the crate split does not require this downgrade. It introduces an unrelated certificate-verification dependency change that needs separate justification and validation. Restore 0.103.16 with cargo update -p rustls-webpki --precise 0.103.16, or move an intentional downgrade into a separate change.
| | ProjectError::EmptyEnvironment | ||
| | ProjectError::InvalidProjectEnvironmentDir(..) | ||
| | ProjectError::UvLockParse(..) |
There was a problem hiding this comment.
[P1] Handle InvalidScriptEnvironmentDir in the error conversion
ProjectError declares InvalidScriptEnvironmentDir, but this match never handles it. Rust therefore rejects the conversion as non-exhaustive, preventing uv-project and uv from compiling. Add ProjectError::InvalidScriptEnvironmentDir(..) to the unexpected-error alternatives, matching the previous EnvironmentError conversion and the exit status required by sync_active_script_environment_non_virtualenv.
Command implementations and shared project workflows are concentrated in
uv. Move every command family into a dedicated*-commandcrate and give shared operations, project logic, CLI settings, output, and process helpers separate owners.uvretains initialization, dispatch, logging, and the central error-hint registry.Selected dependencies:
Callers import directly from owning modules. Existing domain crates retain their responsibilities, and the split keeps command behavior, error classification, and application metadata intact.
self-updateremains optional.