Skip to content

Latest commit

 

History

History
264 lines (141 loc) · 8.23 KB

dev_install.rst

File metadata and controls

264 lines (141 loc) · 8.23 KB

Development Installation

The Python QGIS Plugin for WTSS depends essentially on:

For development environment, you will need to set your python QGIS environment variables basing on your operation system. This means that your QGIS must be configured with your python variables using a terminal or CMD.

This development environment consist in a environment with all dependencies required to compile and build the plugin installer for WTSS QGIS Plugin.

Linux

The scripts to help to configure the environment variables are located in Linux bash scripts.

The fisrt step is to clone the software repository for wtss_plugin:

$ git clone https://github.com/brazil-data-cube/wtss-qgis

If you clone the repository from git you needd to go to the source code folder:

$ cd wtss-qgis

The next step is to install requirements and deploy the plugin in QGIS software according to your operating system.

If you cloned the repository, you can install the requirements running pip in source code:

$ pip3 install -e .[all]

Now you will need to generate a requirements.txt file for plugin install and resolve dependencies conflicts in background when users get the zip file:

This is because only QGIS does not resolve external dependencies like WTSS.py, and to generate the zip file for user installation, the requirements is needed to run installation script in __init__.py.

To generate this file use this script:

$ python3 scripts/build_requirements.py

After requirements.txt, you will need to compile the resources.qrc, then go to the source code folder:

$ cd wtss_plugin

The plugin source code is located at ./wtss_plugin, this folder will be compressed to generate the final zip to user installation.

In source code folder, use pb_tool to compile the requirements.qrc. The pb_tool compile will generate a file named resources.py, check this file before deploy:

$ pb_tool compile

After this steps, the plugin is able to deploy and generate zip. In the development environemnt you can deploy the plugin directely to your installed QGIS.

To deploy the plugin in your installed QGIS, execute:

$ pb_tool deploy --plugin_path \
    /home/${USER}/.local/share/QGIS/QGIS3/profiles/default/python/plugins

To generate the zip file for plugin installer, use:

$ pb_tool zip

This command will compress the files configured in pb_tool.cfg, any errors may be related to previous steps with the generated files requirements.txt and resources.py.

Docker

To run this plugin in a QGIS Docker instance it is required a installed Docker version.

There are two ways to run the plugin: building the image for plugin or run the QGIS Docker and install the user zip file.

To build the plugin image you need to run:

$ docker build -t wtss-qgis .

After build the plugin image, you need to run this script in the root of repository:

$ bash scripts/linux/run-qgis-wtss-plugin.sh

Note

For Windows users, this script is detailed below:

docker run --rm \
    --interactive \
    --tty \
    --name qgis-docker-wtss-plugin \
    -i -t \
    -v ${PWD}:/home/wtss_plugin \
    -v /tmp/.X11-unix:/tmp/.X11-unix \
    -e DISPLAY=unix$DISPLAY \
    wtss-qgis:latest qgis

To run only the QGIS instance and after run the user installation:

$ QGIS_RELEASE="release-3_28" \
    bash scripts/linux/run-qgis.sh

With the QGIS instance running go to Plugins >> Manage and Install Plugins and install the plugin via zip, using the generated zip file using pb_tool zip or any compressing app.

Note that you can choose the release of QGIS, in this example was chosen the 3.28 version.

Note

For Windows users, this script can be adapted from:

set OSGEO4W_ROOT=release-3_28

docker run --rm \
    --interactive \
    --tty \
    --name qgis-docker \
    -i -t \
    -v ${PWD}:/home/wtss_plugin \
    -v ${PWD}/plugins:/root/.local/share/QGIS/QGIS3/profiles/default/python/plugins/ \
    -v /tmp/.X11-unix:/tmp/.X11-unix \
    -e DISPLAY=unix$DISPLAY \
    qgis/qgis:%OSGEO4W_ROOT% qgis

Windows

The scripts to help to configure the environment variables are located in Windows CMD.

To install the plugin in Windows environment, with a installed version > 3 for QGIS, open the Terminal as administrator and set the environment variables to link PYTHONHOME in QGIS.

To set PYTHONHOME, find the Python and Grass version installed by QGIS, you can use this commands:

\wtss-qgis> dir "%OSGEO4W_ROOT%"\apps
\wtss-qgis> dir "%OSGEO4W_ROOT%"\apps\grass

You can set the environment variables in panel control if you were a experient windows user or run the script in set-pyqgis-win.cmd.

But this script must be updated, its required to set the python and grass version. For example below set the python version like 3.12 to 312 and grass version 8.4 to 84:

@echo off
set PYTHON_VERSION=312
set GRASS_VERSION=84
set OSGEO4W_ROOT=C:\OSGeo4W

Now you can run the set-pyqgis-win.cmd:

\wtss-qgis> scripts\set_pyqgis_win.cmd

Now your command line python is the same python used in your QGIS plugins. And you are able to install the requirements running pip in source code:

\wtss-qgis> python3 -m pip install -e .[all]

After install the extra requirements, you can use pb_tool to compile and deploy the plugin as its follows:

\wtss-qgis\wtss_plugin> pb_tool compile

To deploy the plugin in Windows, run the script deploy-win.cmd, but before set the USER variable using your windows user:

\wtss-qgis\wtss_plugin> set USER=<your_user>
\wtss-qgis\wtss_plugin> ..\scripts\deploy_win.cmd

To zip generation is only for Linux environemnt, to do so in Windows, you will need to execute some compressing app like WinRAR.

Note

  • The final step for all environments is run QGIS and open the Plugins Manager and enable the WTSS for development environment;
  • To develop in WTSS QGIS Plugin in all operation systems, you will need to install the QGIS Plugin Reloader. This plugin will reload any updates after deploys during a QGIS open session, it is useful to test new methods.

Unit Test

Go to the source code folder:

$ cd wtss_plugin

Run pytest:

$ pytest