Cookiecutter template for a QGIS plugin.
This template makes it easy to create a new QGIS plugin project with a modern development environment.
Plugin generation is supported with Python 3.8 or newer.
The template is built using Cookiecutter, so you must have it installed.
The recommended way to install Cookiecutter (and other Python cli tools) is to install it with pipx. Pipx will install the application in a isolated environment and make it available as a command line utility. To install pipx
follow the instructions from https://github.com/pypa/pipx#install-pipx.
pipx install cookiecutter
pip install cookiecutter
Creating a new plugin project with Cookiecutter creates a new folder for the project so navigate to the desired parent directory and use the following command. Run Cookiecutter with this repository as the template. This command will set up your project based on the provided template
cookiecutter https://github.com/GispoCoding/cookiecutter-qgis-plugin
You should develop this template using virtual python environment. This way you can install development dependencies and test the template without affecting your global python environment.
# Create a virtual python environment named .venv
python -m venv .venv
# Activate the virtual environment
source .venv/bin/activate # On Windows run: .venv/Scripts/activate
# Install pip-tools dependency manager
pip install pip-tools
# Install/sync development dependencies
pip-sync # This will sync dependencies in the current environment to mach the ones in requirements.txt
Dependencies are pinned to a exact versions so that tests are run in a reproduceable environment also on CI.
# Edit requirements.in
# Compile requirements.in to requirements.txt
pip-compile --resolver=backtracking
# Sync dependencies
pip-sync
# Commit requirements.in and requirements.txt
git add requirements.in requirements.txt
git commit -m "Update development dependencies"
Download the create_qgis_venv.py script from https://github.com/GispoCoding/qgis-venv-creator/releases and add the script to the {{cookiecutter.plugin_name}}
folder without modifying.