Blog

Cookiecutter Pypackage

Feb 21, 2022 | 1 minute read

Tags: python, cookiecutter, pypackage

cookiecutter-pypackage is one of possibly hundreds out there and I invite you to have a look at them if this one doesn’t meet your requirements. So why yet another cookiecutter template for Python packages?

More often than not achieving consistency across all your code projects is difficult when you don’t have a boilerplace you can easily replicate, but more importantly, a boilerplate that enables you with capabilities to spin multiple testing environments with linting and typings check-ups for different Python versions, locally and on your CI.

cookiecutter-pypackage comes with the following packages:

  • pytest for running tests.
  • mypy for checking typings.
  • flake8 for linting and checking code style.
  • tox for running tests in various isolated environments.

Tox acts as a frontend to Continuous Integration servers, greatly reducing boilerplate and merging CI and shell-based testing. Thismakes it easy to:

  • Test against different versions of Python (which would have alerted Kyle that the library hadn’t been tested against his install version).
  • Test against different dependency versions.
  • Capture and run setup steps/ad hoc commands.
  • Isolate environment variables - By design, tox does not pass any evars from the system. Instead you are asked to explicitly declare them.
  • Do all the above across Windows / macOS / Linux.

Consistency is king!