PIP-Talk - Week 34

Every week going forward I plan to write a little about interesting modules/libraries available for Python.

The topic for this week is: cookiecutter


Background: cookiecutter

Cookiecutter is a cross-platform command-line utility that creates projects from project templates.

Every time you start a new project you have to initialize your project with a valid folder structure and lots of configuration for your documentation, tests, builds etc. cookiecutter solves these setup/configuration tasks and will automatically setup your project the way you want it.

  • Supported programming languages or markup format: Python, JavaScript, Ruby, CoffeeScript, RST, Markdown, CSS, HTML.
  • Templates can be in located in the filesystem, as a ZIP-file or on a VCS-Server (Git/Hg) like GitHub.
  • It reads a settings file (cookiecutter.json) or prompts the user interactivly for the settings.
  • Then it takes the template and apply the settings into the new directory structure.

Sources


Install

pip install cookiecutter

Example

If you would like to try it out, you just need to enter this:

cookiecutter https://github.com/audreyfeldroy/cookiecutter-pypackage.git

Cookiecutter will then startup and ask you a number of questions (your name, email, github account etc). Thereafter it will create the folder structure and needed configuration for your new project.

You can even create your own template (local folder or a git repos) or use a simple cookiecutter.json configuration to save your needed configuration.

A simple cookiecutter.json configuration

{

  "full_name": "Alice Cookie",

  "email": "[email protected]",

  "project_name": "Django Boilerplate",

  "version": "0.1.0"

} 

Kickstarting projects with Cookiecutter - Youtube

https://www.youtube.com/watch?v=nExL0SgKsDY