UMEP-dev / UMEP-processing

7 stars 9 forks source link

Loading plugin headless for qgis_process #1

Closed elliots closed 3 years ago

elliots commented 3 years ago

Hi,

It is possible this issue may lie with qgis instead, but when attempting to install the plugin by extracting the zip file to the plugins directory it is found but not loaded.

[root@c4da1ff0ffde /]# qgis_process plugins
QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root'
<string>:1: DeprecationWarning: setapi() is deprecated
/usr/lib/python3.9/site-packages/qgis/utils.py:792: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
  mod = _builtin_import(name, globals, locals, fromlist, level)
Problem with GRASS installation: GRASS was not found or is not correctly installed
Problem with SAGA installation: SAGA was not found or is not correctly installed
Available plugins
(* indicates loaded plugins which implement Processing providers)

  processing_umep
* processing

Has anyone else attempted to install this plugin headless?

elliots commented 3 years ago

This is my current Dockerfile, in case it is useful for anyone else


FROM lopsided/archlinux

RUN pacman -Syy && pacman --noconfirm -S qgis python-pip python-pandas python-scipy unzip

ENV QT_QPA_PLATFORM offscreen

RUN mkdir -p ~/.local/share/QGIS/QGIS3/profiles/default/QGIS && \
  echo "[PythonPlugins]\nprocessing=true\nprocessing_umap=true" > ~/.local/share/QGIS/QGIS3/profiles/default/QGIS/QGIS3.ini && \
  curl https://plugins.qgis.org/plugins/processing_umep/version/0.5/download/ --output umep-processing.zip && \
  mkdir -p ~/.local/share/QGIS/QGIS3/profiles/default/python/plugins && \
  unzip umep-processing.zip -d ~/.local/share/QGIS/QGIS3/profiles/default/python/plugins && \
  rm umep-processing.zip
biglimp commented 3 years ago

Not sure that this is a plugin issue but instead a QGIS issue. Have you tried to install another processing plugin via a zip-file?

elliots commented 3 years ago

You're right, my bad. I just tried another plugin and it did the same thing.

elliots commented 3 years ago

If anyone else is trying to use this headless, this docker file patches qgis_process so that it loads all plugins, and installs umep processing.

FROM qgis/qgis:release-3_16

# build patched qgis_process that loads all plugins
RUN sed -i 's/plugin == QLatin1String( "processing" ) || ( mPythonUtils->isPluginEnabled( plugin ) && mPythonUtils->pluginHasProcessingProvider( plugin ) )/mPythonUtils->pluginHasProcessingProvider( plugin )/' /QGIS/src/process/qgsprocess.cpp
RUN cd /QGIS/build && ninja qgis_process && cp output/bin/qgis_process /usr/bin

# install umep plugin
RUN mkdir -p ~/.local/share/QGIS/QGIS3/profiles/default/QGIS && \
  echo "[PythonPlugins]\nprocessing=true\nprocessing_umap=true" > ~/.local/share/QGIS/QGIS3/profiles/default/QGIS/QGIS3.ini && \
  curl https://plugins.qgis.org/plugins/processing_umep/version/0.5/download/ --output umep-processing.zip && \
  mkdir -p ~/.local/share/QGIS/QGIS3/profiles/default/python/plugins && \
  unzip umep-processing.zip -d ~/.local/share/QGIS/QGIS3/profiles/default/python/plugins && \
  rm umep-processing.zip

# install umep dependencies
RUN apt install -y python3-scipy && pip3 install supy

ENV QT_QPA_PLATFORM offscreen
RUN mkdir /tmp/runtime-root
ENV XDG_RUNTIME_DIR /tmp/runtime-root