Author: Markus Böck Date: 2023-01-06T09:58:35+01:00 New Revision: 9e84e038447e283d020ae01aebb15e0e66ef3642
URL: https://github.com/llvm/llvm-project/commit/9e84e038447e283d020ae01aebb15e0e66ef3642 DIFF: https://github.com/llvm/llvm-project/commit/9e84e038447e283d020ae01aebb15e0e66ef3642.diff LOG: [lldb] Allow configuring on Windows with python interpreter within a junction 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 interpreter and Ubuntu 18.04 with Python 3.6 Differential Revision: https://reviews.llvm.org/D141042 Added: Modified: lldb/bindings/python/get-python-config.py Removed: ################################################################################ diff --git a/lldb/bindings/python/get-python-config.py b/lldb/bindings/python/get-python-config.py index 32d82a54c160f..6369e32a49168 100755 --- a/lldb/bindings/python/get-python-config.py +++ b/lldb/bindings/python/get-python-config.py @@ -51,8 +51,10 @@ def main(): 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) _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits