From b75db5b1f9fda52c7135984614779fd242523248 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Paul=20M=C3=BCller?= Date: Mon, 5 Aug 2024 01:28:39 +0200 Subject: [PATCH] more robust git detection --- dcor_control/update.py | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/dcor_control/update.py b/dcor_control/update.py index 4aa01f9..5b3cca3 100644 --- a/dcor_control/update.py +++ b/dcor_control/update.py @@ -116,20 +116,15 @@ def update_package(name): is_testing = False # Check whether the package is installed -e via git somewhere - for path_item in sys.path: - if name in path_item or name.replace("-", "_") in path_item: - # This means that the package is probably installed - # in editable mode. Import the package to identify its - # location. - mod_name = (name.replace("-", ".", 1) - if name.startswith("ckanext-") else name) - mod = importlib.import_module(mod_name) - for pp in pathlib.Path(mod.__file__).parents: - if (pp / ".git").exists(): - is_located_git = str(pp) - break - else: - is_located_git = False + # This means that the package is probably installed + # in editable mode. Import the package to identify its + # location. + mod_name = (name.replace("-", ".", 1) + if name.startswith("ckanext-") else name) + mod = importlib.import_module(mod_name) + for pp in pathlib.Path(mod.__file__).parents: + if (pp / ".git").exists(): + is_located_git = str(pp) break else: is_located_git = False