Meta: Warehouse's handling and validation of distribution filenames · Issue #12316 · pypi/warehouse (original) (raw)

This is a meta-issue, filed to track multiple independent problems and potential solutions to Warehouse's handling of distribution filenames (i.e., sdist and wheel filenames). I'm going to attempt to index all of them, but I'll almost certainly miss one or more.

Background material

Key PEPs and PyPA standards:

Key discussions:

Outstanding issues and PRs:

Outstanding issues

Warehouse does not support normalized namespace package names

Per both the discuss thread and #10030: namespace packages are commonly denoted as package.foo, which gets normalized to package-foo (PEP 503) and package_foo (wheel-style distribution name).

As such, Warehouse should accept wheels and sdists that start with package_foo for the package.foo package. But it currently doesn't, and complains about a mismatched prefix instead.

The relevant code:

# Make sure that our filename matches the project that it is being uploaded
# to.
prefix = pkg_resources.safe_name(project.name).lower()
if not pkg_resources.safe_name(filename).lower().startswith(prefix):
raise _exc_with_message(
HTTPBadRequest,
"Start filename for {!r} with {!r}.".format(project.name, prefix),
)

Warehouse accepts invalid wheel filenames

Separately, Warehouse's current wheel filename validation is probably overly permissive.

This happens in a few different places: