Skip to content

Commit ff2e2b5

Browse files
authored
Merge pull request #647 from opengisch/fix_whl
Fix runtime error after plugin update when `libqfieldsync` changed API
2 parents 33acba2 + 9565d7f commit ff2e2b5

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

.github/workflows/continuous_integration.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ jobs:
9696
- name: Package libqfieldsync
9797
run: |
9898
pip wheel $(grep -o -P '(https://.*.tar.gz)' requirements.txt)
99-
mv libqfieldsync-*.whl qfieldsync/libqfieldsync.whl
99+
LIBQFIELDSYNC_COMMIT_SHA=$(echo $(grep -o -P '(https://.*.tar.gz)' requirements.txt) | grep -Eo '[0-9a-f]{40}')
100+
mv libqfieldsync-*.whl qfieldsync/libqfieldsyncq_${LIBQFIELDSYNC_COMMIT_SHA}.whl
100101
101102
- name: Release
102103
run: |

qfieldsync/__init__.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,28 @@
2424

2525
from __future__ import absolute_import
2626

27+
import importlib
2728
import pathlib
29+
import re
2830
import sys
2931

3032
src_dir = pathlib.Path(__file__).parent.resolve()
3133

32-
libqfieldsync_whl = src_dir / "libqfieldsync.whl"
33-
if libqfieldsync_whl.exists():
34+
# remove previously loaded `libqfieldsync.whl` from the python import path
35+
for python_path in sys.path:
36+
if re.search(r"libqfieldsync.*\.whl$", python_path):
37+
sys.path.remove(python_path)
38+
39+
# add the new `libqfieldsync.whl` file to the python import path
40+
for libqfieldsync_whl in src_dir.glob("libqfieldsync*.whl"):
3441
sys.path.append(str(libqfieldsync_whl))
3542

43+
# force reload all the `libqfieldsync` modules from the new path
44+
module_names = list(sys.modules.keys())
45+
for module_name in module_names:
46+
if module_name.startswith("libqfieldsync"):
47+
importlib.reload(sys.modules[module_name])
48+
3649

3750
# noinspection PyPep8Naming
3851
def classFactory(iface): # pylint: disable=invalid-name

0 commit comments

Comments
 (0)