Skip to content

Commit 61bf97f

Browse files
Andreas Kunzehenryiii
authored andcommitted
Explicitly fail if libclang shared object file could not be found in default locations. Fixes #15
1 parent 0be71a5 commit 61bf97f

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

pybind11_mkdoc/mkdoc_lib.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,8 +280,13 @@ def read_args(args):
280280
if 'LIBCLANG_PATH' in os.environ:
281281
cindex.Config.set_library_file(os.environ['LIBCLANG_PATH'])
282282
else:
283-
library_file = sorted(glob("/usr/lib/llvm-*/lib/libclang.so.1"), reverse=True)[0]
284-
cindex.Config.set_library_file(library_file)
283+
library_file_dirs = glob("/usr/lib/llvm-*/lib/libclang.so.1")
284+
if len(library_file_dirs) > 0:
285+
library_file = sorted(library_file_dirs, reverse=True)[0]
286+
cindex.Config.set_library_file(library_file)
287+
else:
288+
raise FileNotFoundError("Failed to find libclang.so shared object file! "
289+
"Set the LIBCLANG_PATH environment variable to provide a path to it.")
285290

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

0 commit comments

Comments
 (0)