Skip to main content
Built Status ReadTheDocs Coveralls PyPI-Server Monthly Downloads

pyscaffoldext-cookiecutter

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:

pip install pyscaffoldext-cookiecutter

Or, if you prefer pipx:

pipx install pyscaffold  # if you haven't installed pyscaffold yet
pipx inject pyscaffold pyscaffoldext-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:

putup my-proj1 --cookiecutter ~/my-templates/default
putup my-proj2 --cookiecutter gh:something/from-github

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:

putup mypkg \
  --cookiecutter gh:pyscaffold/cookiecutter-pypackage \
  --cookiecutter-params command_line_interface=Argparse use_pytest=y

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:

putup mypkg --cookiecutter gh:pyscaffold/cookiecutter-pypackage

This is roughly equivalent to first create a project using the Cookiecutter template and convert it to PyScaffold afterwards:

cookiecutter --no-input gh:pyscaffold/cookiecutter-pypackage project_name=mypkg
putup mypkg --force

Suitable templates

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:

cookiecutter-something/
└── {{cookiecutter.project_name}}/
    └── src/
        └── {{cookiecutter.package_name}}/
            └── ...

See Cookiecutter for more information about template creation.

Making Changes & Contributing

This project uses pre-commit, please make sure to install it before making any changes:

pip install pre-commit
cd pyscaffoldext-cookiecutter
pre-commit install

It is a good idea to update the hooks to the latest version:

pre-commit autoupdate

Please also check PyScaffold’s contribution guidelines,

Note

This project has been set up using PyScaffold 4.0a2. For details and usage information on PyScaffold see https://pyscaffold.org/.

Release files for pyscaffoldext-cookiecutter 0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyscaffoldext-cookiecutter 0.1
File Size Uploaded
pyscaffoldext-cookiecutter-0.1.tar.gz 26.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pyscaffoldext-cookiecutter 0.1
File Interpreter ABI Platform
pyscaffoldext_cookiecutter-0.1-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 34.5 kB

Release files / pyscaffoldext-cookiecutter-0.1.tar.gz

Download URL pyscaffoldext-cookiecutter-0.1.tar.gz
Size 26.4 kB
Tags Source
SHA-256 checksum
How to use checksums
1fefa9fe43c04acdc85a4dfd7c25f3ab6d1098c3c6906d1b0d39d5026efbddc5
BLAKE2b-256 checksum
How to use checksums
13891fcc80c8f53be9a76299306c4f41917e5a0acdc9273e26b53b39fe53f4f6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.0.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.7.9

Release files / pyscaffoldext_cookiecutter-0.1-py2.py3-none-any.whl

Download URL pyscaffoldext_cookiecutter-0.1-py2.py3-none-any.whl
Size 8.1 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
c401cc9f259b10223e0cf656a40710e31102892344e441f82e8a1b525301cc99
BLAKE2b-256 checksum
How to use checksums
5ca8a7fd1027667cbbbc7e697681577034bf9b724ce5b38cd67715cbfc80ae53
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.0.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.7.9

Release history Release notifications | RSS feed

This release

0.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page