From fad63006540a8543f3bb0c27f76af68f8426c008 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gerg=C5=91=20Jedlicska?= <57442769+gjedlicska@users.noreply.github.com> Date: Thu, 15 Aug 2024 14:32:12 +0200 Subject: [PATCH 1/2] Update patch_specklepy.py (#3) better path handling for specklepy and pygeoapi --- .../provider/speckle_utils/patch_specklepy.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/pygeoapi/provider/speckle_utils/patch_specklepy.py b/pygeoapi/provider/speckle_utils/patch_specklepy.py index 481bc6f..c35f1f8 100644 --- a/pygeoapi/provider/speckle_utils/patch_specklepy.py +++ b/pygeoapi/provider/speckle_utils/patch_specklepy.py @@ -1,12 +1,18 @@ import sys from pathlib import Path import shutil +import specklepy +import pygeoapi + def get_specklepy_path(): - root_path = Path(sys.executable).parent.parent - credentials_path = Path(root_path, "Lib", "site-packages", "specklepy") - return credentials_path + return Path(specklepy.__file__).parent + +def get_pygeoapi_path(): + + return Path(pygeoapi.__file__).parent + def get_credentials_path(): specklepy_path = get_specklepy_path() @@ -21,14 +27,12 @@ def get_transport_path(): return str(credentials_path) def get_transport_path_src(): - specklepy_path = Path(sys.executable).parent.parent - credentials_path = Path(specklepy_path, "pygeoapi", "pygeoapi", "provider", "speckle_utils", "server.py") + credentials_path = Path(get_pygeoapi_path(), "provider", "speckle_utils", "server.py") return str(credentials_path) def get_gis_feature_path_src(): - specklepy_path = Path(sys.executable).parent.parent - credentials_path = Path(specklepy_path, "pygeoapi", "pygeoapi", "provider", "speckle_utils", "GisFeature.py") + credentials_path = Path(get_pygeoapi_path(), "provider", "speckle_utils", "GisFeature.py") return str(credentials_path) @@ -95,4 +99,3 @@ def patch_specklepy(): patch_credentials() copy_gis_feature() patch_transport() - \ No newline at end of file From ec042201831c8fd966c4fdd23b41586e9a2f366f Mon Sep 17 00:00:00 2001 From: KatKatKateryna <89912278+KatKatKateryna@users.noreply.github.com> Date: Thu, 15 Aug 2024 20:33:36 +0800 Subject: [PATCH 2/2] Update patch_specklepy.py move import inside the function, as "alien" imports are not recognized by pygeoapi --- pygeoapi/provider/speckle_utils/patch_specklepy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygeoapi/provider/speckle_utils/patch_specklepy.py b/pygeoapi/provider/speckle_utils/patch_specklepy.py index c35f1f8..55b5573 100644 --- a/pygeoapi/provider/speckle_utils/patch_specklepy.py +++ b/pygeoapi/provider/speckle_utils/patch_specklepy.py @@ -1,11 +1,11 @@ import sys from pathlib import Path import shutil -import specklepy import pygeoapi def get_specklepy_path(): + import specklepy return Path(specklepy.__file__).parent