Skip to content

Commit 2627803

Browse files
themarpehenryiii
authored andcommitted
Specify path to LLVM directory using environmental variable
1 parent 73ee354 commit 2627803

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ be written to ``stdout``, or to a filename provided via the ``-o`` parameter.
2121
python -m pybind11_mkdoc -o docstrings.h header_file_1.h header_file_2.h
2222
```
2323

24-
Optionally, the path to the `libclang.so` can be specified by setting the LIBCLANG_PATH environment variable.
24+
Optionally, the path to the `libclang.so` and LLVM directory can be specified by setting the LIBCLANG_PATH and LLVM_DIR_PATH environment variables respectively.
2525

2626
Suppose we provide an input file with the following contents:
2727

pybind11_mkdoc/mkdoc_lib.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -278,12 +278,17 @@ def read_args(args):
278278
def folder_version(d):
279279
return [int(ver) for ver in re.findall(r'(?<!lib)(?<!\d)\d+', d)]
280280

281-
llvm_dir = max((
282-
path
283-
for libdir in ['lib64', 'lib', 'lib32']
284-
for path in glob('/usr/%s/llvm-*' % libdir)
285-
if os.path.isdir(path)
286-
), default=None, key=folder_version)
281+
# capability to specify path to LLVM dir manually
282+
# useful when installing LLVM to non standard directories
283+
if 'LLVM_DIR_PATH' in os.environ:
284+
llvm_dir = os.environ['LLVM_DIR_PATH']
285+
else:
286+
llvm_dir = max((
287+
path
288+
for libdir in ['lib64', 'lib', 'lib32']
289+
for path in glob('/usr/%s/llvm-*' % libdir)
290+
if os.path.isdir(path)
291+
), default=None, key=folder_version)
287292

288293

289294
if llvm_dir:

0 commit comments

Comments
 (0)