Build the plugin¶
Important
Make sure, where is the PyQt5 resource compiler
(pyrcc5
) available in your PATH
You can test it by running
pyrcc5 -help
You should obtain readable help message
Note
If you are on MS Windows, open OSGeo4W Shell:
To build the plugin pb_tool must be available in the system. This package is available via PyPI service.
Note
It might look as good idea to use standard make
, since
Makefile is available too. This is considered deprecated option and
should no longer be used. pb_tool
is more complex build system
(and supports various operating systems).
To install pb_tool
run the command below (on MS Windows use OSGeo4W Shell):
python3 -m pip install pb_tool
Configuration file pb_tool.cfg
¶
pb_tool needs a configuration file (generated by the Plugin Builder). In this file, you can modify target plugin path as well as locales, extra directories needed and other metadata.
Using plugin in place¶
Instead of deploying the plugin using pb_tool it is more flexible when the plugin to set up by QGIS environment in order to be able to install the plugin from current folder without need of deployment.
Let’s add your plugin location to the QGIS_PLUGINPATH
in
. Enable Use custom
variables
in Environment
section and add a new variable:
QGIS_PLUGINPATH
. This variable should point to a parent
directory where the plugin is located. Restart (close and open) QGIS
and continue with installing the plugin.
Important
QGIS doesn’t allow in the path defined by
QGIS_PLUGINPATH
non-ascii characters. If your path
contains such characters than consider to rename directories in the
path which causing this issue.
Activate plugin in QGIS¶
Open QGIS and find the new plugin in the
. Check the checkbox to activate the plugin in QGIS.An icon of the plugin appears in the toolbar as well as new menu selection in .
When running it, a new (empty) dialog will be open.
Notes¶
Virtualenv¶
Virtualenv is one of the possibilities, how to keep your code and it’s dependencies independent.
To create the virtualenv, run
python3 -m venv myvenv
For QGIS running within Python virtualenv, you need to adjust
activate
script and add PYTHONPATH
with Python, Qt
and QGIS libraries.
$EDITOR myvenv/bin/activate
[...]
export PYTHONPATH=$PYTHONPATH:/usr/local/share/qgis/python/:/usr/lib/python3/dist-packages/
[...]
To initialize the virtualenv, run
source myenv/bin/activate
Note
It’s generally good advice to use virtualenvwrapper tool.