Improve DirWithoutEntrypoint error message (#3690)

Ran into this and couldn't tell what the problem was without the path
attached.
This commit is contained in:
konsti 2024-05-21 13:21:20 +02:00 committed by GitHub
parent 906f653062
commit 2c4088a518
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 6 additions and 4 deletions

View file

@ -1,4 +1,5 @@
use std::path::PathBuf;
use tokio::task::JoinError;
use zip::result::ZipError;
@ -7,6 +8,7 @@ use distribution_types::ParsedUrlError;
use pep440_rs::Version;
use pypi_types::HashDigest;
use uv_client::BetterReqwestError;
use uv_fs::Simplified;
use uv_normalize::PackageName;
#[derive(Debug, thiserror::Error)]
@ -60,8 +62,8 @@ pub enum Error {
DistInfo(#[from] install_wheel_rs::Error),
#[error("Failed to read zip archive from built wheel")]
Zip(#[from] ZipError),
#[error("Source distribution directory contains neither readable pyproject.toml nor setup.py")]
DirWithoutEntrypoint,
#[error("Source distribution directory contains neither readable pyproject.toml nor setup.py: `{}`", _0.user_display())]
DirWithoutEntrypoint(PathBuf),
#[error("Failed to extract archive")]
Extract(#[from] uv_extract::Error),
#[error("Source distribution not found at: {0}")]

View file

@ -105,7 +105,7 @@ impl<'a> BuiltWheelIndex<'a> {
let Some(modified) =
ArchiveTimestamp::from_source_tree(&source_dist.path).map_err(Error::CacheRead)?
else {
return Err(Error::DirWithoutEntrypoint);
return Err(Error::DirWithoutEntrypoint(source_dist.path.clone()));
};
// If the distribution is stale, omit it from the index.

View file

@ -978,7 +978,7 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
let Some(modified) =
ArchiveTimestamp::from_source_tree(&resource.path).map_err(Error::CacheRead)?
else {
return Err(Error::DirWithoutEntrypoint);
return Err(Error::DirWithoutEntrypoint(resource.path.to_path_buf()));
};
// Read the existing metadata from the cache.