Skip to content

Commit 9a88b4e

Browse files
authored
Merge pull request swiftlang#33235 from JDevlieghere/use-lldb-python-interpreter
[Python3] Find the matching Python interpreter for LLDB in its build dir
2 parents 2e4d76c + 68f6e0a commit 9a88b4e

File tree

1 file changed

+13
-16
lines changed

1 file changed

+13
-16
lines changed

test/lit.cfg

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,11 @@ def get_lldb_python_path(lldb_build_root):
104104
return None
105105
return subprocess.check_output([lldb_path, "-P"]).rstrip().decode('utf-8')
106106

107-
def get_lldb_python_from_path(lldb_path):
108-
(head, tail) = os.path.split(lldb_path)
109-
if tail and re.match('^python[23][.0-9]*$', tail):
110-
return tail
111-
if head and head != lldb_path:
112-
return get_lldb_python_from_path(head)
113-
return None
107+
def get_lldb_python_interpreter(lldb_build_root):
108+
python_path = os.path.join(lldb_build_root, 'bin', 'lldb-python')
109+
if not os.access(python_path, os.F_OK):
110+
return None
111+
return python_path
114112

115113
###
116114

@@ -1959,20 +1957,19 @@ config.substitutions.append(('%import-libdispatch', getattr(config, 'import_libd
19591957

19601958
if config.lldb_build_root != "":
19611959
lldb_python_path = get_lldb_python_path(config.lldb_build_root)
1960+
lldb_python_interpreter = get_lldb_python_interpreter(config.lldb_build_root)
19621961
if lldb_python_path == None:
19631962
lit_config.warning("""
19641963
Specified lldb_build_root, but could not find lldb in that build root
19651964
""")
1965+
elif lldb_python_interpreter == None:
1966+
lit_config.warning("""
1967+
Specified lldb_build_root, but could not find lldb-python in that build root
1968+
""")
19661969
else:
1967-
lldb_python = get_lldb_python_from_path(lldb_python_path)
1968-
if lldb_python == None:
1969-
lit_config.warning("""
1970-
Unable to determine python version from LLDB Python path %s
1971-
""" % lldb_python_path)
1972-
else:
1973-
config.available_features.add('lldb')
1974-
config.substitutions.append(('%lldb-python-path', lldb_python_path))
1975-
config.substitutions.append(('%{lldb-python}', 'PYTHONPATH=%s %s' % (lldb_python_path, lldb_python)))
1970+
config.available_features.add('lldb')
1971+
config.substitutions.append(('%lldb-python-path', lldb_python_path))
1972+
config.substitutions.append(('%{lldb-python}', 'PYTHONPATH=%s %s' % (lldb_python_path, lldb_python_interpreter)))
19761973

19771974
# Disable randomized hash seeding by default. Tests need to manually opt in to
19781975
# random seeds by unsetting the SWIFT_DETERMINISTIC_HASHING environment

0 commit comments

Comments
 (0)