6 #include <pybind11/embed.h> 7 #include <pybind11/pybind11.h> 13 : mainModule(), ownsInterpreter_(ownsInterpreter) {
15 pybind11::initialize_interpreter();
22 pybind11::finalize_interpreter();
42 #if PY_MAJOR_VERSION >= 3 43 typedef std::unique_ptr<wchar_t[], decltype(&PyMem_RawFree)> WArgUPtr;
44 std::vector<WArgUPtr> v_argv;
45 std::vector<wchar_t*> vp_argv;
47 vp_argv.reserve(
argc);
48 for (
int i = 0;
i <
argc;
i++) {
49 v_argv.emplace_back(Py_DecodeLocale(
argv[
i],
nullptr), &PyMem_RawFree);
50 vp_argv.emplace_back(v_argv.back().get());
53 wchar_t** argvt = vp_argv.data();
58 PySys_SetArgv(
argc, argvt);
80 }
catch (pybind11::error_already_set
const&
e) {
93 command +=
"\nprocess.fillProcessDesc(processPSet)";
94 pybind11::exec(
command.c_str());
102 std::ostringstream os;
109 return std::make_unique<edm::ProcessDesc>(
parameterSet());
pybind11::object mainModule
void initializePyBind11Module()
void pythonToCppException(const std::string &iType, const std::string &error)
Python11ParameterSet theProcessPSet
edm::ParameterSet & pset()
std::unique_ptr< edm::ParameterSet > parameterSet() const
PyBind11InterpreterSentry theInterpreter
void readFile(std::string const &fileName)
PyBind11InterpreterSentry(bool ownsInterpreter)
~PyBind11InterpreterSentry()
void read(std::string const &config)
cond::Hash import(Session &source, const cond::Hash &sourcePayloadId, const std::string &inputTypeName, const void *inputPtr, Session &destination)
void readString(std::string const &pyConfig)
bool const ownsInterpreter_
std::unique_ptr< edm::ProcessDesc > processDesc() const