This is not erroring

This commit is contained in:
Charlie Marsh 2025-11-08 20:09:51 -05:00
parent bbb49ef912
commit 5339c83998
11 changed files with 93 additions and 23 deletions

View File

@ -10,7 +10,7 @@ use tempfile::TempDir;
use tokio::io::{AsyncRead, AsyncSeekExt, ReadBuf}; use tokio::io::{AsyncRead, AsyncSeekExt, ReadBuf};
use tokio::sync::Semaphore; use tokio::sync::Semaphore;
use tokio_util::compat::FuturesAsyncReadCompatExt; use tokio_util::compat::FuturesAsyncReadCompatExt;
use tracing::{Instrument, info_span, instrument, warn}; use tracing::{Instrument, info_span, instrument, warn, debug};
use url::Url; use url::Url;
use uv_auth::PyxTokenStore; use uv_auth::PyxTokenStore;
use uv_cache::{ArchiveId, CacheBucket, CacheEntry, WheelCache}; use uv_cache::{ArchiveId, CacheBucket, CacheEntry, WheelCache};
@ -377,29 +377,24 @@ impl<'a, Context: BuildContext> DistributionDatabase<'a, Context> {
hashes: HashPolicy<'_>, hashes: HashPolicy<'_>,
) -> Result<LocalWheel, Error> { ) -> Result<LocalWheel, Error> {
// If this is a Git distribution, look for cached wheels. // If this is a Git distribution, look for cached wheels.
// TODO(charlie): What if this is unnamed? How can we infer the package name? Maybe we make if let SourceDist::Git(dist) = dist {
// the whole thing content-addressed, and assume that the registry contains at most one
// package?
if let BuildableSource::Dist(SourceDist::Git(dist)) = dist {
if dist.subdirectory.is_none() { if dist.subdirectory.is_none() {
if let Some(repo) = GitHubRepository::parse(dist.git.repository()) { if let Some(repo) = GitHubRepository::parse(dist.git.repository()) {
if let Ok(store) = PyxTokenStore::from_settings() { if let Ok(store) = PyxTokenStore::from_settings() {
let url = store.api().join(&format!("v1/git/astral-sh/{}/{}", repo.owner, repo.repo)).unwrap(); // let url = store.api().join(&format!("v1/git/astral-sh/{}/{}", repo.owner, repo.repo)).unwrap();
let url = VerbatimUrl::parse_url(&format!("http://localhost:8000/v1/git/astral-sh/{}/{}", repo.owner, repo.repo)).unwrap();
let index = IndexMetadata { let index = IndexMetadata {
url: IndexUrl::from(VerbatimUrl::from(url)), // url: IndexUrl::from(VerbatimUrl::from(url)),
url: IndexUrl::from(url.clone()),
format: IndexFormat::Simple, format: IndexFormat::Simple,
}; };
let archives = self.client let archives = self.client
.managed(|client| { .manual(|client, semaphore| {
client.package_metadata( client.package_metadata(
dist.name(), Some(index.as_ref()), self.build_context.capabilities(), self.build_context dist.name(), Some(index.as_ref()), self.build_context.capabilities(), semaphore,
) )
}) })
.await .await?;
.map_err(|err| match err {
CachedClientError::Callback { err, .. } => err,
CachedClientError::Client { err, .. } => Error::Client(err),
})?;
// TODO(charlie): This needs to prefer wheels to sdists (but allow sdists), // TODO(charlie): This needs to prefer wheels to sdists (but allow sdists),
// etc., filter by tags, filter by `requires-python`, etc. // etc., filter by tags, filter by `requires-python`, etc.
@ -412,6 +407,7 @@ impl<'a, Context: BuildContext> DistributionDatabase<'a, Context> {
.expect("archived version files always deserializes"); .expect("archived version files always deserializes");
for (filename, file) in files.all() { for (filename, file) in files.all() {
if let DistFilename::WheelFilename(filename) = filename { if let DistFilename::WheelFilename(filename) = filename {
debug!("Found cached wheel {filename} for Git distribution: {dist}");
let dist = BuiltDist::Registry(RegistryBuiltDist { let dist = BuiltDist::Registry(RegistryBuiltDist {
wheels: vec![ wheels: vec![
RegistryBuiltWheel { RegistryBuiltWheel {
@ -597,25 +593,26 @@ impl<'a, Context: BuildContext> DistributionDatabase<'a, Context> {
// the whole thing content-addressed, and assume that the registry contains at most one // the whole thing content-addressed, and assume that the registry contains at most one
// package? // package?
if let BuildableSource::Dist(SourceDist::Git(dist)) = source { if let BuildableSource::Dist(SourceDist::Git(dist)) = source {
// TODO(charlie): Make this more efficient.
self.builder.resolve_revision(source, &self.client).await?;
if dist.subdirectory.is_none() { if dist.subdirectory.is_none() {
if let Some(repo) = GitHubRepository::parse(dist.git.repository()) { if let Some(repo) = GitHubRepository::parse(dist.git.repository()) {
if let Ok(store) = PyxTokenStore::from_settings() { if let Ok(store) = PyxTokenStore::from_settings() {
let url = store.api().join(&format!("v1/git/astral-sh/{}/{}", repo.owner, repo.repo)).unwrap(); // let url = store.api().join(&format!("v1/git/astral-sh/{}/{}", repo.owner, repo.repo)).unwrap();
let url = VerbatimUrl::parse_url(&format!("http://localhost:8000/v1/git/astral-sh/{}/{}", repo.owner, repo.repo)).unwrap();
let index = IndexMetadata { let index = IndexMetadata {
url: IndexUrl::from(VerbatimUrl::from(url)), // url: IndexUrl::from(VerbatimUrl::from(url)),
url: IndexUrl::from(url.clone()),
format: IndexFormat::Simple, format: IndexFormat::Simple,
}; };
let archives = self.client let archives = self.client
.managed(|client| { .manual(|client, semaphore| {
client.package_metadata( client.package_metadata(
dist.name(), Some(index.as_ref()), self.build_context.capabilities(), self.build_context dist.name(), Some(index.as_ref()), self.build_context.capabilities(),semaphore
) )
}) })
.await .await?;
.map_err(|err| match err {
CachedClientError::Callback { err, .. } => err,
CachedClientError::Client { err, .. } => Error::Client(err),
})?;
// TODO(charlie): This needs to prefer wheels to sdists (but allow sdists), // TODO(charlie): This needs to prefer wheels to sdists (but allow sdists),
// etc. // etc.
@ -628,6 +625,7 @@ impl<'a, Context: BuildContext> DistributionDatabase<'a, Context> {
.expect("archived version files always deserializes"); .expect("archived version files always deserializes");
for (filename, file) in files.all() { for (filename, file) in files.all() {
if let DistFilename::WheelFilename(filename) = filename { if let DistFilename::WheelFilename(filename) = filename {
debug!("Found cached wheel {filename} for Git distribution: {dist}");
let dist = BuiltDist::Registry(RegistryBuiltDist { let dist = BuiltDist::Registry(RegistryBuiltDist {
wheels: vec![ wheels: vec![
RegistryBuiltWheel { RegistryBuiltWheel {

View File

@ -213,6 +213,7 @@ impl GitResolver {
/// [`resolve_precise`], and will return `None` for URLs that have not been resolved _or_ /// [`resolve_precise`], and will return `None` for URLs that have not been resolved _or_
/// already have a precise reference. /// already have a precise reference.
pub fn precise(&self, url: GitUrl) -> Option<GitUrl> { pub fn precise(&self, url: GitUrl) -> Option<GitUrl> {
println!("Resolving precise Git URL for: {url}");
let reference = RepositoryReference::from(&url); let reference = RepositoryReference::from(&url);
let precise = self.get(&reference)?; let precise = self.get(&reference)?;
Some(url.with_precise(*precise)) Some(url.with_precise(*precise))

1
foo/.python-version Normal file
View File

@ -0,0 +1 @@
3.14.0

0
foo/README.md Normal file
View File

6
foo/main.py Normal file
View File

@ -0,0 +1,6 @@
def main():
print("Hello from foo!")
if __name__ == "__main__":
main()

10
foo/pyproject.toml Normal file
View File

@ -0,0 +1,10 @@
[project]
name = "foo"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.14.0"
dependencies = ["anyio"]
[tool.uv.sources]
anyio = { git = "https://github.com/agronholm/anyio", rev = "64b753b19c9a49e3ae395cde457cf82d51f7e999" }

31
foo/uv.lock Normal file
View File

@ -0,0 +1,31 @@
version = 1
revision = 3
requires-python = ">=3.14.0"
[[package]]
name = "anyio"
version = "4.11.0.post24"
source = { git = "https://github.com/agronholm/anyio?rev=64b753b19c9a49e3ae395cde457cf82d51f7e999#64b753b19c9a49e3ae395cde457cf82d51f7e999" }
dependencies = [
{ name = "idna" },
]
[[package]]
name = "foo"
version = "0.1.0"
source = { virtual = "." }
dependencies = [
{ name = "anyio" },
]
[package.metadata]
requires-dist = [{ name = "anyio", git = "https://github.com/agronholm/anyio?rev=64b753b19c9a49e3ae395cde457cf82d51f7e999" }]
[[package]]
name = "idna"
version = "3.11"
source = { registry = "https://pypi.org/simple" }
sdist = { url = "https://files.pythonhosted.org/packages/6f/6d/0703ccc57f3a7233505399edb88de3cbd678da106337b9fcde432b65ed60/idna-3.11.tar.gz", hash = "sha256:795dafcc9c04ed0c1fb032c2aa73654d8e8c5023a7df64a53f39190ada629902", size = 194582, upload-time = "2025-10-12T14:55:20.501Z" }
wheels = [
{ url = "https://files.pythonhosted.org/packages/0e/61/66938bbb5fc52dbdf84594873d5b51fb1f7c7794e9c0f5bd885f30bc507b/idna-3.11-py3-none-any.whl", hash = "sha256:771a87f49d9defaf64091e6e6fe9c18d4833f140bd19464795bc32d966ca37ea", size = 71008, upload-time = "2025-10-12T14:55:18.883Z" },
]

View File

@ -0,0 +1,12 @@
<!DOCTYPE html>
<html>
<head>
<meta name="pypi:repository-version" content="1.0">
<title>Links for anyio</title>
</head>
<body>
<h1>Links for anyio</h1>
<a href="anyio-4.11.0.post24-py3-none-any.whl">anyio-4.11.0.post24-py3-none-any.whl</a><br/>
<a href="anyio-4.11.0.post24.tar.gz">anyio-4.11.0.post24.tar.gz</a><br/>
</body>
</html>

View File

@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<meta name="pypi:repository-version" content="1.0">
<title>Links for anyio</title>
</head>
<body>
<h1>Links for anyio</h1>
<a href="anyio/">anyio</a><br/>
</body>
</html>