Trouble uploading a wheel to PyPI

I’ve started getting errors from PyPI uploading to the legacy endpoint, using my build process which has been working for months if not years.

I’m uploading the latest revision of my cs.lex module whose wheel file’s contents look like this (from my build/upload script’s output):

+ unzip -l .tmp--atomic_directory--hlvf1uv4--cs.lex-20241119--2024-11-19T10:19:53.939770/dist/cs.lex-20241119-py3-none-any.whl
Archive:  .tmp--atomic_directory--hlvf1uv4--cs.lex-20241119--2024-11-19T10:19:53.939770/dist/cs.lex-20241119-py3-none-any.whl
  Length      Date    Time    Name
---------  ---------- -----   ----
    66768  11-18-2024 23:14   cs/lex.py
    39279  11-18-2024 23:20   cs.lex-20241119.dist-info/METADATA
       91  11-18-2024 23:20   cs.lex-20241119.dist-info/WHEEL
        3  11-18-2024 23:20   cs.lex-20241119.dist-info/top_level.txt
      373  11-18-2024 23:20   cs.lex-20241119.dist-info/RECORD
---------                     -------
   106514                     5 files

and the twine upload step recites this:

+ twine upload --repository pypi dist/cs.lex-20241119-py3-none-any.whl dist/cs_lex-20241119.tar.gz
Uploading distributions to https://upload.pypi.org/legacy/
Uploading cs.lex-20241119-py3-none-any.whl
100% ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 74.1/74.1 kB • 00:00 • 63.2 MB/s
WARNING  Error during upload. Retry with the --verbose option for more details.
ERROR    HTTPError: 400 Bad Request from https://upload.pypi.org/legacy/
         Invalid distribution file. WHEEL not found at cs-lex-20241119.dist-info/WHEEL

It seems to me to be there. Hand inspection of the .whl file just before upload shows it there.

This has been working. I last uploaded a package using this same build process on 11 November.

Might something have changed upstream?

Adding the suggested --verbose option doesn’t produce any better information, just a somewhat more raw output. Presumably because the failing check is on PyPI, not within the twine stuff.

+ twine upload --verbose --repository pypi dist/cs.lex-20241119-py3-none-any.whl dist/cs_lex-20241119.tar.gz
INFO     Using configuration from /Users/cameron/.pypirc
Uploading distributions to https://upload.pypi.org/legacy/
INFO     dist/cs.lex-20241119-py3-none-any.whl (30.1 KB)
INFO     dist/cs_lex-20241119.tar.gz (59.0 KB)
INFO     Querying keyring for password
INFO     password set from keyring
INFO     username: __token__
INFO     password: <hidden>
Uploading cs.lex-20241119-py3-none-any.whl
100% ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 74.1/74.1 kB • 00:00 • 63.3 MB/s
INFO     Response from https://upload.pypi.org/legacy/:
         400 Invalid distribution file. WHEEL not found at cs-lex-20241119.dist-info/WHEEL
INFO     <html>
          <head>
           <title>400 Invalid distribution file. WHEEL not found at cs-lex-20241119.dist-info/WHEEL</title>
          </head>
          <body>
           <h1>400 Invalid distribution file. WHEEL not found at cs-lex-20241119.dist-info/WHEEL</h1>
           The server could not comply with the request since it is either malformed or otherwise incorrect.<br/><br/>
         Invalid distribution file. WHEEL not found at cs-lex-20241119.dist-info/WHEEL


          </body>
         </html>
ERROR    HTTPError: 400 Bad Request from https://upload.pypi.org/legacy/
         Invalid distribution file. WHEEL not found at cs-lex-20241119.dist-info/WHEEL

If you look closely at the error message, you can see that it is looking for cs-lex-20241119.dist-info, but you are providing cs.lex-20241119.dist-info. This means pypi is normalizing the package names before looking for the folders. If you generated the wheel yourself, you should adjust your code. If you are using a build backend, make a bug report to them that they are using the wrong folder name.

Aha. I had looked, but must have been only half awake.

Maybe setuptools has changed something subtle (I use python -m build and my pyproject.toml uses setuptools as the build tool).

I’ll go debug. Thanks, I now know the specific problem!