Leveraging Cookiecutter to Publish Python Packages

I started working on my first Python package (which is far from ready, but I will definitely post about it when I have a version worth sharing). When trying to find resources of how to publish it to make it available for the community, I felt a bit overwhelmed. The setup for it to work properly involves a lot of individual files. These need to be in the right structure with the right content. As you can imagine, this is very prone to errors.

Enter Cookiecutter. Cookiecutter is a tool that allows you to very easily create projects from templates. This way, you can find a template of your liking and use it as a boilerplate for the development of your package. This is huge, since (as you may know) DevOps knowledge is not precisely a strong suit for Data Scientists.

Cookiecutter

The most popular Cookiecutter for Python packages (and with good reason) is the one created by audreyr. The resulting project has some terrific out-of-the-box features, such as Travis CI integration, Sphinx documentation ready to be imported into Read the Docs, and auto release to PyPI.

However, I felt it was lacking a couple of things that I would like for a Data Science package. Therefore, I decided to fork it and tune it to my needs. In the process, I took the liberty to add a few quality-of-life improvements, which resulted in the following features:

  • Updated requirements to more recent versions
  • Concentrated original documentation into the project’s README
  • Added a data directory (together with its corresponding README)
  • Added an examples directory
  • Updated the generated project’s README from .rst to .md
  • Changed the generated project’s default documentation style from Alabaster to Sphinx-rtd-theme (much nicer)
  • Added issue templates for bugs reports, documentation improvements, feature suggestions, and others.
  • More to come!

You can find my Cookiecutter template for a Python (Data Science) package here. In the same repository, you will find both a Quickstart and a Tutorial to get you up and running in no time.

I hope to keep on working and improving this Cookiecutter. On the meantime, if you have suggestions for its improvement, file a new issue in Github or drop me a line on Twitter (@amoncadatorres).