Skip to content

Commit

Permalink
Merge pull request #188 from stackhpc/upstream/2023.1-2023-10-18
Browse files Browse the repository at this point in the history
Synchronise 2023.1 with upstream
  • Loading branch information
priteau authored Oct 18, 2023
2 parents f209ccb + 16a993b commit f0399d8
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
22 changes: 22 additions & 0 deletions kayobe/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

import base64
import glob
from importlib.metadata import Distribution
import json
import logging
import os
import shutil
Expand Down Expand Up @@ -48,10 +50,30 @@ def _detect_install_prefix(path):
return prefix_path


def _get_direct_url(dist):
direct_url = os.path.join(dist._path, 'direct_url.json')
if os.path.isfile(direct_url):
with open(direct_url, 'r') as f:
direct_url_content = json.loads(f.readline().strip())
url = direct_url_content['url']
prefix = 'file://'
if url.startswith(prefix):
return url[len(prefix):]

return None


def _get_base_path():
override = os.environ.get("KAYOBE_DATA_FILES_PATH")
if override:
return os.path.join(override)

kayobe_dist = list(Distribution.discover(name="kayobe"))
if kayobe_dist:
direct_url = _get_direct_url(kayobe_dist[0])
if direct_url:
return direct_url

egg_glob = os.path.join(
sys.prefix, 'lib*', 'python*', '*-packages', 'kayobe.egg-link'
)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
fixes:
- |
Fixes detection of data file path when using editable installations with a
recent pip.

0 comments on commit f0399d8

Please sign in to comment.