diff options
author | Haibo Huang <hhb@google.com> | 2019-10-07 23:49:01 +0000 |
---|---|---|
committer | Haibo Huang <hhb@google.com> | 2019-10-07 23:49:01 +0000 |
commit | 61f471a705a5df3d581ba4905337f433bac3ba1f (patch) | |
tree | e9b2f65b0e30300541d8fcefa733d2f6009b6729 /lldb/scripts/get_relative_lib_dir.py | |
parent | f4c7345b88f8ca56ee350a4a0dbfee7e2db79839 (diff) | |
download | bcm5719-llvm-61f471a705a5df3d581ba4905337f433bac3ba1f.tar.gz bcm5719-llvm-61f471a705a5df3d581ba4905337f433bac3ba1f.zip |
[lldb] Unifying lldb python path
Based on mgorny@'s D67890
There are 3 places where python site-package path is calculated
independently:
1. finishSwigPythonLLDB.py where files are written to site-packages.
2. lldb/scripts/CMakeLists.txt where site-packages are installed.
3. ScriptInterpreterPython.cpp where site-packages are added to
PYTHONPATH.
This change creates the path once and use it everywhere. So that they
will not go out of sync.
Also it provides a chance for cross compiling users to specify the right
path for site-packages.
Subscribers: lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D68442
llvm-svn: 373991
Diffstat (limited to 'lldb/scripts/get_relative_lib_dir.py')
-rw-r--r-- | lldb/scripts/get_relative_lib_dir.py | 44 |
1 files changed, 0 insertions, 44 deletions
diff --git a/lldb/scripts/get_relative_lib_dir.py b/lldb/scripts/get_relative_lib_dir.py deleted file mode 100644 index 3afeeafd7b4..00000000000 --- a/lldb/scripts/get_relative_lib_dir.py +++ /dev/null @@ -1,44 +0,0 @@ -import distutils.sysconfig -import os -import platform -import re -import sys - - -def get_python_relative_libdir(): - """Returns the appropropriate python libdir relative to the build directory. - - @param exe_path the path to the lldb executable - - @return the python path that needs to be added to sys.path (PYTHONPATH) - in order to find the lldb python module. - """ - if platform.system() != 'Linux': - return None - - # We currently have a bug in lldb -P that does not account for - # architecture variants in python paths for - # architecture-specific modules. Handle the lookup here. - # When that bug is fixed, we should just ask lldb for the - # right answer always. - arch_specific_libdir = distutils.sysconfig.get_python_lib(True, False) - split_libdir = arch_specific_libdir.split(os.sep) - lib_re = re.compile(r"^lib.*$") - - for i in range(len(split_libdir)): - match = lib_re.match(split_libdir[i]) - if match is not None: - # We'll call this the relative root of the lib dir. - # Things like RHEL will have an arch-specific python - # lib dir, which isn't 'lib' on x86_64. - return os.sep.join(split_libdir[i:]) - # Didn't resolve it. - return None - -if __name__ == '__main__': - lib_dir = get_python_relative_libdir() - if lib_dir is not None: - sys.stdout.write(lib_dir) - sys.exit(0) - else: - sys.exit(1) |