Skip to content

[Python3] Find the matching Python interpreter for LLDB in its build dir #33235

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 13 additions & 16 deletions test/lit.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,11 @@ def get_lldb_python_path(lldb_build_root):
return None
return subprocess.check_output([lldb_path, "-P"]).rstrip().decode('utf-8')

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

###

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

if config.lldb_build_root != "":
lldb_python_path = get_lldb_python_path(config.lldb_build_root)
lldb_python_interpreter = get_lldb_python_interpreter(config.lldb_build_root)
if lldb_python_path == None:
lit_config.warning("""
Specified lldb_build_root, but could not find lldb in that build root
""")
elif lldb_python_interpreter == None:
lit_config.warning("""
Specified lldb_build_root, but could not find lldb-python in that build root
""")
else:
lldb_python = get_lldb_python_from_path(lldb_python_path)
if lldb_python == None:
lit_config.warning("""
Unable to determine python version from LLDB Python path %s
""" % lldb_python_path)
else:
config.available_features.add('lldb')
config.substitutions.append(('%lldb-python-path', lldb_python_path))
config.substitutions.append(('%{lldb-python}', 'PYTHONPATH=%s %s' % (lldb_python_path, lldb_python)))
config.available_features.add('lldb')
config.substitutions.append(('%lldb-python-path', lldb_python_path))
config.substitutions.append(('%{lldb-python}', 'PYTHONPATH=%s %s' % (lldb_python_path, lldb_python_interpreter)))

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