astral-sh/uv · error · anyhow::Error
The file `{}` appears to be a `pyproject.toml`, `setup.py`,
Error message
The file `{}` appears to be a `pyproject.toml`, `setup.py`, or `setup.cfg` file, which must be in a directory What it means
Error "The file `{}` appears to be a `pyproject.toml`, `setup.py`, or `setup.cfg` file, which must be in a directory" thrown in astral-sh/uv.
Source
Thrown at crates/uv-requirements/src/source_tree.rs:180
project,
extras,
})
}
/// Resolve the [`RequiresDist`] metadata for a given source tree. Attempts to resolve the
/// requirements without building the distribution, even if the project contains (e.g.) a
/// dynamic version since, critically, we don't need to install the package itself; only its
/// dependencies.
async fn resolve_requires_dist(&self, source_tree: &SourceTree) -> Result<RequiresDist> {
// Convert to a buildable source.
let path = fs_err::canonicalize(source_tree.path()).with_context(|| {
format!(
"Failed to canonicalize path to source tree: {}",
source_tree.path().user_display()
)
})?;
let path = path.parent().ok_or_else(|| {
anyhow::anyhow!(
"The file `{}` appears to be a `pyproject.toml`, `setup.py`, or `setup.cfg` file, which must be in a directory",
path.user_display()
)
})?;
// If the path is a `pyproject.toml`, attempt to extract the requirements statically. The
// distribution database will do this too, but we can be even more aggressive here since we
// _only_ need the requirements. So, for example, even if the version is dynamic, we can
// still extract the requirements without performing a build, unlike in the database where
// we typically construct a "complete" metadata object.
if let Some(pyproject_toml) = source_tree.pyproject_toml() {
if let Some(metadata) = self.database.requires_dist(path, pyproject_toml).await? {
return Ok(metadata);
}
}
let Ok(url) = Url::from_directory_path(path).map(DisplaySafeUrl::from_url) else {
return Err(anyhow::anyhow!("Failed to convert path to URL"));View on GitHub (pinned to f1a42680ff)
When it happens
Trigger: Thrown at crates/uv-requirements/src/source_tree.rs:180 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of astral-sh/uv@f1a42680ff (2026-08-16).
Data as JSON: /api/errors/47da0a95c2bb4052.
Report an issue: GitHub.