Skip to content

Bug(?): uv publish fails if unknown files are present in ./dist #8944

@3j14

Description

@3j14

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

  1. Build the project (using uv build). The build files will be generated in ./dist.
  2. 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
  3. 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)

Metadata

Metadata

Assignees

Labels

bugSomething isn't workinggreat writeupA wonderful example of a quality contribution 💜

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions