Fix detection of editable installation
This synchronises this code with kolla-ansible [1], preemptively fixing issues with Python 3.12. [1] https://review.opendev.org/c/openstack/kolla-ansible/+/933633 Change-Id: I027c48d7ff6fe06e1898720273fef3da571aabe4
This commit is contained in:
parent
3abc25fbf0
commit
ec1d336529
@ -54,15 +54,20 @@ def _detect_install_prefix(path):
|
||||
return prefix_path
|
||||
|
||||
|
||||
def _get_direct_url(dist):
|
||||
def _get_direct_url_if_editable(dist):
|
||||
direct_url = os.path.join(dist._path, 'direct_url.json')
|
||||
editable = None
|
||||
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):]
|
||||
dir_info = direct_url_content.get('dir_info')
|
||||
if dir_info is not None:
|
||||
editable = dir_info.get('editable')
|
||||
if editable:
|
||||
url = direct_url_content['url']
|
||||
prefix = 'file://'
|
||||
if url.startswith(prefix):
|
||||
return url[len(prefix):]
|
||||
|
||||
return None
|
||||
|
||||
@ -74,7 +79,7 @@ def _get_base_path():
|
||||
|
||||
kayobe_dist = list(Distribution.discover(name="kayobe"))
|
||||
if kayobe_dist:
|
||||
direct_url = _get_direct_url(kayobe_dist[0])
|
||||
direct_url = _get_direct_url_if_editable(kayobe_dist[0])
|
||||
if direct_url:
|
||||
return direct_url
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user