Accounts for Ubuntu paths on pip installation

On Ubuntu pip installs everything to /usr/local by default, including
putting DIB element to /usr/local/share, where we cannot find it.
This changes add support for it and additionally improves error message.

Change-Id: I52e0abd7e69668f15ca7a02ad238a96b98eeaaf3
This commit is contained in:
Dmitry Tantsur 2019-08-26 18:02:12 +02:00
parent a1858be876
commit 84f673d30a

View File

@ -17,7 +17,10 @@ import sys
LOCATIONS = [
'.',
os.path.abspath('.'),
# This accounts for pip installations on Ubuntu that go into /usr/local
os.path.abspath(os.path.basename(sys.argv[0])),
# This accounts for system-wide installations to /usr
os.path.join(sys.prefix, 'share', 'ironic-python-agent-builder'),
]
@ -29,7 +32,7 @@ def find_elements_path():
return final
sys.exit('ironic-python-agent-ramdisk element has not been found in any '
'of the following locations: %s' % ', '.join(LOCATIONS))
'of the following locations: %s' % ', '.join(set(LOCATIONS)))
def main():