Packaging your Python Packages into PyPI (pip)

This is a quick walkthrough on submiting your module for a package. Most of it has been distiled from Peter Down’s article so any credits please send it his way. I’ve modified the walkthrough to use setuptools instead of disutils

For a more verbose account, please read his article.

First-time PyPI packagers

  1. Make sure you register an account at both and
  2. Create a .pypirc file in your ~/.pypirc
index-servers =



PyPI Package directory structure

root-dir/   # arbitrary working directory name

Note: Your package should belong in a subfolder. In this example, all py files relating to the package is in the mypackage/ folder.

  1. Create a file. This contains all the important information that you might need
from setuptools import setup
  name = 'nea_api',
  packages = ['nea_api'],
  version = '0.1.0',
  description = "Python Wrapper for's Data API",
  author = 'David Chua',
  author_email = '[email protected]',
  url = '',
  download_url = '',
  keywords = ['', 'python', 'wrapper', 'psi', 'singapore'],
  classifiers = [],

Note: install_requires is where you put your external dependencies. To get your download_url, you need to push a tag. See below.

Tagging The download_url is a link to a hosted file with your repository’s code. Github will host this for you, but only if you create a git tag. In your repository, type: git tag 0.1 -m “Adds a tag so that we can put this on PyPI.”. Then, type git tag to show a list of tags — you should see 0.1 in the list. Type git push –tags origin master to update your code on Github with the latest tag information. Github creates tarballs for download at{username}/{module_name}/tarball/{tag}. Taken from Peter Downs' article

  1. Create a setup.cfg
description-file =


  1. Test it on PyPI Test. You want to make sure everything’s working first
$ python register -r pypitest
$ python sdist upload -r pypitest

If it all goes well, lets deploy to PyPI Live

  1. Deploy to PyPI Live
$ python register -r pypi
$ python sdist upload -r pypi

You’re done!