Python Goodstuff Cookiecutter
Bootstrap your new Python 3 project using Cookiecutter! Start your new package with testing, linting, coverage reports, and automatic releases right out of the box.
- (Optional) Type checking with either MyPy or Pyre
- No nonsense Pytest configuration out of the box.
- Test coverage reports generated by CoveragePy.
- Pylint linter integrated with Pytest.
- Create a command line tool for installation with
- (Optional) Support for Docker and containers.
- (Optional) Makefile for PyPi/Docker releases, tests, and more (Currently *nix Only).
Python Goodstuff relies on Cookiecutter; you will need it installed before you can start your new project!
Generating your new project is now as easy as one command:
Answer the questions when prompted, and Cookiecutter will generate your new project. Congrats, that's it! Now you just need to install your project:
cd my-project virtualenv .env source .env/bin/activate pip install -r requirements.dev.txt python setup.py install
Or, if you generated a Makefile and have GNU Make:
cd my-project make test
Goodstuff creates tests run by Pytest, an assert-based testing framework and alternative to
unittest. On invoking
pytest, Pylint and PyCoverage will also run against your codebase, checking your code style and generating a coverage report.
Tests with Virtualenv/venv
If your environment is managed with
venv, you can run your tests directly from the command line:
source .env/bin/activate pytest
Tests with Make
With the optional Makefile, your tests will be run with
make test, along with your choice of type checking:
Command Line Interface
If you selected a command line interface option, Goodstuff will create a
bin/ folder with an executable named after your package:
bin/ └── myproject
This file creates a call to the
main function in your package's
cli.py file. Place all of your code and/or interfaces to be run into that
cli.py function. When installed with
pip, or a tarball release, this script will automatically be added to your $PATH for usage from the command line.
A Dockerfile for your project can be automatically created. Note that the generated Docker image assumes that you also enabled a command line script:
FROM python:3.6-alpine WORKDIR /usr/src/awesome-project COPY requirements.txt ./ RUN pip install --no-cache-dir -r requirements.txt COPY . . RUN python setup.py install CMD awesome_project
The Dockerfile is based on an Alpine Linux base image
debian-slim images instead, which have fairly good compatibility without being too much larger than the Alpine images.
Makefile (*nix Only)
If you have
/bin/bash on your system plus common *nix utilities, you can use the Makefile for running tests, installing requirements, or building packages.
# Run Tests make test # Build a Release Package based on the version in VERSION make build
The Makefile also integrates with Docker, making it easy to keep your images up to date:
# Build the current image based on VERSION, as well as update the latest make docker-build # Run the docker image make docker-run
This project is licensed under the terms of the MIT License