Skip to content

Commit 14c7d70

Browse files
authored
feat: set LIBCLANG_PATH in environment on Linux (#3)
* useful if using the LLVM releases from tar files
1 parent 0103839 commit 14c7d70

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ 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.
25+
2426
Suppose we provide an input file with the following contents:
2527

2628
```cpp

pybind11_mkdoc/mkdoc_lib.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,8 +265,11 @@ def read_args(args):
265265
# versions and distributions. LLVM switched to a monolithical setup
266266
# that includes everything under /usr/lib/llvm{version_number}/
267267
# We therefore glob for the library and select the highest version
268-
library_file = sorted(glob("/usr/lib/llvm-*/lib/libclang.so.1"), reverse=True)[0]
269-
cindex.Config.set_library_file(library_file)
268+
if 'LIBCLANG_PATH' in os.environ:
269+
cindex.Config.set_library_file(os.environ['LIBCLANG_PATH'])
270+
else:
271+
library_file = sorted(glob("/usr/lib/llvm-*/lib/libclang.so.1"), reverse=True)[0]
272+
cindex.Config.set_library_file(library_file)
270273

271274
# clang doesn't find its own base includes by default on Linux,
272275
# but different distros install them in different paths.

0 commit comments

Comments
 (0)