This is an archive of the discontinued LLVM Phabricator instance.

[lldb] Allow configuring on Windows with python interpreter within a junction
ClosedPublic

Authored by zero9178 on Jan 5 2023, 3:03 AM.

Details

Summary

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

Diff Detail

Event Timeline

zero9178 created this revision.Jan 5 2023, 3:03 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 5 2023, 3:03 AM
zero9178 requested review of this revision.Jan 5 2023, 3:03 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 5 2023, 3:03 AM
JDevlieghere accepted this revision.Jan 5 2023, 9:21 AM

Looks reasonable to me.

@lawrence_danna do you happen to remember why you wrote:

exe = os.path.join(os.path.realpath(os.path.dirname(exe)), os.readlink(exe))

instead of

exe = os.path.realpath(exe)

which seems like it should be equivalent? Aand you're doing a realpath call anyway...

This revision is now accepted and ready to land.Jan 5 2023, 9:21 AM
clayborg accepted this revision.Jan 5 2023, 3:23 PM

lgtm