Releasing dev version of your package to PyPI


PyPI (Python Package Index) has become a central place for python developers these days to look for third party libraries. Common tools such as easy_install, pip or buildout by default will look into PyPI when asked to install certain packages. For example:-

easy_install Django
easy_install Django==1.3.1
pip install Django
pip install Django==1.2.4

all those commands above will either install the latest stable release of Django or an exact version as specified as argument to the command. For our own mamopublic package, I'd plan to also release it on PyPI so it more inline with other third party libraries that we need to install as part of our project dependencies. The process actually pretty straightforward, once you have sign up and get your username and password, all you have to do is from your package root:-

python setup.py register # this will register the package name on pypi
python setup.py sdist upload

It will ask you to save the username and password in ~/.pypirc so you don't have to
type username and password everytime you want to upload to PyPI. Now I can install mamopublic simpy by just typing easy_install mamopublic. That will grab the tarball from PyPI website. There's always a case that I want to install the latest code from our github commit. I have seen lot of packages on PyPI that allow us to install their latest dev release using command such as:-

easy_install django-nose==dev

Looking around in setuptools/distribute documentation, I didn't found any settings for setup.py that allow us to specify the url to download the package instead from PyPI's tarball. Finally, checking package edit page on PyPI I noticed that there's an input field for download url. So what I did was to change the version in setup.py to 'dev' instead of '1.8' and then upload it to PyPI. Since 'dev' version not exists yet, PyPI happily accept that. PyPI apparently refused to accept upload of package of similar version. You have to bump the version number or delete the package from PyPI first. Then I went to the package edit page and specified the download url pointing to github generated tarball from latest commit.

Now it's possible to install our latest commit simply by using easy_install -U mamopublic==dev.

Kamal Mustafa

CTO

Joined December 2010. Have been doing web development since early 2000 with classic ASP, then moved on to PHP and finally involved with Python/Django since joining Xoxzo Inc. During his spare time Kamal hacks various open source projects at github.