Suppose we have written a Python package, like pypdb. Our goal is to make it possible for users to install the package using PyPI:

$ pip install pypdb

Initialization and setup

  • Make an account on PyPI. Note: Depending on your project scale, consider also making a matching account on TestPyPI for testing
  • In your computer’s home folder , create a .pypirc file, which allows authentication

    [distutils] index-servers = pypi pypitest

    [pypi] repository= username=your_username password=your_password

Set the appropriate permissions

$ chmod 600 ~/.pypirc

Setup project structure

Follow the instructions here for properly setting up a Python project. In the root directory, add a file setup.cfg

description-file =

Publish the project

First, register and upload it on the test server

$ python register -r pypitest
$ python sdist upload -r pypitest

If all goes okay, upload to the live server

$ python register -r pypi
$ python sdist upload -r pypi

Updating the package

This is really only necessary when the actual package changes, you can mess with the demos and README on GitHub all you want because that’s not stored on PyPI

  • Update the code
  • Update and increment the version number
  • Push to Github
  • Now update git tags:

    $ git tag 0.5 -m “latest version” $ git push –tags origin master

  • Now update the PyPI listing with the newest version:

    $ python sdist upload -r pypi


Issues authenticating when uploading to PyPI from Terminal

You might need to make a file at ~/.pypirc containing

index-servers =

username: <username>
password: <pass>

This will help avoid having to login elsewhere