Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/uv-build-frontend/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ workspace = true

[dependencies]
uv-auth = { workspace = true }
uv-cache = { workspace = true }
uv-cache-key = { workspace = true }
uv-configuration = { workspace = true }
uv-distribution = { workspace = true }
Expand Down
5 changes: 5 additions & 0 deletions crates/uv-build-frontend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ use tokio::process::Command;
use tokio::sync::{Mutex, Semaphore};
use tracing::{Instrument, debug, info_span, instrument, warn};
use uv_auth::CredentialsCache;
use uv_cache::Cache;
use uv_cache_key::cache_digest;
use uv_configuration::{BuildKind, BuildOutput, NoSources};
use uv_distribution::BuildRequires;
Expand Down Expand Up @@ -321,6 +322,7 @@ impl SourceBuild {
fallback_package_name,
locations,
&no_sources,
build_context.cache(),
workspace_cache,
credentials_cache,
)
Expand Down Expand Up @@ -572,6 +574,7 @@ impl SourceBuild {
package_name: Option<&PackageName>,
locations: &IndexLocations,
no_sources: &NoSources,
cache: &Cache,
workspace_cache: &WorkspaceCache,
credentials_cache: &CredentialsCache,
) -> Result<(Pep517Backend, Option<Project>), Box<Error>> {
Expand Down Expand Up @@ -652,6 +655,7 @@ impl SourceBuild {
locations,
no_sources,
true,
cache,
workspace_cache,
credentials_cache,
)
Expand Down Expand Up @@ -1100,6 +1104,7 @@ async fn create_pep517_build_environment(
build_context
.source_tree_editable_policy()
.workspace_member_editable(None),
build_context.cache(),
workspace_cache,
credentials_cache,
)
Expand Down
13 changes: 10 additions & 3 deletions crates/uv-distribution/src/metadata/build_requires.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use std::collections::BTreeMap;
use std::path::Path;

use uv_auth::CredentialsCache;
use uv_cache::Cache;
use uv_configuration::NoSources;
use uv_distribution_types::{
ExtraBuildRequirement, ExtraBuildRequires, IndexLocations, Requirement,
Expand Down Expand Up @@ -43,7 +44,8 @@ impl BuildRequires {
locations: &IndexLocations,
sources: &NoSources,
editable: bool,
cache: &WorkspaceCache,
cache: &Cache,
workspace_cache: &WorkspaceCache,
credentials_cache: &CredentialsCache,
) -> Result<Self, MetadataError> {
let discovery = if sources.all() {
Expand All @@ -54,8 +56,13 @@ impl BuildRequires {
} else {
DiscoveryOptions::default()
};
let Some(project_workspace) =
ProjectWorkspace::from_maybe_project_root(install_path, &discovery, cache).await?
let Some(project_workspace) = ProjectWorkspace::from_maybe_project_root(
install_path,
&discovery,
cache,
workspace_cache,
)
.await?
else {
return Ok(Self::from_metadata23(metadata));
};
Expand Down
13 changes: 8 additions & 5 deletions crates/uv-distribution/src/metadata/dependency_groups.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ use std::collections::BTreeMap;
use std::path::{Path, PathBuf};

use uv_auth::CredentialsCache;
use uv_cache::Cache;
use uv_configuration::NoSources;
use uv_distribution_types::{IndexLocations, Requirement};
use uv_normalize::{GroupName, PackageName};
use uv_workspace::dependency_groups::FlatDependencyGroups;
use uv_workspace::pyproject::{Sources, ToolUvSources};
use uv_workspace::{
DiscoveryOptions, MemberDiscovery, VirtualProject, WorkspaceCache, WorkspaceError,
WorkspaceErrorKind,
};

use crate::metadata::{GitWorkspaceMember, LoweredRequirement, MetadataError};
Expand Down Expand Up @@ -57,7 +59,8 @@ impl SourcedDependencyGroups {
git_member: Option<&GitWorkspaceMember<'_>>,
locations: &IndexLocations,
no_sources: NoSources,
cache: &WorkspaceCache,
cache: &Cache,
workspace_cache: &WorkspaceCache,
credentials_cache: &CredentialsCache,
) -> Result<Self, MetadataError> {
// If the `pyproject.toml` doesn't exist, fail early.
Expand All @@ -80,15 +83,15 @@ impl SourcedDependencyGroups {
} else {
MemberDiscovery::None
},
..DiscoveryOptions::default()
};

// The subsequent API takes an absolute path to the dir the pyproject is in
let empty = PathBuf::new();
let absolute_pyproject_path =
std::path::absolute(pyproject_path).map_err(WorkspaceError::Normalize)?;
let absolute_pyproject_path = std::path::absolute(pyproject_path)
.map_err(|err| WorkspaceError::from(WorkspaceErrorKind::Normalize(err)))?;
let project_dir = absolute_pyproject_path.parent().unwrap_or(&empty);
let project = VirtualProject::discover(project_dir, &discovery, cache).await?;
let project =
VirtualProject::discover(project_dir, &discovery, cache, workspace_cache).await?;

// Collect the dependency groups.
let dependency_groups =
Expand Down
5 changes: 4 additions & 1 deletion crates/uv-distribution/src/metadata/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use std::path::{Path, PathBuf};
use thiserror::Error;

use uv_auth::CredentialsCache;
use uv_cache::Cache;
use uv_configuration::NoSources;
use uv_distribution_types::{GitDirectorySourceUrl, IndexLocations, Requirement};
use uv_normalize::{ExtraName, GroupName, PackageName};
Expand Down Expand Up @@ -101,7 +102,8 @@ impl Metadata {
locations: &IndexLocations,
sources: NoSources,
editable: bool,
cache: &WorkspaceCache,
cache: &Cache,
workspace_cache: &WorkspaceCache,
credentials_cache: &CredentialsCache,
) -> Result<Self, MetadataError> {
// Lower the requirements.
Expand All @@ -125,6 +127,7 @@ impl Metadata {
sources,
editable,
cache,
workspace_cache,
credentials_cache,
)
.await?;
Expand Down
17 changes: 13 additions & 4 deletions crates/uv-distribution/src/metadata/requires_dist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use std::slice;
use rustc_hash::FxHashSet;

use uv_auth::CredentialsCache;
use uv_cache::Cache;
use uv_configuration::NoSources;
use uv_distribution_types::{IndexLocations, Requirement};
use uv_normalize::{ExtraName, GroupName, PackageName};
Expand Down Expand Up @@ -35,7 +36,8 @@ impl RequiresDist {
locations: &IndexLocations,
sources: NoSources,
editable: bool,
cache: &WorkspaceCache,
cache: &Cache,
workspace_cache: &WorkspaceCache,
credentials_cache: &CredentialsCache,
) -> Result<Self, MetadataError> {
let discovery = DiscoveryOptions {
Expand All @@ -51,10 +53,14 @@ impl RequiresDist {
} else {
MemberDiscovery::None
},
..DiscoveryOptions::default()
};
let Some(project_workspace) =
ProjectWorkspace::from_maybe_project_root(install_path, &discovery, cache).await?
let Some(project_workspace) = ProjectWorkspace::from_maybe_project_root(
install_path,
&discovery,
cache,
workspace_cache,
)
.await?
else {
return Self::from_metadata23_with_source_context(metadata, git_member);
};
Expand Down Expand Up @@ -454,6 +460,7 @@ mod test {
use tempfile::TempDir;

use uv_auth::CredentialsCache;
use uv_cache::Cache;
use uv_configuration::NoSources;
use uv_distribution_types::IndexLocations;
use uv_normalize::PackageName;
Expand All @@ -468,12 +475,14 @@ mod test {
contents: &str,
) -> anyhow::Result<RequiresDist> {
fs_err::write(temp_dir.join("pyproject.toml"), contents)?;
let cache = Cache::from_path(temp_dir.join(".uv_cache"));
let project_workspace = ProjectWorkspace::discover(
temp_dir,
&DiscoveryOptions {
stop_discovery_at: Some(temp_dir.to_path_buf()),
..DiscoveryOptions::default()
},
&cache,
&WorkspaceCache::default(),
)
.await?;
Expand Down
9 changes: 9 additions & 0 deletions crates/uv-distribution/src/source/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1479,6 +1479,7 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
self.build_context.locations(),
self.build_context.sources().clone(),
editable,
self.build_context.cache(),
self.build_context.workspace_cache(),
credentials_cache,
)
Expand Down Expand Up @@ -1534,6 +1535,7 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
self.build_context.locations(),
self.build_context.sources().clone(),
editable,
self.build_context.cache(),
self.build_context.workspace_cache(),
credentials_cache,
)
Expand Down Expand Up @@ -1585,6 +1587,7 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
self.build_context.locations(),
self.build_context.sources().clone(),
editable,
self.build_context.cache(),
self.build_context.workspace_cache(),
credentials_cache,
)
Expand Down Expand Up @@ -1648,6 +1651,7 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
self.build_context.locations(),
self.build_context.sources().clone(),
editable,
self.build_context.cache(),
self.build_context.workspace_cache(),
credentials_cache,
)
Expand Down Expand Up @@ -1727,6 +1731,7 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
self.build_context
.source_tree_editable_policy()
.workspace_member_editable(None),
self.build_context.cache(),
self.build_context.workspace_cache(),
credentials_cache,
)
Expand Down Expand Up @@ -2322,6 +2327,7 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
self.build_context
.source_tree_editable_policy()
.workspace_member_editable(None),
self.build_context.cache(),
self.build_context.workspace_cache(),
credentials_cache,
)
Expand Down Expand Up @@ -2359,6 +2365,7 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
self.build_context
.source_tree_editable_policy()
.workspace_member_editable(None),
self.build_context.cache(),
self.build_context.workspace_cache(),
credentials_cache,
)
Expand Down Expand Up @@ -2415,6 +2422,7 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
self.build_context
.source_tree_editable_policy()
.workspace_member_editable(None),
self.build_context.cache(),
self.build_context.workspace_cache(),
credentials_cache,
)
Expand Down Expand Up @@ -2480,6 +2488,7 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
self.build_context
.source_tree_editable_policy()
.workspace_member_editable(None),
self.build_context.cache(),
self.build_context.workspace_cache(),
credentials_cache,
)
Expand Down
2 changes: 2 additions & 0 deletions crates/uv-workspace/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ workspace = true

[dependencies]
uv-build-backend = { workspace = true, features = ["schemars"] }
uv-cache = { workspace = true }
uv-cache-key = { workspace = true }
uv-configuration = { workspace = true }
uv-distribution-types = { workspace = true }
Expand All @@ -25,6 +26,7 @@ uv-fs = { workspace = true, features = ["tokio"] }
uv-git-types = { workspace = true }
uv-macros = { workspace = true }
uv-normalize = { workspace = true }
uv-once-map = { workspace = true }
uv-options-metadata = { workspace = true }
uv-pep440 = { workspace = true }
uv-pep508 = { workspace = true }
Expand Down
5 changes: 2 additions & 3 deletions crates/uv-workspace/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
pub use workspace::{
DiscoveryOptions, Editability, MemberDiscovery, ProjectDiscovery, ProjectWorkspace,
RequiresPythonSources, VirtualProject, Workspace, WorkspaceCache, WorkspaceError,
WorkspaceMember,
DiscoveryOptions, Editability, MemberDiscovery, ProjectWorkspace, RequiresPythonSources,
VirtualProject, Workspace, WorkspaceCache, WorkspaceError, WorkspaceErrorKind, WorkspaceMember,
};

pub mod dependency_groups;
Expand Down
Loading
Loading