Skip to content

Instantly share code, notes, and snippets.

@mikegrima
Last active December 17, 2019 00:15
Show Gist options
  • Save mikegrima/1f0f106e46b45c154dce9296bfe92071 to your computer and use it in GitHub Desktop.
Save mikegrima/1f0f106e46b45c154dce9296bfe92071 to your computer and use it in GitHub Desktop.
Uploading to PyPI

Uploading to PyPI

Initial things:

  1. Make an account on PyPI

  2. Make sure you have twine and wheel installed in your venv: pip install twine wheel

  3. Make sure you have your ~/.pypirc file that looks like this:

[distutils]
index-servers =
  pypi

[pypi]
username=<INSERT HERE>
password=<INSERT HERE>
  1. Change permissions of that file: chmod 600 ~/.pypirc

  2. Add a setup.cfg file that looks like this:

[metadata]
description-file = README.md

[wheel]
universal = 1

[egg_info]
tag_build =
tag_date = 0
tag_svn_revision = 0
  1. In your setup.py, make sure you have the following classifiers:
classifiers=[
  'Programming Language :: Python',
  'Programming Language :: Python :: 2',
  'Programming Language :: Python :: 2.7',
  'Programming Language :: Python :: 3',
  'Programming Language :: Python :: 3.5',
  'Programming Language :: Python :: 3.6',
],

Build and Upload:

  1. [OPTIONAL] Tag branch: git tag <VERSION> -m "Version blah blah blah..." and then upload: git push --tags REMOTE

  2. If applicable, delete any existing build and dist directories. (this avoids old versions from being re-uploaded)

  3. Build it: python setup.py sdist bdist_wheel --universal

  4. Then upload: twine upload dist/*

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment