[PATCH] D52806: [python] Support overriding library path via environment

Michał Górny via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 2 15:27:33 PDT 2018


mgorny updated this revision to Diff 168042.
mgorny added a comment.

(also included README update)


https://reviews.llvm.org/D52806

Files:
  bindings/python/README.txt
  bindings/python/clang/cindex.py


Index: bindings/python/clang/cindex.py
===================================================================
--- bindings/python/clang/cindex.py
+++ bindings/python/clang/cindex.py
@@ -67,6 +67,7 @@
 
 import clang.enumerations
 
+import os
 import sys
 if sys.version_info[0] == 3:
     # Python 3 strings are unicode, translate them to/from utf8 for C-interop.
@@ -4148,6 +4149,8 @@
 
         if Config.library_path:
             file = Config.library_path + '/' + file
+        elif 'CLANG_LIBRARY_PATH' in os.environ:
+            file = os.environ['CLANG_LIBRARY_PATH'] + '/' + file
 
         return file
 
Index: bindings/python/README.txt
===================================================================
--- bindings/python/README.txt
+++ bindings/python/README.txt
@@ -4,12 +4,12 @@
 
 This directory implements Python bindings for Clang.
 
-You may need to alter LD_LIBRARY_PATH so that the Clang library can be
+You may need to set CLANG_LIBRARY_PATH so that the Clang library can be
 found. The unit tests are designed to be run with any standard test
 runner. For example:
 --
 $ env PYTHONPATH=$(echo ~/llvm/tools/clang/bindings/python/) \
-      LD_LIBRARY_PATH=$(llvm-config --libdir) \
+      CLANG_LIBRARY_PATH=$(llvm-config --libdir) \
   python -m unittest discover -v
 tests.cindex.test_index.test_create ... ok
 ...


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D52806.168042.patch
Type: text/x-patch
Size: 1340 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20181002/d6f1aaaf/attachment.bin>


More information about the cfe-commits mailing list