Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to libclang #32

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Switch to libclang #32

wants to merge 3 commits into from

Conversation

corna
Copy link
Contributor

@corna corna commented Jul 10, 2023

A newer package provigind the python libclang bindings is available, called "libclang". Unlike "clang", this package ships the libclang library, removing the dependency from the system's one. This dependency is particularly frustrating as it requires not only the presence of libclang on the system, but also a specific version of it, requiring things like pip3 install clang==14 where the version depends on the distro and distro's version.

The "libclang" library is identical to the "clang" one, the only difference being a pre-set index.Config.library_path, set to the package's library.

This PR adds support to it, detecting if index.Config.library_path is set (and so, if "libclang" is being used) and leaving it as it is unless overridden by the environment variables. With this, pybind11_mkdoc works out-of-the-box.

The only issue are the system's headers, not shipped within "libclang" (see sighingnow/libclang#40) which cause some error messages on the stderr like

/usr/include/unistd.h:226:10: fatal error: 'stddef.h' file not found

but the docstrings generation successfully completes anyways.

As a side effect, this fixes pybind11_mkdoc on Arch Linux, as it currently can not find libclang.so (installed under /usr/lib/, while pybind11_mkdoc searches it under /usr/lib/llvm{version_number}/).

Tested only on Linux.

A newer package provigind the python libclang bindings is available, called
"libclang". Unlike "clang", this package ships the libclang library, removing
the dependency from the system's one.

This commit adds support for it, using the libclang's builtin library if found
and if LIBCLANG_PATH and LLVM_DIR_PATH are not defined.

As libclang does not ship the clang standard library headers, some system
headers may not be found (like stddef.h), but the documentation generation
completes successfully anyways.
@aloisklink aloisklink mentioned this pull request Jul 18, 2023
jeguzzi added a commit to jeguzzi/pybind11_mkdoc that referenced this pull request Sep 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant