pyptmpl.creator_core package

Submodules

pyptmpl.creator_core.ci_ops module

Pre-commit and CI automation setup operations.

setup_github_actions(project_dir: Path, python_version: str, load_template: Callable[[str], str], render_template: Callable[[...], str]) None[source]

Create .github/dependabot.yml and workflow YAML files.

setup_prek(project_dir: Path, package_name: str, python_version: str, run_fn: Callable[[list[str], Path | None], None], load_template: Callable[[str], str], render_template: Callable[[...], str]) None[source]

Add prek to dev dependencies and write .pre-commit-config.yaml.

pyptmpl.creator_core.license_ops module

License matching, pyproject patching, and interactive license selection.

match_pypi_classifier(spdx_key: str, classifiers: list[str]) str[source]

Return the best-matching PyPI License :: classifier for an SPDX key.

pick_license(project_dir: Path, python_version: str, scancode_index_url: str, scancode_base_url: str, urlopen: Callable[[...], Any], update_pyproject_license_fn: Callable[[Path, str, str], None]) None[source]

Interactively fetch, filter, and download a license from scancode-licensedb.

update_pyproject_license(project_dir: Path, spdx_name: str, python_version: str, get_license_classifier: Callable[[str], str]) None[source]

Patch license and classifier block in an existing pyproject.toml.

pyptmpl.creator_core.project_ops module

Project scaffolding operations grouped by concern.

class GitAuthor(name: str, email: str)[source]

Bases: NamedTuple

Git author information.

email: str

Alias for field number 1

name: str

Alias for field number 0

check_uv() None[source]

Raise SystemExit if uv is not available on PATH.

create_smoke_test(project_dir: Path, package_name: str, load_template: Callable[[str], str], render_template: Callable[[...], str]) None[source]

Create a minimal importable smoke test.

create_venv(project_dir: Path, python_version: str, run_fn: Callable[[list[str], Path | None], None]) None[source]

Create a virtual environment inside the project directory.

get_git_author() GitAuthor[source]

Return the git user name/email, falling back to placeholders.

infer_package_name_from_pyproject(project_dir: Path, *, strict: bool = False) str | None[source]

Infer import package name from project.name in pyproject.toml.

infer_project_name_from_pyproject(project_dir: Path, *, strict: bool = False) str | None[source]

Infer project.name from pyproject.toml.

infer_python_version_from_pyproject(project_dir: Path, default: str, *, strict: bool = False) str[source]

Infer major.minor Python version from pyproject.toml.

init_project(project_name: str, python_version: str, cwd: Path, run_fn: Callable[[list[str], Path | None], None]) Path[source]

Run uv init –lib and return the created project directory.

run_cmd(cmd: list[str], cwd: Path | None = None) None[source]

Run a command, raising SystemExit on non-zero exit.

setup_docs_build_assets(project_dir: Path, package_name: str, load_template: Callable[[str], str], render_template: Callable[[...], str]) None[source]

Create docs and build scaffolding files.

setup_gitignore(project_dir: Path, load_template: Callable[[str], str]) None[source]

Create or augment .gitignore with Python-standard entries.

setup_justfiles(project_dir: Path, load_template: Callable[[str], str]) None[source]

Create a single root justfile.

setup_typos(project_dir: Path, load_template: Callable[[str], str]) None[source]

Create typos.toml if it does not exist.

setup_vscode(project_dir: Path, load_template: Callable[[str], str]) None[source]

Write VS Code workspace settings.

setup_yamllint(project_dir: Path, load_template: Callable[[str], str]) None[source]

Create .yamllint if it does not exist.

sync_project(project_dir: Path, run_fn: Callable[[list[str], Path | None], None]) None[source]

Sync project dependencies and materialize uv.lock.

write_pyproject(project_dir: Path, project_name: str, package_name: str, python_version: str, description: str, author: GitAuthor, default_license_id: str, load_template: Callable[[str], str], render_template: Callable[[...], str], get_license_classifier: Callable[[str], str]) None[source]

Overwrite pyproject.toml with the canonical template.

pyptmpl.creator_core.templates module

Template loading and rendering utilities.

load_template(relative_path: str) str[source]

Load a template file from the bundled templates directory.

render_template(template: str, **kwargs: str) str[source]

Replace {{KEY}} placeholders in template with provided values.

Module contents

Internal creator components split by concern.