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 (ideally as
administrator) and run two scripts before any attempts:
py3_env
and qt5_env
c:\> py3_env c:\> qt5_env c:\> pyrcc5 -help
To build the plugin pb_tool must be available in the system. This
package is available via PyPI service (using pip install
).
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
, just use
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.
First build of the plugin¶
First we compile UI files
cd /path/to/save_views
pb_tool compile
Note
If you have no administrator permission on MS Windows than you can run pb_tool by this command:
%homepath%\AppData\Roaming\Python\Python37\Scripts\pb_tool compile
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
:file:``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.