g-sherman / Qgis-Plugin-Builder

Plugin generator for creating QGIS Python plugins (QGIS 3 version is now in master)
85 stars 62 forks source link

Building Processing Provider Plugin gives unnecessary compiling error #136

Open Hannes-Ole opened 1 year ago

Hannes-Ole commented 1 year ago

TL:DR: Building a Processing Provider plugin warns of a compiling error, which is very confusing for first-time-users. Suggested solution: Create a "dummy" resources.qrc only containing the basic structure. Of course this will be obsolete once issue #126 is resolved. Alternatively (or additionally) the "Plugin Builder Results" page should at least mention, that for Processing Provider plugin templates, no compilation is necessary (or even possible).


The long story is "documented" here:

Working with QGIS 3.22.13-2 (OSGeo4W installer). I selected to build a Processing Provider plugin.

image of plugin builder > processing plugin

I assume it uses the Processing interface, therefore no QT resources (interface elements) are generated (resources.qrc). When choosing "Tool button with dialog", everything works smoothly as expected and described in the tutorials: resources.qrc is properly generated and the compiling process seems to work fine, as resources.py is also generated and no errors occur.

The compiling error I am getting when building a processing provider is simply misleading for me as an unexperienced user:

error compiling your resources.qrc file

I spent a few hours trying to find resources.qrc, fixing my PATH, reinstalling QGIS, trying to understand the compilation and testing pb_tool, although everything was working fine in the first place.

As there is no resources.qrc file needed, no compilation is necessary. The plugin can simply be copied to the plugin directory (e.g. C:\Users{user name}\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins ) without compilation and works fine. This holds true at least for the template that plugin builder generates. Once the plugin gets more complex and uses files, the compilation may be necessary.

I also created a dummy resources.qrc with the basic structure in the processing provider plugin:

<RCC>
  <qresource prefix="/plugins/hello_world_plugin" >
  </qresource>
</RCC>

When compiling, this simply generates the "warning": No resources in resource description. I think it would be a better solution for the plugin builder in case of processing provider (rather than not generating resources.qrc) at all: It avoids the misleading compilation error, may be needed later anyways and also "tests"/"confirms" that the pyrcc5 compiler is found.

palikao commented 1 year ago

Edit pyrcc5 file, replacing 'dirname $0/python3.9' with dirname $0/python3.9 (removing quotes)