[Lldb-commits] [PATCH] D133513: [lldb] Fix detection of LLDB_PYTHON_EXE_RELATIVE_PATH
Sergey Kosukhin via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Thu Sep 8 11:44:32 PDT 2022
skosukhin created this revision.
skosukhin added a reviewer: lawrence_danna.
Herald added a project: All.
skosukhin requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.
It looks like f07ddbc6 <https://reviews.llvm.org/rGf07ddbc620a0466ebbb41ccbc78f20a8591bed5a> broke the building when `sys.executable` is not a symlink itself but resides in a prefix that is one:
$ readlink /sw
/opt/zmaw/sw
$ /sw/python-3.9.12/bin/python3.9 ./get-python-config.py LLDB_PYTHON_EXE_RELATIVE_PATH
Could not find a relative path to sys.executable under sys.prefix
tried: /sw/python-3.9.12/bin/python3.9
realpath(sys.prefix): /opt/zmaw/sw/python-3.9.12
sys.prefix: /sw/python-3.9.12
I think it makes sense to try `sys.prefix` and `sys.executable` first and only then try to resolve the real paths for **both** `sys.prefix` and `os.path.dirname(sys.executable)`.
I would remove the `elif os.path.islink(exe):` logic as it seems to be redundant but I cannot tell for sure that it is.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D133513
Files:
lldb/bindings/python/get-python-config.py
Index: lldb/bindings/python/get-python-config.py
===================================================================
--- lldb/bindings/python/get-python-config.py
+++ lldb/bindings/python/get-python-config.py
@@ -44,15 +44,21 @@
elif args.variable_name == "LLDB_PYTHON_EXE_RELATIVE_PATH":
tried = list()
exe = sys.executable
- prefix = os.path.realpath(sys.prefix)
+ prefix = sys.prefix
while True:
try:
print(relpath_nodots(exe, prefix))
break
except ValueError:
tried.append(exe)
- if os.path.islink(exe):
- exe = os.path.join(os.path.realpath(os.path.dirname(exe)), os.readlink(exe))
+ real_exe_dirname = os.path.realpath(os.path.dirname(exe))
+ real_prefix = os.path.realpath(prefix)
+ if prefix != real_prefix:
+ prefix = real_prefix
+ exe = os.path.join(real_exe_dirname, os.path.basename(exe))
+ continue
+ elif os.path.islink(exe):
+ exe = os.path.join(real_exe_dirname, os.readlink(exe))
continue
else:
print("Could not find a relative path to sys.executable under sys.prefix", file=sys.stderr)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D133513.458803.patch
Type: text/x-patch
Size: 1356 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20220908/28a40f29/attachment.bin>
More information about the lldb-commits
mailing list