Skip to content

Silent failure when wrong distribution format #895

@bayersglassey-zesty

Description

@bayersglassey-zesty

Your Environment

Thank you for taking the time to report an issue.

To more efficiently resolve this issue, we'd like to know some basic information about your system and setup.

(env) $ uname -a
Linux noo-lappy 5.16.11-76051611-generic #202202230823~1646248261~20.04~2b22243~dev-Ubuntu SMP PREEMPT Th x86_64 x86_64 x86_64 GNU/Linux
(env) $ python --version
Python 3.8.10
(env) $ twine --version
twine version 4.0.0 (importlib-metadata: 4.11.3, keyring: 23.5.0, pkginfo: 1.8.2, requests: 2.27.1, requests-toolbelt: 0.9.1, urllib3: 1.26.9)

I installed twine into a virtualenv with pip install -U twine.
I'm targeting TestPyPi.

The Issue

The twine upload command is silently failing.
It's my fault it's failing: after running python -m build, I wanted to examine the source archive, so I ran gunzip dist/zingest-shared-0.0.1.tar.gz, which transformed it into a TAR file, dist/zingest-shared-0.0.1.tar.
However, twine upload was silently failing because of this:

(env) $ python -m twine upload -r testpypi dist/* || echo "No dice"
Uploading distributions to https://test.pypi.org/legacy/
No dice

...I had to stick a breakpoint in twine/commands/upload.py with ipdb.set_trace() to figure out what the problem was:

> /home/zesty_bag/repos/zestyai/data-ingestion/env/lib/python3.8/site-packages/twine/commands/upload.py(124)upload()
    123 
--> 124     packages_to_upload = [
    125         _make_package(filename, signatures, upload_settings) for filename in uploads

ipdb> 
twine.exceptions.InvalidDistribution: Unknown distribution format: 'zingest-shared-0.0.1.tar'

...that error bubbles up to twine/__main__.py, where there is an attempt to log it, but nothing is output (maybe logging is never configured?):

> /home/zesty_bag/repos/zestyai/data-ingestion/env/lib/python3.8/site-packages/twine/__main__.py(45)main()
     44         error = True
---> 45         logger.error(f"{exc.__class__.__name__}: {exc.args[0]}")
     46 

ipdb> l
     40             f"from {exc.response.url}\n"
     41             f"{exc.response.reason}"
     42         )
     43     except exceptions.TwineException as exc:
     44         error = True
---> 45         logger.error(f"{exc.__class__.__name__}: {exc.args[0]}")
     46 
     47     return error

Steps to Reproduce

  1. Go into a Python package
  2. Build it with python -m build
  3. Turn the source archive into a .tar with gunzip dist/*.gz
  4. Attempt to python -m twine upload -r testpypi dist/*

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions