Description
When a file is created in the ./dist directory before running uv publish, this file causes uv publish to fail. The documentation states that it ignores all other files.
|
<p>Defaults to the <code>dist</code> directory. Selects only wheels and source distributions, while ignoring other files.</p> |
This issue is clearly minor and does not really impact the user much (the error message is quite clear).
However, I think there is no reason to fail if an unknown file is present – as long as a wheel and/or sdist file is found.
If this failure is deliberate, then I would recommend change the documentation.
Steps to reproduce
- Build the project (using
uv build). The build files will be generated in ./dist.
- Create a file in the
./dist directory. On macOS, this could happen e.g. when opening the directory in Finder, which might create the .DS_Store file. Example: touch ./dist/.DS_Store
- Run
uv publish.
This will fail with the error: error: File is neither a wheel nor a source distribution: 'dist/.DS_Store'
Where does this error come from
The error is raised in uv_publish::files_for_publishing:
|
let dist_filename = DistFilename::try_from_normalized_filename(&filename) |
|
.ok_or_else(|| PublishError::InvalidFilename(dist.clone()))?; |
uv_distribution_filename::DistFilename::try_from_normalized_filename in turn checks if the files are valid wheel or sdist files. Example for wheels:
|
let stem = filename.strip_suffix(".whl").ok_or_else(|| { |
|
WheelFilenameError::InvalidWheelFileName( |
|
filename.to_string(), |
|
"Must end with .whl".to_string(), |
|
) |
|
})?; |
Meta
uv version:
uv 0.5.0 (Homebrew 2024-11-07)
Description
When a file is created in the
./distdirectory before runninguv publish, this file causesuv publishto fail. The documentation states that it ignores all other files.uv/docs/reference/cli.md
Line 7835 in 04c445a
This issue is clearly minor and does not really impact the user much (the error message is quite clear).
However, I think there is no reason to fail if an unknown file is present – as long as a wheel and/or sdist file is found.
If this failure is deliberate, then I would recommend change the documentation.
Steps to reproduce
uv build). The build files will be generated in./dist../distdirectory. On macOS, this could happen e.g. when opening the directory in Finder, which might create the.DS_Storefile. Example:touch ./dist/.DS_Storeuv publish.This will fail with the error:
error: File is neither a wheel nor a source distribution: 'dist/.DS_Store'Where does this error come from
The error is raised in
uv_publish::files_for_publishing:uv/crates/uv-publish/src/lib.rs
Lines 257 to 258 in 0b4e5cf
uv_distribution_filename::DistFilename::try_from_normalized_filenamein turn checks if the files are valid wheel or sdist files. Example for wheels:uv/crates/uv-distribution-filename/src/wheel.rs
Lines 29 to 34 in 0b4e5cf
Meta
uv version: