Cookiecutter Django App Package

Cookiecutter template for a Python PyPI ready package library with django app or module, extends upon wooyek/cookiecutter-pylib

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 https://img.shields.io/badge/Say%20Thanks-!-1EAEDB.svg

Features

  • Testing setup with unittest and python setup.py test or py.test
  • Travis-CI: Ready for Travis Continuous Integration testing
  • Tox testing: Setup to easily test for multiple Python and Django 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

Quickstart

Before we start we need some tooling:

curl https://raw.githubusercontent.com/mitsuhiko/pipsi/master/get-pipsi.py | python
pipsi install cookiecutter
pipsi install detox
pipsi install pew
pipsi install vex
pipsi install pipenv

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

cookiecutter https://github.com/wooyek/cookiecutter-django-app.git

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.

Initial tests and linting should fail on links to your project and documentation returning 404 and unused import in empty modules. Once you write some code push changes to the repo and setup Read The Docs all should nicely go green.

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-django-app 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 setup.py 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 setup.py register

Time to release a new version? Bam!

$ make release

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