You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
PEP 427 defines the wheel distribution format, including the wheel filename format. PEP 427 is unfortunately internally inconsistent about distribution name normalization, as mentioned in this comment.
PEP 625 is the most recent sdist filename PEP. It punts to PEP 427 for distribution name normalization, meaning that it carries some of the same ambiguity.
PyPA's Binary Distribution Format Spec is the living standard copy of PEP 427. It eliminates the ambiguity in the original PEP, making it clear that the normalization only applies to the distribution name and is strictly equivalent to PEP 503 normalization, followed by replacing - with _.
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.
"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:
_is_valid_dist_file fails open rather than closed. In particular, anything that ends with .whl and contains a WHEEL file is treated as valid, even if it does not have all of the PyPA/PEP 427 required filename components.
Extended wheel filename validation uses a regular expression, but doesn't actually check all parts of the resulting match:
# Check that if it's a binary wheel, it's on a supported platform
iffilename.endswith(".whl"):
wheel_info=_wheel_file_re.match(filename)
plats=wheel_info.group("plat").split(".")
forplatinplats:
ifnot_valid_platform_tag(plat):
raise_exc_with_message(
HTTPBadRequest,
"Binary wheel '{filename}' has an unsupported "
"platform tag '{plat}'.".format(filename=filename, plat=plat),
)
In particular, the build, pyver, and abi components are never checked, meaning that they might be missing entirely.
As a result, there is at least one invalid wheel filename (pyffmpeg-2.0.5-cp35.cp36.cp37.cp38.cp39-macosx_10_14_x86_64.whl) already present on PyPI, with correspondingly invalid metadata available via the JSON API (note the incorrect python_version field):
So, to summarize: there are some distribution filenames that PyPI incorrectly accepts, and some other filenames that PyPI incorrectly rejects, all modulo the current PEPs and living PyPA specifications.
Separately, there's a whole rats' nest of presentation issues and ambiguity between package names, distribution names, etc. I think these are mostly separate from the question of distribution filename acceptance and validation, but they'll be important to consider as well.
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:
-
with_
.Key discussions:
Outstanding issues and PRs:
.
replaced with_
#10030: Warehouse does not currently except distribution filenames that have been normalized from.
to_
.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 topackage-foo
(PEP 503) andpackage_foo
(wheel-style distribution name).As such, Warehouse should accept wheels and sdists that start with
package_foo
for thepackage.foo
package. But it currently doesn't, and complains about a mismatched prefix instead.The relevant code:
warehouse/warehouse/forklift/legacy.py
Lines 1133 to 1140 in 68d1216
Warehouse accepts invalid wheel filenames
Separately, Warehouse's current wheel filename validation is probably overly permissive.
This happens in a few different places:
_is_valid_dist_file
fails open rather than closed. In particular, anything that ends with.whl
and contains aWHEEL
file is treated as valid, even if it does not have all of the PyPA/PEP 427 required filename components.Extended wheel filename validation uses a regular expression, but doesn't actually check all parts of the resulting match:
warehouse/warehouse/forklift/legacy.py
Lines 1265 to 1275 in 68d1216
In particular, the
build
,pyver
, andabi
components are never checked, meaning that they might be missing entirely.As a result, there is at least one invalid wheel filename (
pyffmpeg-2.0.5-cp35.cp36.cp37.cp38.cp39-macosx_10_14_x86_64.whl
) already present on PyPI, with correspondingly invalid metadata available via the JSON API (note the incorrectpython_version
field):The text was updated successfully, but these errors were encountered: