2017-12-01 Python and PyPI

I recently rewrote my Mastodon Archive tool to be uploaded to PyPI. Steve Ivy provided the initial push and code, as you can see in this Mastodon thread. But eventually I was stuck.

see in this Mastodon thread

I was setting up Travis CI to publish my code to PyPI and I was seeing “UnicodeEncodeError: latin-1” at the very end of the deployment. I didn’t know what I was doing. Everything finished without an error?

I decided to give this a try myself, locally. Mark Pilgrim had written something about Packaging Python Libraries but I always ended up with an error:

Packaging Python Libraries

$ python3 setup.py sdist upload
...
running upload
Password:
Submitting dist/mastodon_archive-0.0.1.tar.gz to https://upload.pypi.org/legacy/
Upload failed (403): Invalid or non-existent authentication information.
error: Upload failed (403): Invalid or non-existent authentication information.

Finally, Joe Friedl was able to help me, as you can see in this Mastodon thread. The official documentation on Uploading your Project to PyPI had already mentioned `twine`. Apparently we no longer use `python3 setup.py sdist upload` – now it’s `python3 setup.py sdist` and `twine upload dist/*`.

in this Mastodon thread

Uploading your Project to PyPI

Installing `twine` ran into a permission issue on this laptop (running macOS and Homebrew):

$ pip3 install twine
...
PermissionError: [Errno 13] Permission denied: '/usr/local/man'
$ sudo mkdir  /usr/local/man
$ sudo chown alex /usr/local/man
$ pip3 install twine
...
$ twine upload dist/mastodon_archive-0.0.1.tar.gz
Uploading distributions to https://upload.pypi.org/legacy/
Enter your username: kensanata
Enter your password:
Uploading mastodon_archive-0.0.1.tar.gz

Yay!

And I can tear down the Travis CI integration. 😄

Here it is: mastodon-archive.

mastodon-archive

​#Python