Cookiecutter PyLib

Cookiecutter template for a Python PyPI ready package library, extends upon audreyr/cookiecutter-pypackage

Instead of hacking boilerplate setup you can jump to coding immediately. All the check are already in place and a your package can be nicely released to pypi.

Linux build status on Travis CI Windows build status on Appveyor Documentation build status Maintainability License Tweet about this project!-1EAEDB.svg


  • Testing setup with unittest and python test or py.test
  • Travis-CI: Ready for Travis Continuous Integration testing
  • Tox testing: Setup to easily test for multiple Python versions
  • Sphinx docs: Documentation ready for generation with, for example, ReadTheDocs
  • Bumpversion: Pre-configured version bumping with a single command
  • Auto-release to PyPI when you push a new tag to master (optional)
  • Split file requirements management with inheritance and support for private locally installed packages
  • Command line interface using Click (optional)
  • Initialization of Git repo, github origin remote and git-flow
  • Python virtual environment bootstrapping
  • Git master/develop local/origin sync with a single command
  • Release (sync, test, bump, publish) with a single command


Before we start we need some tooling:

curl | python
pipsi install cookiecutter
pipsi install detox
pipsi install pew
pipsi install vex
pipsi install pipenv
pip install "backports.shutil_which ; python_version < '3.4'"

Now we can generate and initialize a Django app package project:


You’ll be prompted for some infomation, based on your choices cookiecutter create a directory that is your new package.

This directory should contain fully initialized project. Empty but passing tests and ready to be pushed and released.

Post generation provisioning

  • Activate virtual environemnt and run tests with tox
  • Create a repo on Github (or Bitbucket)
  • Add the repo to your Travis-CI account.
  • Add the repo to your ReadTheDocs account + turn on the ReadTheDocs service hook.
  • Update requirements/base.txt file that specifies the packages you will need for your project and their versions. For more info see the pip docs for requirements files.

For more details, see the cookiecutter-pylib tutorial.

Running Tests

Code has been written, but does it actually work? Let’s find out!

source .pyvenv/bin/activate
(pyvenv) $ pip install -r requirements/development.txt
(pyvenv) $ pytest
(pyvenv) $ python test
(pyvenv) $ tox

Register releasing on PyPI

First make sure you have newest setuptools installed:

pip install pip setuptools -U

Once you’ve got at least a prototype working and tests running, it’s time to register the app on PyPI:

python register

Time to release a new version and upload it to PyPi? Bam!

$ make publish

It will sync your local and origin repo, test, increment version number, setup and release package then push to origin master.