diff --git a/crates/uv-distribution/src/workspace.rs b/crates/uv-distribution/src/workspace.rs index 3d395aa82a26..e6106829c211 100644 --- a/crates/uv-distribution/src/workspace.rs +++ b/crates/uv-distribution/src/workspace.rs @@ -192,13 +192,6 @@ impl Workspace { .collect() } - /// If there is a package at the workspace root, return it. - pub fn root_member(&self) -> Option<&WorkspaceMember> { - self.packages - .values() - .find(|package| package.root == self.root) - } - /// The path to the workspace root, the directory containing the top level `pyproject.toml` with /// the `uv.tool.workspace`, or the `pyproject.toml` in an implicit single workspace project. pub fn root(&self) -> &PathBuf { diff --git a/crates/uv/src/commands/project/add.rs b/crates/uv/src/commands/project/add.rs index e6d11534d8ef..4e1b4a7e958b 100644 --- a/crates/uv/src/commands/project/add.rs +++ b/crates/uv/src/commands/project/add.rs @@ -48,15 +48,7 @@ pub(crate) async fn add( let exclude_newer = None; // Lock and sync the environment. - let root_project_name = project - .current_project() - .pyproject_toml() - .project - .as_ref() - .map(|project| project.name.clone()); - let lock = project::lock::do_lock( - root_project_name, project.workspace(), venv.interpreter(), &index_locations, diff --git a/crates/uv/src/commands/project/lock.rs b/crates/uv/src/commands/project/lock.rs index 4647c15cdc93..a0242cb030bf 100644 --- a/crates/uv/src/commands/project/lock.rs +++ b/crates/uv/src/commands/project/lock.rs @@ -13,7 +13,6 @@ use uv_configuration::{ use uv_dispatch::BuildDispatch; use uv_distribution::{Workspace, DEV_DEPENDENCIES}; use uv_git::GitResolver; -use uv_normalize::PackageName; use uv_requirements::upgrade::{read_lockfile, LockedRequirements}; use uv_resolver::{ExcludeNewer, FlatIndex, InMemoryIndex, Lock, OptionsBuilder, RequiresPython}; use uv_toolchain::Interpreter; @@ -46,15 +45,7 @@ pub(crate) async fn lock( let interpreter = project::find_interpreter(&workspace, python.as_deref(), cache, printer)?; // Perform the lock operation. - let root_project_name = workspace.root_member().and_then(|member| { - member - .pyproject_toml() - .project - .as_ref() - .map(|project| project.name.clone()) - }); match do_lock( - root_project_name, &workspace, &interpreter, &index_locations, @@ -82,7 +73,6 @@ pub(crate) async fn lock( /// Lock the project requirements into a lockfile. #[allow(clippy::too_many_arguments)] pub(super) async fn do_lock( - root_project_name: Option, workspace: &Workspace, interpreter: &Interpreter, index_locations: &IndexLocations, @@ -122,27 +112,13 @@ pub(super) async fn do_lock( if matches!(requires_python.bound(), Bound::Unbounded) { let default = RequiresPython::greater_than_equal_version(interpreter.python_minor_version()); - if let Some(root_project_name) = root_project_name.as_ref() { - warn_user!( - "The `requires-python` field found in `{root_project_name}` does not contain a lower bound: `{requires_python}`. Set a lower bound to indicate the minimum compatible Python version (e.g., `{default}`).", - ); - } else { - warn_user!( - "The `requires-python` field does not contain a lower bound: `{requires_python}`. Set a lower bound to indicate the minimum compatible Python version (e.g., `{default}`).", - ); - } + warn_user!("The `requires-python` field does not contain a lower bound: `{requires_python}`. Set a lower bound to indicate the minimum compatible Python version (e.g., `{default}`)."); } requires_python } else { let default = RequiresPython::greater_than_equal_version(interpreter.python_minor_version()); - if let Some(root_project_name) = root_project_name.as_ref() { - warn_user!( - "No `requires-python` field found in `{root_project_name}`. Defaulting to `{default}`.", - ); - } else { - warn_user!("No `requires-python` field found in workspace. Defaulting to `{default}`.",); - } + warn_user!("No `requires-python` field found. Defaulting to `{default}`."); default }; @@ -208,7 +184,7 @@ pub(super) async fn do_lock( overrides, dev, source_trees, - root_project_name, + None, &extras, preferences, EmptyInstalledPackages, diff --git a/crates/uv/src/commands/project/remove.rs b/crates/uv/src/commands/project/remove.rs index e04e2edcce2b..d51ac45ed5bf 100644 --- a/crates/uv/src/commands/project/remove.rs +++ b/crates/uv/src/commands/project/remove.rs @@ -51,15 +51,7 @@ pub(crate) async fn remove( let exclude_newer = None; // Lock and sync the environment. - let root_project_name = project - .current_project() - .pyproject_toml() - .project - .as_ref() - .map(|project| project.name.clone()); - let lock = project::lock::do_lock( - root_project_name, project.workspace(), venv.interpreter(), &index_locations, diff --git a/crates/uv/src/commands/project/run.rs b/crates/uv/src/commands/project/run.rs index d0ef4b28aca1..38c704410e1d 100644 --- a/crates/uv/src/commands/project/run.rs +++ b/crates/uv/src/commands/project/run.rs @@ -66,14 +66,7 @@ pub(crate) async fn run( project::init_environment(project.workspace(), python.as_deref(), cache, printer)?; // Lock and sync the environment. - let root_project_name = project - .current_project() - .pyproject_toml() - .project - .as_ref() - .map(|project| project.name.clone()); let lock = project::lock::do_lock( - root_project_name, project.workspace(), venv.interpreter(), &index_locations,