What is Cookiecutter?
Cookiecutter is a command-line utility that creates projects from cookiecutters (project templates), e.g. creating a Python package project from a Python package project template.
Cookiecutter is available on PyPI. Use
pip to download and install:
$ pip install cookiecutter
You can generate a new project from a template by using the following command:
$ cookiecutter https://github.com/pytest-dev/cookiecutter-pytest-plugin
This will not only
git clone the template but also start the generation process.
Each Cookiecutter template uses variables, which are specified in the template, that it replaces in all of the directory and file names, but also in text such as source code or markdown formats.
Cookiecutter prompts you for information regarding your plugin based on aforementioned variables:
full_name [Raphael Pierzina]: Andreas Pelme email [email@example.com]: firstname.lastname@example.org github_username [hackebrot]: pelme plugin_name [foobar]: awesome short_description [A simple plugin to use with pytest]: version [0.1.0]: pytest_version [2.9.0]: 2.9.1
The values in the square brackets (f.i.
[foobar]) are defaults for the according variables.
Once you answered to the questions, Cookiecutter renders the the project:
pytest-awesome/ ├── LICENSE ├── README.rst ├── pytest_awesome.py ├── setup.py ├── tests │ ├── conftest.py │ └── test_awesome.py └── tox.ini
There you go - you just created a minimal pytest plugin: