David Cramer's Blog

Setting Up Your Own PyPi Server

Ever had problems with PyPi being unreachable? Dislike dealing with requirement.txt files just to support a git repository? For a low low price of FREE, and an hour of labor, get your very own PyPi server and solve all of your worries!

Set up Chishop

We're going to jump right into this one. Start by setting up Chishop. Currently the best way is to do so using the DISQUS fork as it contains several fixes. Expect to see all of the hard work in the various forks merged upstream as soon as we get some proper docs going. Follow the instructions in the README to configure Chishop, and your PyPi index.

Now you're going to want to tweak some things that are on by default. For starters, you're probably going to want to proxy the official PyPi repository, and this can be done by enabling a simple flag in your newly created settings.py:


There are many other configuration options, but you're going to have to read the source for those.

Configure PIP/Setuptools/Buildout

Now that you've got a sexy PyPi server up and running, you'll probably want to configure the default index locations for your package managers. It took me a bit of Googling but then I stumpled upon an awesome post by Jacob Kaplan-Moss about dealing with PyPi when it goes down, which describes procedures for configuring PyPi mirrors.

Let's start with pip, which stores its configuration in ~/.pip/pip.conf:

index-url = http://my.chishop/simple

Next up, setuptools, located in ~/.pydistutils.cfg:

index_url = http://my.chishop/simple

And finally, if you use buildout, tweak your buildout.cfg:

index = http://my.chishop/simple

Use It

Now that you have a fully functioning PyPi, kill off your requirements files and build a real setup.py. Hopefully as a bit of inspiration, here's a snippet from Sentry's:

#!/usr/bin/env python

    from setuptools import setup, find_packages
except ImportError:
    from ez_setup import use_setuptools
    from setuptools import setup, find_packages

tests_require = [

    author='David Cramer',
    description = 'Exception Logging to a Database in Django',
    extras_require={'test': tests_require},
        'Framework :: Django',
        'Intended Audience :: Developers',
        'Intended Audience :: System Administrators',
        'Operating System :: OS Independent',
        'Topic :: Software Development'