|
1 | 1 | # Python Training Project by [devminds GmbH](https://devminds.ch) |
| 2 | + |
| 3 | +This Python project is used for DevOps CI/CD trainings. |
| 4 | + |
| 5 | +The project contains a Python package providing a CLI to calculate the sum of two numbers: |
| 6 | + |
| 7 | +```bash |
| 8 | +Usage: python_training_project [OPTIONS] COMMAND [ARGS]... |
| 9 | + |
| 10 | +Options: |
| 11 | + --version Show the version and exit. |
| 12 | + --help Show this message and exit. |
| 13 | + |
| 14 | +Commands: |
| 15 | + sum |
| 16 | +``` |
| 17 | + |
| 18 | + |
| 19 | +## Toolchain |
| 20 | + |
| 21 | +The Python package is based on the following toolchain: |
| 22 | + |
| 23 | +* [uv](https://docs.astral.sh/uv/) for dependencies, virtual environment, package build and deployment |
| 24 | +* [Sphinx](https://www.sphinx-doc.org/en/master/) for documentation |
| 25 | +* [Flake8](https://flake8.pycqa.org/en/latest/) for style guide enforcement |
| 26 | +* [mypy](https://mypy-lang.org/) for static type checking |
| 27 | +* [Pylint](https://www.pylint.org/) for static code analysis |
| 28 | +* [Ruff](https://docs.astral.sh/ruff/) for linting and code formatting |
| 29 | +* [pytest](https://docs.pytest.org/en/stable/) for test creation and execution |
| 30 | + |
| 31 | + |
| 32 | +## Directory structure |
| 33 | + |
| 34 | +``` |
| 35 | +├── build Reserved folder for build artifacts |
| 36 | +├── dist Reserved folder for build artifacts |
| 37 | +├── docs Sphinx documentation |
| 38 | +├── src Python package source code |
| 39 | +├── tests Python tests |
| 40 | +└── tools Scripts |
| 41 | +
|
| 42 | +``` |
| 43 | + |
| 44 | +## Build, test and deploy instructions |
| 45 | + |
| 46 | +All steps required to build, test or deploy the Python package are wrapped in separate shell scripts. |
| 47 | + |
| 48 | +Check the content of the corresponding scripts for details. |
| 49 | + |
| 50 | +### Build documentation |
| 51 | + |
| 52 | +Build the Sphinx documentation: |
| 53 | + |
| 54 | +```bash |
| 55 | +./tools/build-docs.sh |
| 56 | +``` |
| 57 | + |
| 58 | +### Build Python package |
| 59 | + |
| 60 | +Build the Python package: |
| 61 | + |
| 62 | +```bash |
| 63 | +./tools/build-package.sh |
| 64 | +``` |
| 65 | + |
| 66 | +### Run Python linters |
| 67 | + |
| 68 | +Run static code analysis: |
| 69 | + |
| 70 | +```bash |
| 71 | +./tools/lint-package.sh |
| 72 | +``` |
| 73 | + |
| 74 | +### Run Python tests |
| 75 | + |
| 76 | +Run Python tests: |
| 77 | + |
| 78 | +```bash |
| 79 | +./tools/test-package.sh |
| 80 | +``` |
| 81 | + |
| 82 | +### Deploy Python package |
| 83 | + |
| 84 | +Make sure the set the following environment variables before calling the deployment script: |
| 85 | + |
| 86 | +* `UV_PUBLISH_URL` |
| 87 | +* `UV_PUBLISH_USERNAME` |
| 88 | +* `UV_PUBLISH_PASSWORD` |
| 89 | + |
| 90 | +Deploy the Python package: |
| 91 | + |
| 92 | +```bash |
| 93 | +./tools/deploy-package.sh |
| 94 | +``` |
0 commit comments