It looks like f07ddbc6 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.