A tool to aid in QGIS Python plugin development
Project description
pb_tool
A command-line tool for building and deploying QGIS Python plugins. pb_tool handles compiling UI and resource files, building Sphinx documentation, managing translations, deploying to your local QGIS plugin directory, and packaging for the QGIS Plugin Repository.
Supports QGIS 3 and QGIS 4, Qt5 and Qt6, and runs on Linux, macOS, and Windows.
Features
- Compile
.uiand.qrcfiles (auto-detectspyuic5/pyuic6andrcc) - Deploy to your QGIS plugin directory for live testing
- Package into a
.zipfor upload to the Plugin Repository - Build and clean Sphinx HTML documentation
- Compile translation files with
lrelease - Clean compiled and deployed files
- Validate your config file and environment
Installation
pip install pb_tool
To upgrade:
pip install --upgrade pb_tool
pb_tool is also available as the shorter alias pbt:
pbt deploy
Runtime dependencies
| Tool | Purpose |
|---|---|
pyuic5 or pyuic6 |
Compile .ui files to Python |
rcc |
Compile .qrc resource files |
lrelease |
Build .qm translation files from .ts sources |
zip or 7z |
Package the plugin for upload |
sphinx + make |
Build HTML help documentation |
Configuration
pb_tool requires a pb_tool.cfg file in your plugin's root directory. Plugin Builder generates this automatically. You can also create one by hand using the template below.
[plugin]
# Directory name used when deploying to the QGIS plugins folder
name: MyPlugin
# Override the deploy path (leave empty to use the QGIS default location)
plugin_path:
[files]
# Python source files to deploy
python_files: __init__.py my_plugin.py my_plugin_dialog.py
# Main dialog .ui file — loaded at runtime, not compiled
main_dialog: my_plugin_dialog_base.ui
# Additional .ui files to compile to Python
compiled_ui_files: settings_dialog.ui
# Qt resource files (.qrc) to compile
resource_files: resources.qrc
# Other files to include (e.g. metadata.txt, icon.png)
extras: metadata.txt icon.png
# Subdirectories to deploy alongside the plugin
extra_dirs: i18n
# Locales to build — .ts files must exist in the i18n/ directory
locales: en.ts fr.ts
[help]
# Sphinx build output directory
dir: help/build/html
# Directory name inside the deployed plugin
target: help
All paths are relative to the directory where you run pb_tool. The name value must match the folder name used in the QGIS plugins directory.
Commands
Run pb_tool --help for the full command list. Commands support unique-prefix abbreviation — pb_tool dep is the same as pb_tool deploy.
deploy
Compile files, build docs, and copy everything to the QGIS plugin directory.
pb_tool deploy [OPTIONS]
| Option | Description |
|---|---|
--config_file FILE |
Config file to use (default: pb_tool.cfg) |
-p, --plugin_path PATH |
Override the deploy destination |
-q, --quick |
Skip compiling and doc building; copy files only |
-y, --no-confirm |
Skip the confirmation prompt |
A full deploy will:
- Remove the currently deployed version (
dclean) - Compile all UI and resource files
- Build Sphinx HTML documentation
- Copy all declared files and directories to the plugin folder
Use -q for fast iteration when you only changed Python files.
Example output:
Deploying will:
* Remove your currently deployed version
* Compile the ui and resource files
* Build the help docs
* Copy everything to your ~/.local/share/QGIS/QGIS4/.../plugins/MyPlugin directory
Proceed? [y/N]: y
Removing plugin from ...
Compiling to make sure install is clean
Skipping resources.qrc (unchanged)
Building the help documentation
...
Copying __init__.py
Copying my_plugin.py
...
compile
Compile .ui and .qrc files without deploying.
pb_tool compile [--config pb_tool.cfg]
- Detects
pyuic6first, falls back topyuic5 - Uses
rccfor resource files; automatically rewritesPySide6imports toqgis.PyQt - Skips files that have not changed since the last compile
doc
Build Sphinx HTML documentation.
pb_tool doc
Runs make html inside the help/ directory. Requires a Sphinx project set up there (Plugin Builder creates this automatically).
translate
Compile .ts translation files to .qm using lrelease.
pb_tool translate [--config pb_tool.cfg]
Locales must be listed under [files] > locales in your config, and the .ts files must exist in the i18n/ directory.
zip
Package the deployed plugin into a .zip suitable for the QGIS Plugin Repository.
pb_tool zip [--config_file pb_tool.cfg] [-q]
By default triggers a full dclean + deploy first. Use -q to skip that step if the plugin is already deployed and current.
Requires zip or 7z on your PATH.
validate
Check pb_tool.cfg for required fields and report the environment status.
pb_tool validate [--config_file pb_tool.cfg]
Reports:
- Whether all mandatory config keys are present
- Resolved QGIS plugin directory path
- Python version in use
- Whether a suitable zip utility was found
clean
Delete compiled UI and resource .py files.
pb_tool clean [--config pb_tool.cfg]
clean_docs
Remove the built Sphinx HTML output.
pb_tool clean_docs
dclean
Remove the deployed plugin from the QGIS plugins directory (prompts for confirmation).
pb_tool dclean [--config pb_tool.cfg]
list
Print the contents of the config file.
pb_tool list [--config_file pb_tool.cfg]
update
Check whether a newer version of pb_tool is available.
pb_tool update
version
Print the current pb_tool version and exit.
pb_tool version
Plugin directory detection
pb_tool automatically resolves the QGIS plugin directory in this order:
~/.local/share/QGIS/QGIS4/profiles/default/python/plugins~/.local/share/QGIS/QGIS3/profiles/default/python/plugins
If neither exists, the QGIS 4 path is used as the default. Override at any time with deploy -p /your/path.
Typical workflow
# First deploy — full compile + copy
pb_tool deploy
# Iterate quickly on Python changes only
pb_tool deploy -q
# Validate your config and environment
pb_tool validate
# Package for the Plugin Repository
pb_tool zip
# Clean up compiled artefacts
pb_tool clean
Troubleshooting
pyuic5/pyuic6 not found — install Qt development tools. On Ubuntu/Debian: sudo apt install pyqt5-dev-tools or sudo apt install pyqt6-dev-tools. On Windows, install via OSGeo4W.
rcc not found — install the Qt resource compiler. On Ubuntu/Debian: sudo apt install qtbase5-dev-tools or sudo apt install qt6-base-dev-tools.
Pygments uninstall error on pip install — run:
pip install --ignore-installed Pygments pb_tool
Windows setup — see A Quick Guide to Getting Started with PyQGIS on Windows.
Contributing
Issues and pull requests: https://github.com/g-sherman/plugin_build_tool
License
GNU General Public License v2 or later (GPLv2+).
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pb_tool-3.3.1.tar.gz.
File metadata
- Download URL: pb_tool-3.3.1.tar.gz
- Upload date:
- Size: 55.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ca360ee341ed4a02c589eea32652589bc6b297544bc06b9cfea327faea5e9a9c
|
|
| MD5 |
1a26863a386eae1d81c1f06af1d7fa13
|
|
| BLAKE2b-256 |
8fec8913fbe4a5f4a463f26e3535335c9672ba44364ffb42ef0e7b6a8f1bf0f8
|
Provenance
The following attestation bundles were made for pb_tool-3.3.1.tar.gz:
Publisher:
publish.yml on jonah-sullivan/plugin_build_tool
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pb_tool-3.3.1.tar.gz -
Subject digest:
ca360ee341ed4a02c589eea32652589bc6b297544bc06b9cfea327faea5e9a9c - Sigstore transparency entry: 1404983192
- Sigstore integration time:
-
Permalink:
jonah-sullivan/plugin_build_tool@473c5cd71a66b8205f34297dfc0ca1d4bef8c0ce -
Branch / Tag:
refs/tags/v3.3.1 - Owner: https://github.com/jonah-sullivan
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@473c5cd71a66b8205f34297dfc0ca1d4bef8c0ce -
Trigger Event:
push
-
Statement type:
File details
Details for the file pb_tool-3.3.1-py3-none-any.whl.
File metadata
- Download URL: pb_tool-3.3.1-py3-none-any.whl
- Upload date:
- Size: 35.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c024915a54fc27f9e22e9a8d3b0f9a8606f2b22f6490b49bae58feb25a97dc91
|
|
| MD5 |
c8dc8144671cea63daaddc185d1f711d
|
|
| BLAKE2b-256 |
4b4aa27c941b6da6ab375e4851d4dcc593776438f1e1d6270c9706d06fe19f47
|
Provenance
The following attestation bundles were made for pb_tool-3.3.1-py3-none-any.whl:
Publisher:
publish.yml on jonah-sullivan/plugin_build_tool
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pb_tool-3.3.1-py3-none-any.whl -
Subject digest:
c024915a54fc27f9e22e9a8d3b0f9a8606f2b22f6490b49bae58feb25a97dc91 - Sigstore transparency entry: 1404983437
- Sigstore integration time:
-
Permalink:
jonah-sullivan/plugin_build_tool@473c5cd71a66b8205f34297dfc0ca1d4bef8c0ce -
Branch / Tag:
refs/tags/v3.3.1 - Owner: https://github.com/jonah-sullivan
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@473c5cd71a66b8205f34297dfc0ca1d4bef8c0ce -
Trigger Event:
push
-
Statement type: