Fix installation prefix detection
When multiple 'lib' components are present in the installation path, Kayobe fails to detect the right installation prefix which causes various commands to raise an error. Rewrite logic to detect the last 'lib' component in path instead. This should work as long as this function is not stored under a lib directory inside the Kayobe source tree. Change-Id: Ie9b15db6563546ede9ce9735292ec566d540432a Story: 2009721 Task: 44109
This commit is contained in:
parent
8897ea6d35
commit
e438189a19
@ -179,6 +179,13 @@ key2: value2
|
|||||||
result = utils._detect_install_prefix(path)
|
result = utils._detect_install_prefix(path)
|
||||||
self.assertEqual(expected, os.path.normpath(result))
|
self.assertEqual(expected, os.path.normpath(result))
|
||||||
|
|
||||||
|
def test_detect_install_prefix_multiple_lib_components(self):
|
||||||
|
tmp_path = os.path.realpath('/tmp')
|
||||||
|
path = "%s/lib/test/local/lib/python3.6/dist-packages" % tmp_path
|
||||||
|
expected = os.path.normpath("%s/lib/test/local/" % tmp_path)
|
||||||
|
result = utils._detect_install_prefix(path)
|
||||||
|
self.assertEqual(expected, os.path.normpath(result))
|
||||||
|
|
||||||
def test_intersect_limits_no_arg_no_cli(self):
|
def test_intersect_limits_no_arg_no_cli(self):
|
||||||
result = utils.intersect_limits(None, None)
|
result = utils.intersect_limits(None, None)
|
||||||
self.assertEqual("", result)
|
self.assertEqual("", result)
|
||||||
|
@ -14,7 +14,6 @@
|
|||||||
|
|
||||||
import base64
|
import base64
|
||||||
import glob
|
import glob
|
||||||
import itertools
|
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
@ -40,13 +39,11 @@ def _detect_install_prefix(path):
|
|||||||
script_path = os.path.realpath(path)
|
script_path = os.path.realpath(path)
|
||||||
script_path = os.path.normpath(script_path)
|
script_path = os.path.normpath(script_path)
|
||||||
components = script_path.split(os.sep)
|
components = script_path.split(os.sep)
|
||||||
# use heuristic: anything before 'lib' in path is the prefix
|
# use heuristic: anything before the last 'lib' in path is the prefix
|
||||||
if 'lib' not in components:
|
if 'lib' not in components:
|
||||||
return None
|
return None
|
||||||
prefix = itertools.takewhile(
|
last_lib = len(components) - 1 - components[::-1].index('lib')
|
||||||
lambda x: x != "lib",
|
prefix = components[:last_lib]
|
||||||
components
|
|
||||||
)
|
|
||||||
prefix_path = os.sep.join(prefix)
|
prefix_path = os.sep.join(prefix)
|
||||||
return prefix_path
|
return prefix_path
|
||||||
|
|
||||||
|
@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
fixes:
|
||||||
|
- |
|
||||||
|
Fixes a failure to detect the Kayobe installation prefix when ``lib`` is
|
||||||
|
present multiple times in the installation path. See `story 2009721
|
||||||
|
<https://storyboard.openstack.org/#!/story/2009721>`__ for details.
|
Loading…
Reference in New Issue
Block a user