Skip to content

Commit

Permalink
more robust git detection
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmueller committed Aug 4, 2024
1 parent 9933701 commit b75db5b
Showing 1 changed file with 9 additions and 14 deletions.
23 changes: 9 additions & 14 deletions dcor_control/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b75db5b

Please sign in to comment.