|
| 1 | +# Poetry Cookiecutter |
| 2 | + |
| 3 | +A simple [Cookiecutter](https://github.com/cookiecutter/cookiecutter) template for scaffolding Python packages and apps. The goal is to provide sane defaults for any application. |
| 4 | + |
| 5 | +## Batteries Included |
| 6 | + |
| 7 | +- **Packaging and dependency management** with [Poetry](https://github.com/python-poetry/poetry) |
| 8 | +- **Task running** with [Poe the Poet](https://github.com/nat-n/poethepoet) |
| 9 | + - **Pre defined** tasks |
| 10 | + - **Code formatting** with [Black](https://github.com/psf/black), [isort](https://github.com/PyCQA/isort) |
| 11 | + - **Code linting** with [Ruff](https://github.com/charliermarsh/ruff) |
| 12 | + - **Tests and test coverage** with [Pytest](https://github.com/pytest-dev/pytest/) |
| 13 | +- **Scaffolding** updates with [Cookiecutter](https://github.com/cookiecutter/cookiecutter) and [Cruft](https://github.com/cruft/cruft) |
| 14 | +- **Documentation generation** with [Mkdocs](https://github.com/mkdocs/mkdocs) and `mkdocstrings` |
| 15 | +- Installing from and publishing to **RISCs private** [PyPI](https://pypi.org/) |
| 16 | +- Simple **Gitignore** for working with Python / PyCharm / VSCode / ... |
| 17 | +- Default **EditorConfig** for Python and miscellaneous files |
| 18 | +- Uses [Google-style docstrings](https://google.github.io/styleguide/pyguide.html#38-comments-and-docstrings) or [NumPy-style](https://numpydoc.readthedocs.io/en/latest/format.html) |
| 19 | +- Ready to use **Docker images** as a base CI/CD |
| 20 | +- Cross-platform support for Linux, macOS (Apple silicon and Intel), and Windows |
| 21 | + |
| 22 | +### Extras |
| 23 | +- Optionally follows the [Conventional Commits](https://www.conventionalcommits.org/) standard to automate [Semantic Versioning](https://semver.org/) and [Keep A Changelog](https://keepachangelog.com/) with [Commitizen](https://github.com/commitizen-tools/commitizen) |
| 24 | + |
| 25 | +### Planned |
| 26 | +- [ ] **Automatic dependency** updates with [RenovateBot]() |
| 27 | + |
| 28 | +## Usage |
| 29 | + |
| 30 | +### Creating a new Python project |
| 31 | + |
| 32 | +1. Install [Cruft](https://github.com/cruft/cruft) and [Cookiecutter](https://github.com/cookiecutter/cookiecutter) |
| 33 | +2. Create a new repository locally |
| 34 | +3. In the directory that contains the cloned repository, run: |
| 35 | + ```sh |
| 36 | + cruft create -f https://gitdma.risc-software.at/common/python-package-template |
| 37 | + ``` |
| 38 | +4. Install the environment with `poetry install` and create a container using `docker build -f Dockerfile-test .` |
| 39 | +5. [Optional] Update your project template by running `cruft update` |
| 40 | + |
| 41 | +## Parameters |
| 42 | + |
| 43 | +| Parameter | Description | |
| 44 | +| ----------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | |
| 45 | +| `package_name` <br> "My Awesome Proect" | The name of the package. Will be slugified to `snake_case` for importing and `kebab-case` for installing. | |
| 46 | +| `package_description` <br> "A single sentence description" | A single-line description of the package. | |
| 47 | +| `package_url` <br> "https://gitdma.risc-software.at/<ID>/<package_name>" | The URL to the package's repository. | |
| 48 | +| `author_name` <br> "Sonja Sunshine" | The full name of the primary author of the package. | |
| 49 | +| `author_email` <br> "sonja.sunshine@risc-software.at" | The email address of the primary author of the package. | |
| 50 | +| `python_version` <br> "3.11" | The minimum Python version that the package requires. | |
| 51 | +| `docstring_style` <br> ["Google", "Numpy"] | Whether to use and validate [NumPy-style](https://numpydoc.readthedocs.io/en/latest/format.html) or [Google-style docstrings](https://google.github.io/styleguide/pyguide.html#38-comments-and-docstrings). | |
| 52 | +| `use_conventional_commits` <br> [true, false] | If true, [Commitizen](https://github.com/commitizen-tools/commitizen) will verify that your commits follow the [Conventional Commits](https://www.conventionalcommits.org/) standard. Then, `cz bump` may be used to automate [Semantic Versioning](https://semver.org/) and [Keep A Changelog](https://keepachangelog.com/). | |
| 53 | + |
| 54 | +## Supported Poe Tasks |
| 55 | + |
| 56 | +- **precommit** Runs formatting, linting, and import sorting |
| 57 | +- **check** Checks if formatting, linting and import sorting are corrcet |
| 58 | +- **test** Runs all unit tests and doctests |
| 59 | +- **docs** Serves documentation in the `docs` folder, also generates API docs from docstrings |
0 commit comments