Create a pip-installable python package in 2 minutes

Between cookiecutter, cookiecutter-pipproject, and some reasonably fast typing, you can now get version 0 of a project up to pypi and pip installable in pretty much no time at all (not that you should actually do that, but you know what I mean).

The down and dirty:

pip install cookiecutter
cd projectname
git init
git add -A
git commit -m 'first commit'
git remote add origin foo://bar
git push origin master
git tag {{version}} -m 'adds the version you entered in cookiecutter as the first tag for release'
git push --tags origin master
cd ~
touch .pypirc
nano .pypirc
(add snippet from below)
cd -
python register -r pypitest
python sdist upload -r pypitest

And then you have it, the package is up on the test pypi server.  Simply repeat the last two commands with pypi instead of pypitest to push to the real pip server.

As for that .pypirc file, that contains your credentials for pypi and pypi test (you need to log onto those and make accounts before you can really do this).  It will look like this:

[distutils] # this tells distutils what package indexes you can push to
index-servers =

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

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


So total of 14 commands, 2 accounts made, and a remote git repo set up somewhere ( is assumed by cookiecutter-pipproject), and you are up and running. Would be a difficult 2 minutes, but probably could be done.

Huge thanks to Peter Downs for his great blog on the last bit of this, which has been my personal reference in the past. If you'd like to use, contribute to, or otherwise examine the cookiecutter template referenced, you can check it out here:







Will has a background in Mechanical Engineering from Auburn, but mostly just writes software now. He was the first employee at Predikto, and is currently building out the premiere platform for predictive maintenance in heavy industry there as Chief Scientist. When not working on that, he is generally working on something related to python, data science or cycling.


Leave a Reply