Skip to content

Commit

Permalink
Use PEP 517 build hooks to resolve unnamed requirements (#2604)
Browse files Browse the repository at this point in the history
  • Loading branch information
charliermarsh authored Mar 22, 2024
1 parent 5d7d7dc commit 31743f2
Show file tree
Hide file tree
Showing 14 changed files with 259 additions and 252 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

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

15 changes: 8 additions & 7 deletions crates/distribution-types/src/buildable.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use std::borrow::Cow;
use std::path::Path;

use url::Url;
Expand All @@ -12,7 +13,7 @@ use crate::{GitSourceDist, Name, PathSourceDist, SourceDist};
///
/// Distributions can _also_ point to URLs in lieu of a registry; however, the primary distinction
/// here is that a distribution will always include a package name, while a URL will not.
#[derive(Debug, Clone, Copy)]
#[derive(Debug, Clone)]
pub enum BuildableSource<'a> {
Dist(&'a SourceDist),
Url(SourceUrl<'a>),
Expand Down Expand Up @@ -46,7 +47,7 @@ impl std::fmt::Display for BuildableSource<'_> {
}

/// A reference to a source distribution defined by a URL.
#[derive(Debug, Clone, Copy)]
#[derive(Debug, Clone)]
pub enum SourceUrl<'a> {
Direct(DirectSourceUrl<'a>),
Git(GitSourceUrl<'a>),
Expand All @@ -63,7 +64,7 @@ impl std::fmt::Display for SourceUrl<'_> {
}
}

#[derive(Debug, Clone, Copy)]
#[derive(Debug, Clone)]
pub struct DirectSourceUrl<'a> {
pub url: &'a Url,
}
Expand All @@ -74,7 +75,7 @@ impl std::fmt::Display for DirectSourceUrl<'_> {
}
}

#[derive(Debug, Clone, Copy)]
#[derive(Debug, Clone)]
pub struct GitSourceUrl<'a> {
pub url: &'a Url,
}
Expand All @@ -91,10 +92,10 @@ impl<'a> From<&'a GitSourceDist> for GitSourceUrl<'a> {
}
}

#[derive(Debug, Clone, Copy)]
#[derive(Debug, Clone)]
pub struct PathSourceUrl<'a> {
pub url: &'a Url,
pub path: &'a Path,
pub path: Cow<'a, Path>,
}

impl std::fmt::Display for PathSourceUrl<'_> {
Expand All @@ -107,7 +108,7 @@ impl<'a> From<&'a PathSourceDist> for PathSourceUrl<'a> {
fn from(dist: &'a PathSourceDist) -> Self {
Self {
url: &dist.url,
path: &dist.path,
path: Cow::Borrowed(&dist.path),
}
}
}
8 changes: 5 additions & 3 deletions crates/uv-distribution/src/distribution_database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ pub struct DistributionDatabase<'a, Context: BuildContext + Send + Sync> {
cache: &'a Cache,
reporter: Option<Arc<dyn Reporter>>,
locks: Arc<Locks>,
tags: &'a Tags,
client: &'a RegistryClient,
build_context: &'a Context,
builder: SourceDistCachedBuilder<'a, Context>,
Expand All @@ -58,9 +59,10 @@ impl<'a, Context: BuildContext + Send + Sync> DistributionDatabase<'a, Context>
cache,
reporter: None,
locks: Arc::new(Locks::default()),
tags,
client,
build_context,
builder: SourceDistCachedBuilder::new(build_context, client, tags),
builder: SourceDistCachedBuilder::new(build_context, client),
}
}

Expand Down Expand Up @@ -287,7 +289,7 @@ impl<'a, Context: BuildContext + Send + Sync> DistributionDatabase<'a, Context>

let built_wheel = self
.builder
.download_and_build(BuildableSource::Dist(source_dist))
.download_and_build(&BuildableSource::Dist(source_dist), self.tags)
.boxed()
.await?;

Expand Down Expand Up @@ -363,7 +365,7 @@ impl<'a, Context: BuildContext + Send + Sync> DistributionDatabase<'a, Context>

let metadata = self
.builder
.download_and_build_metadata(BuildableSource::Dist(&source_dist))
.download_and_build_metadata(&BuildableSource::Dist(&source_dist))
.boxed()
.await?;
Ok((metadata, precise))
Expand Down
4 changes: 2 additions & 2 deletions crates/uv-distribution/src/reporter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ use distribution_types::BuildableSource;

pub trait Reporter: Send + Sync {
/// Callback to invoke when a source distribution build is kicked off.
fn on_build_start(&self, source: BuildableSource) -> usize;
fn on_build_start(&self, source: &BuildableSource) -> usize;

/// Callback to invoke when a source distribution build is complete.
fn on_build_complete(&self, source: BuildableSource, id: usize);
fn on_build_complete(&self, source: &BuildableSource, id: usize);

/// Callback to invoke when a repository checkout begins.
fn on_checkout_start(&self, url: &Url, rev: &str) -> usize;
Expand Down
Loading

0 comments on commit 31743f2

Please sign in to comment.