A cookiecutter template to create Python packages. It's tailored for those working in Azure DevOps with Azure Pipelines and includes tools for testing, linting, documentation, versioning and publishing.
Install cookiecutter and then run:
cookiecutter https://github.com/tspanos/pythonPackageCookiecutter
- Python package setup with
src
layout. - Azure Pipelines configuration for continuous integration and delivery.
- PyTest for testing
- Ruff for linting Python code.
- MkDocs for project documentation.
An example project using this template would have the following structure:
src/
: Contains your Python package source code.tests/
: Tests for your package.docs/
: MkDocs documentation source files.azure-pipelines.yml
: Configuration for Azure Pipelines.pyproject.toml
: Defines project metadata and dependencies.
<project_name>/
├── .gitignore
├── azure-pipelines.yml
├── LICENSE.txt
├── mkdocs.yml
├── pyproject.toml
├── README.md
├── docs/
│ ├── index.md
│ └── installation.md
└── src/
| └── <package_name>/
| └── __init__.py
└── tests/
└── tests.py
The azure-pipelines.yml
includes several features:
- Linting: Ruff is used to lint the Python code.
- Testing: PyTest runs tests, test coverage is calculated and the results are published to Azure DevOps
- Versioning: Automatic versioning is handled by GitVersion.
- Building: Python packages are built into distributions.
- Tagging: Successful builds are tagged to the repository with the version number.
- Publishing: Built packages are submitted to an Azure Feed.
- An Azure DevOps account and an Azure Pipeline setup.
- A Git Tools extension for Azure DevOps (Git Tools).
- Azure Artifacts feed for publishing packages.
- Appropriate permissions for the (build service account to interact with the Azure feed).
- Appropriate permissions for the (build service account to write to the repo).