Warning, file /jana2/src/python/modules/jana/jana_module.cc was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005 #include <janapy.h>
0006 #include <JANA/CLI/JMain.h>
0007 #include <JANA/JVersion.h>
0008 #include <dlfcn.h>
0009
0010
0011 class PYTHON_MODULE_STARTUP_FAILED{public: PYTHON_MODULE_STARTUP_FAILED(){}};
0012
0013
0014
0015
0016
0017
0018
0019 PYBIND11_MODULE(jana, m) {
0020
0021 m.doc() = "JANA2 Python Interface";
0022
0023
0024 JANA_MODULE_DEF
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040 std::string suffix = ".so";
0041 #if __APPLE__
0042 suffix = ".dylib";
0043 #endif
0044
0045 auto jana_install_dir = JVersion::GetInstallDir();
0046 auto shared_lib = jana_install_dir + "/lib/libJANA" + suffix;
0047 void* handle = dlopen(shared_lib.c_str(), RTLD_LAZY | RTLD_GLOBAL | RTLD_NODELETE);
0048 if (!handle) {
0049 LOG_ERROR(default_cerr_logger) << dlerror() << LOG_END;
0050 LOG_ERROR(default_cerr_logger) << "This may be due to building JANA with BUILD_SHARED_LIBS=Off." << LOG_END;
0051 LOG_ERROR(default_cerr_logger) << "You can try running with the embedded python interpreter like this:" << LOG_END;
0052 LOG_ERROR(default_cerr_logger) << LOG_END;
0053 LOG_ERROR(default_cerr_logger) << " jana -Pplugins=janapy -PJANA_PYTHON_FILE=myfile.py" << LOG_END;
0054 LOG_ERROR(default_cerr_logger) << LOG_END;
0055 LOG_ERROR(default_cerr_logger) << "Alternatively, build JANA with BUILD_SHARED_LIBS=On" << LOG_END;
0056
0057 throw PYTHON_MODULE_STARTUP_FAILED();
0058 }else{
0059
0060 }
0061 auto options = jana::ParseCommandLineOptions(0, nullptr, false);
0062 pyjapp = jana::CreateJApplication(options);
0063
0064 PY_MODULE_INSTANTIATED_JAPPLICATION = true;
0065 }