2

I am building a python library, that I want to be installable via pip. The installation process requires a cpp file to be compiled, and that cpp file depends on libclang (in particular, it includes some of clang-c header files, and needs to be linked against libclang.so).

I am assuming that the end user has clang++ installed. However, I don't know where that installation is. For example, when I installed clang++ locally, even though it installed all the headers and the library I need, if I just compile a blank C++ file that has

#include <clang-c/CXCompilationDatabase.h>

It won't find it. I need to explicitly provide the path via command-line argument or CPLUS_INCLUDE_PATH.

Now I need some way for the script that pip invokes to find those headers. I obviously can ask the user to set CPLUS_INCLUDE_PATH and LD_LIBRARY_PATH to include paths to clang++ before running the installation process, but it seems ugly. I can add headers and the library into my package, but then I would rather it build against the version that the user has. Is there a way to find a clang++ installation if a user has one (or at least if he installed one via apt-get or another package manager?), or in general, what is the correct way of solving this issue when building a pip package?

4

0 回答 0