|
| 1 | +# Python Project Template |
| 2 | +A Python Project template that comes out of the box with configuration for: |
| 3 | +- Packaging and dependency management using [Poetry](https://python-poetry.org) |
| 4 | +- Testing using [pytest](https://pytest.org) |
| 5 | +- Code coverage using [coverage](https://coverage.readthedocs.io) |
| 6 | +- Fomatting using [black](https://black.readthedocs.io) |
| 7 | +- Import sorting using [isort](https://pycqa.github.io/isort) |
| 8 | +- Linting usig [flake8](https://flake8.pycqa.org) |
| 9 | +- Pre-commit validations using [pre-commit](https://pre-commit.com) |
| 10 | +- Workflow automation using [GitHub Actions](https://github.com/features/actions) |
| 11 | + |
| 12 | +## Prerquisites |
| 13 | +- Python 3.12+ (You can update the [`pyproject.toml`](pyproject.toml#L17) for lower versions) |
| 14 | +- Pipx (*optional* - used to install Poetry if not already installed) |
| 15 | + |
| 16 | +## Usage |
| 17 | +- Click the **Use the template** button to use this template to create your Python project |
| 18 | +- Clone your newly created project to your local |
| 19 | + |
| 20 | +### Install Poetry |
| 21 | +Run `make poetry` to install poetry if not installed (requires pipx) |
| 22 | + |
| 23 | +### Install dependencies |
| 24 | +Run `make install` to install the project dependencies defined in the [pyproject.toml](pyproject.toml) file |
| 25 | + |
| 26 | +### Install pre-commit hook |
| 27 | +Run `make precommit` to install the pre-commit hook for the project to format and lint your code automatically before commiting to GitHub |
| 28 | + |
| 29 | +### Format and Lint code |
| 30 | +Run `make lint` to format and lint project code |
| 31 | + |
| 32 | +### Run tests with coverage |
| 33 | +Run `make test` to run the tests defined under the [tests](tests) folder and show coverage report |
| 34 | + |
| 35 | +### Run main script |
| 36 | +A script with the name `app` is defined in the [pyproject.toml](pyproject.toml#L14) file to run the main function as a shell script. |
| 37 | +Run `make run` to run the main script |
| 38 | + |
| 39 | +## Project Structure |
| 40 | + |
| 41 | +``` |
| 42 | +├── .github # Github files |
| 43 | +│ ├── FUNDING.md # GitHub funding |
| 44 | +│ └── workflows # Github Actions Workflows |
| 45 | +│ └── check.yml # Workflow to validate code on push |
| 46 | +├── .gitignore # Git-ignored file list (duh) |
| 47 | +├── .pre-commit-config.yaml # Pre-commit configuration file |
| 48 | +├── LICENSE # Project license |
| 49 | +├── Makefile # Make commands |
| 50 | +├── README.md # Read-me file |
| 51 | +├── pyproject.toml # Configuration file for different tools |
| 52 | +├── project # Main project folder |
| 53 | +│ ├── __init__.py # Init file of the main package |
| 54 | +│ └── app.py # Main Python file of the project |
| 55 | +└── tests # Unit tests for the project |
| 56 | + ├── conftest.py # Pytest configuration, and fixtures, and hooks |
| 57 | + ├── __init__.py # Init file fo the test package |
| 58 | + └── test_app.py # Sample test file |
| 59 | +``` |
0 commit comments