qfieldsync icon indicating copy to clipboard operation
qfieldsync copied to clipboard

Fix runtime error after plugin update when `libqfieldsync` changed API

Open suricactus opened this issue 8 months ago • 1 comments
trafficstars

When we add a new class/method/API change in libqfieldsync and we use it within QFieldSync plugin, we get a runtime error, such as:

ImportError: cannot import name 'PackagingCanceledException' from 'libqfieldsync.offline_converter' (C:\Users\paul.bennett\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\qfieldsync\libqfieldsync.whl\libqfieldsync\offline_converter.py)

The reason is that libqfieldsync is loaded from a .whl file, which is cached by the Python runtime and we need to introduce this magic to force reload this.

The magic consists of two parts:

  1. ensure the new version .whl file has a different name 2) ensure we use importlib.reload to force reload from the new .whl

Tested on Windows 11 with QGIIS 3.34. Failed to reproduce on Ubuntu, but also did not try hard.

I wish I have time to do more fun stuff like this...

Fix #643 #646

suricactus avatar Mar 19 '25 00:03 suricactus