[Lldb-commits] [PATCH] D141042: [lldb] Allow configuring on Windows with python interpreter within a junction
Markus Böck via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Thu Jan 5 03:03:56 PST 2023
zero9178 created this revision.
zero9178 added reviewers: JDevlieghere, lawrence_danna, clayborg, labath, jingham.
Herald added a project: All.
zero9178 requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.
The current implementation nicely takes into account when the python interpreter is symlinked (or transitively within a symlinked directory). Sadly, `os.path.islink` returns `false` on Windows if instead of Windows symlinks, junctions are used. This has caused me issues after I started using `scoop` as my package manager on Windows, which creates junctions instead of symlinks.
The fix proposed in this patch is to check whether `realpath` returns a different path to `exe`, and if it does, to simply try again with that path.
The code could also be simplified since `sys.executable` is guaranteed to be absolute, and `os.readlink`, which can return a relative path, is no longer used.
Tested on Windows 11 with Python 3.11 as interpereter and Ubuntu 18.04 with Python 3.6
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D141042
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
@@ -51,8 +51,10 @@
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))
+ # Retry if the executable is symlinked or similar.
+ # This is roughly equal to os.path.islink, except it also works for junctions on Windows.
+ if os.path.realpath(exe) != exe:
+ exe = os.path.realpath(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: D141042.486511.patch
Type: text/x-patch
Size: 897 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20230105/a630239a/attachment-0001.bin>
More information about the lldb-commits
mailing list