Files
Dokumentace/Python/TEMPLATE.md
T

2.4 KiB

Template Generation Request

Create a template/ folder in project root with reusable files for new Python projects.

Required Structure

template/
├── .env                    # Environment variables (sample)
├── .gitignore              # Git ignore rules
├── CHANGELOG.md            # Changelog template
├── PROJECT.md              # Project documentation template
├── README.md               # Project overview, tool descriptions, build instructions
├── <tool_name>.py          # Entry point — named by purpose or tool name
├── <tool_name>.spec        # PyInstaller spec (only for projects shipping an .exe)
├── prebuild.py             # Pre-build script: venv check, version print, console= rewrite
├── pyproject.toml          # Poetry config (ruff, mypy, pytest)
├── docs/
│   └── .gitkeep            # Detailed documentation lives here, never in the root
├── src/
│   ├── __init__.py
│   ├── _version.py         # Version fallback for PyInstaller
│   └── constants.py        # Version extraction from toml + DEBUG mode
└── tests/
    ├── __init__.py
    └── test_constants.py   # Basic test

CLAUDE.md, AGENTS.md and DESIGN_DOCUMENT_PYTHON.md are not part of the template — they are copied into the project root from the documentation repository, which stays their source of truth. The copies themselves are committed with the project and are never edited in place.

Key Features

  • Version extraction from pyproject.toml with _version.py fallback for PyInstaller builds
  • DEBUG mode via ENV_DEBUG=true in .env (adds "DEV" suffix to version: v1.2.3DEV)
  • Build configuration via ENV_BUILD_CONSOLE and ENV_BUILD_SPEC in .env, applied by prebuild.py
  • loguru for logging (never print for debugging)
  • Poetry for dependency management, poetry.lock committed
  • pytest for testing (no unittest)
  • ruff + mypy for linting and type checking (120-character lines)

Rules

  • No .example suffixes - the folder itself is the separator
  • Generic/reusable format
  • Keep files simple and minimal
  • .gitignore is the shared core from Project template/.gitignore with Python/.gitignore appended
  • Entry point is named by purpose or tool name — a project may have several
  • prebuild.py and the .spec file are only needed for projects distributed as a standalone .exe