An opinionated, dead-simple cookiecutter for modern Python 3 packages.
Adapted from Audrey's cookiecutter-pypackage
- Testing setup with
py.test
- Future-proof use of Pipfile as opposed to requirements.txt [see pipenv]
- Tox testing: Setup to easily test
- Sphinx docs: Documentation ready for generation and hosting on GitHub Pages
- Bumpversion: Pre-configured version bumping with a single command
- Command line interface with Click
Install the latest Cookiecutter and pipenv (optional, but highly recommended) if you haven't installed it yet.
brew install cookiecutter pipenv
Generate a Python package project
cookiecutter https://github.com/knowsuchagency/python-package-template.git --checkout cloudfoundry
# answer questions to generate project template
cd your_new_project
# generate the virtual environment and activate it
pipenv shell # or whatever you use to manage your venvs
# install package dependencies within venv
pip install -e .[dev]
The last step will install the task runner at the root of the repo, run.py as a command-line
utility {{project_slug}} dev
.
# to run the development server locally
{{project_slug}} runserver
# deploy
{{project_slug}} dev deploy
You should now have a command-line tool {{project_slug}} dev
which you can use to execute common tasks.
This is just a shortcut to the run.py file at the root of your project, meaning you have 3 ways of executing the task runner:
{{project_slug}} dev # or, from project root ./run.py # or python -m run
The following are some of the sub-commands you may find:
Commands: autopep8 Autopep8 modules. clean Remove all build, test, coverage and Python... coverage Check code coverage quickly with the default... dist Build source and wheel package. docs Generate Sphinx HTML documentation, including... install Install Python dependencies. publish_docs Compile docs and publish to GitHub Pages. test Run tests quickly with default Python. test_readme Test README.rst to ensure it will render... tox Run tests in isolated environments using tox. uninstall Uninstalls all Python dependencies.