linz / gazetteer

New Zealand Gazetteer of official place names
http://www.linz.govt.nz/regulatory/place-names/find-name/new-zealand-gazetteer-official-geographic-names/new-zealand-gazetteer-search-place-names#zoom=0&lat=-41.14127&lon=172.5&layers=BTTT
Other
2 stars 2 forks source link

plugin fails to start in CI with ImportError: cannot import name 'Config' #99

Closed SPlanzer closed 4 years ago

SPlanzer commented 4 years ago

As part of porting python2 > 3 all implicit relative imports were replaced with explicit relative imports. (see python docs for more for example considering

src/NZGBplugin/LINZ/gazetteer/gui/
├── AdminWidget.py
├── Config.py
├── Controller.py
├── DatabaseConfiguration.py
├── Editor.py
├── FormUtils.py

and considering DatabaseConfiguration.py

import Config becomes from import . Config

This change worked well when testing porting locally but testing with the docker container is throwing the below import error

from . import Config
ImportError: cannot import name 'Config'
SPlanzer commented 4 years ago

This is because .docker/qgis/scripts/docker-entry.sh is calling DatabaseConfiguration.py as a module level rather than as part of a python package. see - https://stackoverflow.com/questions/14132789/relative-imports-for-the-billionth-time for more

https://github.com/linz/gazetteer/blob/74507d8d71f4ebb399a4d70b0af10a6b9f921398/.docker/qgis/scripts/docker-entry.sh#L6-L13

This can be solved by either making relative imports absolute (eg. from NZGBplugin.LINZ.gazetteer.gui import Config)

or configuring database parameters via the QGIS startup script

SPlanzer commented 4 years ago

Your