question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"twine upload" usually fails to upload .asc files

See original GitHub issue

On the most recent Foolscap release, I signed the sdist tarballs as usual, and tried to use twine to upload everything:

% python setup.py sdist --formats=zip,gztar bdist_wheel
% ls dist
foolscap-0.9.1-py2-none-any.whl     foolscap-0.9.1.tar.gz           foolscap-0.9.1.zip
% (gpg sign them all)
% ls dist
foolscap-0.9.1-py2-none-any.whl     foolscap-0.9.1.tar.gz           foolscap-0.9.1.zip
foolscap-0.9.1-py2-none-any.whl.asc foolscap-0.9.1.tar.gz.asc       foolscap-0.9.1.zip.asc
% python setup.py register
% twine upload dist/*

Twine uploaded the tar/zip/whl files, but ignored the .asc signatures, and the resulting pypi page doesn’t show them either.

After some digging, I found that twine/upload.py upload() will only use pre-signed .asc files if the command was run like cd dist; twine upload *. It won’t use them if it was run as cd dist; twine upload ./* or twine upload dist/*. The problem seems to be that the signatures dictionary is indexed by the basename of the signature files, while the lookup key is using the full (original) filename of the tarball/etc with “.asc” appended.

I think it might be simpler and safer to have the code just check for a neighboring .asc file inside the upload loop, something like:

for filename in uploads:
    package = PackageFile.from_filename(filename, comment)
    maybe_sig = package.signed_filename + ".asc"
    if os.path.exists(maybe_sig):
        package.gpg_signature = (os.path.basename(maybe_sig), sigdata)
    ...

I’ll write up a patch for this. I started to look for a way of adding a test, but the code that looks for signatures happens deep enough in upload() that it’d need a oversized mock “Repository” class to exercise the .asc check without actually uploading anything. I’m not sure what the best way to approach the test would be.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
meejahcommented, Sep 27, 2015

With twine 1.5.0, I (just) successfully made another upload of txtorcon that included signatures properly. The command-lines used are in the my Makefile: https://github.com/meejah/txtorcon/blob/master/Makefile#L101

I have not tried with other Twine versions.

0reactions
warnercommented, Sep 29, 2015

great, thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unknown distribution format: '' when uploading to PyPI via Twine
Per the docs for twine upload (emphasis mine): positional arguments: dist The distribution files to upload to the repository (package index) ...
Read more >
twine upload - Read the Docs
This means that you cannot test the exact file you're going to upload to PyPI to ensure that it works before uploading it....
Read more >
Twine Documentation - Read the Docs
Add a helpful error message when an upload fails due to missing a ... Twine allows you to pre-sign your files and pass...
Read more >
How to upload programs to PyPI - Packt Subscription
twine also allows you to pre-create your distribution files, that is, ... your files and pass the .asc files to the command line...
Read more >
Top 5 twine Code Examples - Snyk
Usually dist/* . May additionally contain " "a .asc file to include an existing signature with the " "file upload.", ) parsed_args =...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found