How to submit a package to PyPI

By | October 29, 2015

How to submit a package to PyPI

PyPI (Python Package Index) is a repository of software for the Python programming language. This article will tell you how to submit your package to PyPI, so others are able to install it with easy_install or pip. The offical document is at

Create your accounts

You must create accounts on PyPI Live and PyPI Test before upload your code.

After registration, create a pypirc configuration file at ~/. This file holds your information for authenticating with PyPI, both the live and the test versions.

index-servers =

username: {{your_username}}
password: {{your_password}}

username: {{your_username}}
password: {{your_password}}

Prepare your package

Every package on PyPI needs to have a file called at the root of the directory. If you are using a markdown-formatted README file you’ll also need a setup.cfg file. Also, you’ll want a LICENSE.txt file describing what can be done with your code. So the directory structure would look like this:


This is metadata about your library.

from distutils.core import setup
  name = 'mypackage',
  packages = ['mypackage'],
  version = '0.1',
  description = 'A random test lib',
  author = 'Peter Downs',
  author_email = 'your email address',
  url = '',
  keywords = ['testing', 'logging', 'example'],
  classifiers = [],


This tells PyPI where your README file is.

description-file =

Upload your package to PyPI

Run the following code to
1. Register your package against PyPI (and test) server, to make sure you’ve set up everything correctly.
2. Upload the package to PyPI (and test) server

python register -r pypitest
python sdist upload -r pypitest
python register -r pypi
python sdist upload -r pypi

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.