A command-line utility that creates projects from project templates, e.g. creating a Python package project from a Python package project template.
npx @tessl/cli install tessl/pypi-cookiecutter@2.6.0A command-line utility that creates projects from project templates (cookiecutters). Cookiecutter enables developers to quickly generate project structures by answering a few questions about their project, making it ideal for scaffolding Python packages, web applications, and other software projects.
pip install cookiecutter or pipx install cookiecutterfrom cookiecutter.main import cookiecutterFor CLI usage:
from cookiecutter.cli import main# Create project from GitHub template
cookiecutter gh:audreyfeldroy/cookiecutter-pypackage
# Create project from local template
cookiecutter ./my-template-directory/
# Create project with no user input (use defaults)
cookiecutter template_path --no-input
# Create project with extra context
cookiecutter template_path --no-input key1=value1 key2=value2from cookiecutter.main import cookiecutter
# Create project from local template
result = cookiecutter('cookiecutter-pypackage/')
# Create project from remote template with extra context
result = cookiecutter(
'gh:audreyfeldroy/cookiecutter-pypackage',
extra_context={'project_name': 'my-awesome-project', 'author': 'Jane Doe'},
no_input=True
)
# Create project with custom output directory
result = cookiecutter(
'template-path',
output_dir='/path/to/projects',
overwrite_if_exists=True
)Cookiecutter's architecture centers around template processing and user interaction:
cookiecutter.json files to generate template variables and promptsThis design enables maximum flexibility for template creators while providing a consistent, user-friendly interface for project generation.
Core functionality for generating projects from templates, including the primary cookiecutter() function and CLI interface.
def cookiecutter(
template,
checkout=None,
no_input=False,
extra_context=None,
replay=None,
overwrite_if_exists=False,
output_dir='.',
config_file=None,
default_config=False,
password=None,
directory=None,
skip_if_file_exists=False,
accept_hooks=True,
keep_project_on_failure=False
): ...User configuration handling with defaults, file-based config, and runtime overrides for customizing cookiecutter behavior.
def get_user_config(config_file=None, default_config=False): ...
def get_config(config_path): ...
def merge_configs(default, overwrite): ...Context generation, file rendering, and template discovery functionality that powers cookiecutter's core template processing capabilities.
def generate_context(context_file='cookiecutter.json', default_context=None, extra_context=None): ...
def generate_files(repo_dir, context=None, output_dir='.', overwrite_if_exists=False, skip_if_file_exists=False, accept_hooks=True, keep_project_on_failure=False): ...
def find_template(repo_dir, env): ...Support for Git repositories, zip files, and URL-based templates with automatic cloning, extraction, and local caching.
def determine_repo_dir(template, abbreviations, clone_to_dir, checkout, no_input, password=None, directory=None): ...
def clone(repo_url, checkout=None, clone_to_dir=".", no_input=False): ...
def unzip(zip_uri, is_url, clone_to_dir=".", no_input=False, password=None): ...Interactive prompts for template variables with support for different input types including text, choices, boolean, and JSON inputs.
def prompt_for_config(context, no_input=False): ...
def read_user_variable(var_name, default_value, prompts=None, prefix=""): ...
def read_user_choice(var_name, options, prompts=None, prefix=""): ...Pre/post generation hook system and Jinja2 template extensions for enhanced templating capabilities.
def run_hook(hook_name, project_dir, context): ...
def run_pre_prompt_hook(repo_dir): ...
class JsonifyExtension(Extension): ...
class SlugifyExtension(Extension): ...Helper functions, logging configuration, replay functionality, and comprehensive exception hierarchy.
def rmtree(path): ...
def make_sure_path_exists(path): ...
def configure_logger(stream_level='DEBUG', debug_file=None): ...
class CookiecutterException(Exception): ...__version__: str # Package version string (access via cookiecutter.__version__)import cookiecutter
print(cookiecutter.__version__) # e.g., "2.6.0"