I wanted to use the macro cppyy_add_bindings from FindCppyy.cmake. I have to add this in a cpp/python using bazel project. How do I handle the library dependencies? Do I have to load all libraries explicitly in the py file, or is it possible to have bazel do this for me?
cmake to bazel - cppyy - shared libraries and includepath
602 Views Asked by user9092688 At
1
There are 1 best solutions below
Related Questions in BUILD
- Redirect inside java interceptor
- Spring RestTemplate passing the type of the response
- spring-integration-dsl-groovy-http return null when i use httpGet method
- Custom Spring annotation for request parameters
- Spring - configure Jboss Intros for xml with java config?
- HTTP Status 404 - Not Found in Spring 3.2.7
- AndroidAnnotations how to use setBearerAuth
- android I/O error: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found
- Show login dialog when not authenticated yet
- Spring Data Rest supporting json and xml
Related Questions in SHARED-LIBRARIES
- Redirect inside java interceptor
- Spring RestTemplate passing the type of the response
- spring-integration-dsl-groovy-http return null when i use httpGet method
- Custom Spring annotation for request parameters
- Spring - configure Jboss Intros for xml with java config?
- HTTP Status 404 - Not Found in Spring 3.2.7
- AndroidAnnotations how to use setBearerAuth
- android I/O error: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found
- Show login dialog when not authenticated yet
- Spring Data Rest supporting json and xml
Related Questions in BAZEL
- Redirect inside java interceptor
- Spring RestTemplate passing the type of the response
- spring-integration-dsl-groovy-http return null when i use httpGet method
- Custom Spring annotation for request parameters
- Spring - configure Jboss Intros for xml with java config?
- HTTP Status 404 - Not Found in Spring 3.2.7
- AndroidAnnotations how to use setBearerAuth
- android I/O error: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found
- Show login dialog when not authenticated yet
- Spring Data Rest supporting json and xml
Related Questions in CPPYY
- Redirect inside java interceptor
- Spring RestTemplate passing the type of the response
- spring-integration-dsl-groovy-http return null when i use httpGet method
- Custom Spring annotation for request parameters
- Spring - configure Jboss Intros for xml with java config?
- HTTP Status 404 - Not Found in Spring 3.2.7
- AndroidAnnotations how to use setBearerAuth
- android I/O error: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found
- Show login dialog when not authenticated yet
- Spring Data Rest supporting json and xml
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular # Hahtags
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
I'm not familiar with Bazel, but can perhaps shed some light of what cppyy needs/expects. In particular, FindCppyy.cmake was written with a specific type of use in mind that may not fit everyone.
What cppyy needs is for the linker symbols of C++ code used from Python to be available at run-time. How they are made available does not matter: as long as they are, it will work. Here are a couple of options:
Link dependent libraries with another library that will be loaded. This is typical when using dictionaries (https://cppyy.readthedocs.io/en/latest/utilities.html#dictionaries): simply link all the relevant library with the dictionary shared library, then only load the dictionary, the rest will be pulled in by the dynamic linker. This is the most common method AFAIK, precisely b/c the dependencies are easy to figure out as the build tool already has them and already knows how to link.
Add them to the .rootmap file (https://cppyy.readthedocs.io/en/latest/utilities.html#class-loader): when a class is not found, the .rootmap files (which should sit in some path reachable by
LD_LIBRARY_PATH
on Linux/Mac orPATH
on Windows) are searched and if the class is found there, the libraries specified are all loaded. This would have my preference (b/c class-lazy, not project-lazy) and is often used together with a dictionary file as above.Use
cppyy.load_library
explicitly within a Python module. Personally, I do not prefer this unless the code is truly well compartimentalized, and/or the project is small (a handful of libraries at most), as this approach is not lazy.Use another means such as
ctypes.CDLL
. This will work, butctypes.CDLL
behaves very differently from one OS to the next, putting more work on the developer, so I would not recommend it. It is also not lazy.The cppyy cmake macros mentioned assume that the goal is one python module per project, and that as laziness granularity, the project (as opposed to individual classes) is good enough. If that fits your purposes, that I'd go for the first option above: generate a dictionary from all headers for (each part of) the project, and get the list of libraries for it from Bazel, then when building the generated dictionary code, simply link with it. Finally, rely on auto-loading, or simply
load_library
that one dictionary shared library.Now, if I take your question completely literally (don't know whether I should), then there may be an option for Bazel to load libraries explicitly into the process, e.g. startup? If so, that would work as long as the libraries are loaded with the
RTLD_GLOBAL
flag (Linux, Mac; this is common), or have the relevant symbols exported (Windows; also common, but requires more care).