Making your Python code installable with PIP

I like to install 3rd party Python libraries using pip. Pip and easy_install can automatically download and install Python code from PyPi (also known as The Cheese Shop). This is how to publish your own Python code on PyPi, so people can do this:

pip install yourawesomeproject

The packaging chapter in dive into python 3 is a good starting point, also for Python 2, and this guide is a shorter rehash of that chapter. Just enough to get you started with publishing code on PyPi.

Step 1: Structure your code

Follow the tutorial, and you should have the right structure. Let's assume that you have the following basic structure for your project "foolib":


Add COPYING.txt, README.txt,,


Example (choose classifier strings from this list):

from setuptools import setup
    name = 'foolib',
    packages = ['foolib'],
    version = '0.0.1',
    description = 'Does something foo',
    author='Your Name',
        'Programming Language :: Python',
        'Programming Language :: Python :: 2',
        'License :: OSI Approved :: GNU General Public License (GPL)',
        'Operating System :: OS Independent',
        'Development Status :: 1 - Planning',
        'Environment :: Console',
        'Intended Audience :: Science/Research',
        'Topic :: Scientific/Engineering :: GIS'


include COPYING.txt

Step 2: Build distribution files

This is how to publish a binary distribution of your code on PyPi

# check the configuration
python check
# build Python eggs and publish in PyPi
python register bdist_egg upload

This has added some new folders in the root of your library:


And now, anyone can install your Python library using PIP or easy_install

pip install foolib

Leave a Comment

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