Extension that combines the flexibility of Cookiecutter templates
with the power of PyScaffold.
Cookiecutter is a flexible utility that allows the definition of templates
for a diverse range of software projects.
On the other hand, PyScaffold is focused in a good out-of-the-box experience
for developing distributable Python packages (exclusively).
Despite the different objectives, it is possible to combine the power of both
tools to create a custom Python project setup.
Quickstart
This extension can be directly installed with pip:
pipinstallpyscaffoldext-cookiecutter
Or, if you prefer pipx:
pipxinstallpyscaffold# if you haven't installed pyscaffold yet
pipxinjectpyscaffoldpyscaffoldext-cookiecutter
Note that, after the installation, putup -h will show a new option
--cookiecutter TEMPLATE.
Use this option to point out which template you want to use (path or url).
The file structure created by Cookiecutter will be refined by PyScaffold
afterwards.
For example:
Please refer to Cookiecutter documentation for more details on possible URLs
and abbreviations.
An additional option --cookiecutter-params is also added, so you can have
more control over the values Cookiecutter uses when rendering the templates
(PyScaffold will not run Cookiecutter’s interactive prompt).
This option takes the form of a space separated list of NAME=VALUE
arguments as showed in the example bellow:
Check the cookiecutter.json file in the repository (or directory) of the template you are
using to see the available parameters.
Please notice PyScaffold already add some default parameters, as indicated in
the section Suitable Templates bellow.
Cookiecutter templates with PyScaffold
The following example shows how to create a new package named mypkg,
that uses a Cookiecutter template, but is enhanced by PyScaffold’s features:
Note that PyScaffold will overwrite some files generated by Cookiecutter,
like setup.py, the __init__.py file under the package folder
and most of the docs folder, in order to provide setuptools_scm
and sphinx integration.
Therefore not all Cookiecutter templates are suitable for this approach.
Ideally, interoperable templates should focus on the file structure inside the
src folder instead of packaging or distributing, since PyScaffold already
handles it under-the-hood. This also means that your template should adhere to
the src-layout if you want to generate files within your Python package.
In addition, PyScaffold runs Cookiecutter with the --no-input flag
activated and thus the user is not prompted for manual configuration. Instead,
PyScaffold injects the following parameters:
author
email
full_name => same as author
project_name => the name of the folder where the project will be generated
repo_name => same as project_name
package_name => putup's --package (as in `import`)
namespace => putup's --namespace (if any)
installable_name => putup's --name (an installable name, like in PyPI/pip install)
project_short_description => putup's description
release_date => equivalent to the day you are running putup
year => equivalent to the year you are running putup
Any extra parameter should be passed using the --cookiecutter-params option.
Accordingly, the template file structure should be similar to: