Rebrand workspace API as project API (#3489)

## Summary

I've started to refer to this as the "project" API in various places, it
seems less duplicative than the "workspace" API which is a little
different.
This commit is contained in:
Charlie Marsh 2024-05-09 13:05:31 -04:00 committed by GitHub
parent 7585c8be5d
commit 2d70303d56
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 27 additions and 27 deletions

View File

@ -16,6 +16,9 @@ pub(crate) use pip_list::pip_list;
pub(crate) use pip_show::pip_show;
pub(crate) use pip_sync::pip_sync;
pub(crate) use pip_uninstall::pip_uninstall;
pub(crate) use project::lock::lock;
pub(crate) use project::run::run;
pub(crate) use project::sync::sync;
#[cfg(feature = "self-update")]
pub(crate) use self_update::self_update;
use uv_cache::Cache;
@ -25,9 +28,6 @@ use uv_interpreter::PythonEnvironment;
use uv_normalize::PackageName;
pub(crate) use venv::venv;
pub(crate) use version::version;
pub(crate) use workspace::lock::lock;
pub(crate) use workspace::run::run;
pub(crate) use workspace::sync::sync;
use crate::printer::Printer;
@ -42,12 +42,12 @@ mod pip_list;
mod pip_show;
mod pip_sync;
mod pip_uninstall;
mod project;
mod reporters;
#[cfg(feature = "self-update")]
mod self_update;
mod venv;
mod version;
mod workspace;
#[derive(Copy, Clone)]
pub(crate) enum ExitStatus {

View File

@ -13,8 +13,8 @@ use uv_resolver::{FlatIndex, InMemoryIndex, OptionsBuilder};
use uv_types::{BuildIsolation, HashStrategy, InFlight};
use uv_warnings::warn_user;
use crate::commands::workspace::Error;
use crate::commands::{workspace, ExitStatus};
use crate::commands::project::Error;
use crate::commands::{project, ExitStatus};
use crate::printer::Printer;
/// Resolve the project requirements into a lockfile.
@ -31,10 +31,10 @@ pub(crate) async fn lock(
// TODO(charlie): If the environment doesn't exist, create it.
let venv = PythonEnvironment::from_virtualenv(cache)?;
// Find the workspace requirements.
let Some(requirements) = workspace::find_workspace()? else {
// Find the project requirements.
let Some(requirements) = project::find_project()? else {
return Err(anyhow::anyhow!(
"Unable to find `pyproject.toml` for project workspace."
"Unable to find `pyproject.toml` for project project."
));
};
@ -105,7 +105,7 @@ pub(crate) async fn lock(
.build();
// Resolve the requirements.
let resolution = workspace::resolve(
let resolution = project::resolve(
spec,
&hasher,
&interpreter,

View File

@ -63,7 +63,7 @@ pub(crate) enum Error {
}
/// Find the requirements for the current workspace.
pub(crate) fn find_workspace() -> Result<Option<Vec<RequirementsSource>>> {
pub(crate) fn find_project() -> Result<Option<Vec<RequirementsSource>>> {
// TODO(zanieb): Add/use workspace logic to load requirements for a workspace
// We cannot use `Workspace::find` yet because it depends on a `[tool.uv]` section
let pyproject_path = std::env::current_dir()?.join("pyproject.toml");

View File

@ -21,7 +21,7 @@ use uv_resolver::{FlatIndex, InMemoryIndex, OptionsBuilder};
use uv_types::{BuildIsolation, HashStrategy, InFlight};
use uv_warnings::warn_user;
use crate::commands::{workspace, ExitStatus};
use crate::commands::{project, ExitStatus};
use crate::printer::Printer;
/// Run a command.
@ -56,22 +56,22 @@ pub(crate) async fn run(
"python".to_string()
};
// Discover and sync the workspace.
let workspace_env = if isolated {
// Discover and sync the project.
let project_env = if isolated {
None
} else {
debug!("Syncing workspace environment.");
debug!("Syncing project environment.");
let Some(workspace_requirements) = workspace::find_workspace()? else {
let Some(project_requirements) = project::find_project()? else {
return Err(anyhow::anyhow!(
"Unable to find `pyproject.toml` for project workspace."
"Unable to find `pyproject.toml` for project project."
));
};
let venv = PythonEnvironment::from_virtualenv(cache)?;
// Install the workspace requirements.
Some(update_environment(venv, &workspace_requirements, preview, cache, printer).await?)
// Install the project requirements.
Some(update_environment(venv, &project_requirements, preview, cache, printer).await?)
};
// If necessary, create an environment for the ephemeral requirements.
@ -82,8 +82,8 @@ pub(crate) async fn run(
debug!("Syncing ephemeral environment.");
// Discover an interpreter.
let interpreter = if let Some(workspace_env) = &workspace_env {
workspace_env.interpreter().clone()
let interpreter = if let Some(project_env) = &project_env {
project_env.interpreter().clone()
} else if let Some(python) = python.as_ref() {
PythonEnvironment::from_requested_python(python, cache)?.into_interpreter()
} else {
@ -123,7 +123,7 @@ pub(crate) async fn run(
.map(PythonEnvironment::scripts)
.into_iter()
.chain(
workspace_env
project_env
.as_ref()
.map(PythonEnvironment::scripts)
.into_iter(),
@ -146,7 +146,7 @@ pub(crate) async fn run(
.into_iter()
.flatten()
.chain(
workspace_env
project_env
.as_ref()
.map(PythonEnvironment::site_packages)
.into_iter()
@ -286,7 +286,7 @@ async fn update_environment(
.build();
// Resolve the requirements.
let resolution = match workspace::resolve(
let resolution = match project::resolve(
spec,
&hasher,
&interpreter,
@ -309,7 +309,7 @@ async fn update_environment(
let in_flight = InFlight::default();
// Sync the environment.
workspace::install(
project::install(
&resolution,
SitePackages::from_executable(&venv)?,
&no_binary,

View File

@ -13,7 +13,7 @@ use uv_resolver::{FlatIndex, InMemoryIndex, Lock};
use uv_types::{BuildIsolation, HashStrategy, InFlight};
use uv_warnings::warn_user;
use crate::commands::{workspace, ExitStatus};
use crate::commands::{project, ExitStatus};
use crate::printer::Printer;
/// Sync the project environment.
@ -79,7 +79,7 @@ pub(crate) async fn sync(
};
// Sync the environment.
workspace::install(
project::install(
&resolution,
SitePackages::from_executable(&venv)?,
&no_binary,