6 #include <pybind11/embed.h> 7 #include <pybind11/pybind11.h> 13 : mainModule(), ownsInterpreter_(ownsInterpreter) {
15 pybind11::initialize_interpreter();
22 pybind11::finalize_interpreter();
29 : theProcessPSet(), theInterpreter(
true) {
36 : theProcessPSet(), theInterpreter(
true) {
40 typedef std::unique_ptr<wchar_t[], decltype(&PyMem_RawFree)> WArgUPtr;
41 std::vector<WArgUPtr> v_argv;
42 std::vector<wchar_t*> vp_argv;
43 v_argv.reserve(
args.size());
44 vp_argv.reserve(
args.size());
45 for (
size_t i = 0;
i <
args.size();
i++) {
46 v_argv.emplace_back(Py_DecodeLocale(
args[
i].c_str(),
nullptr), &PyMem_RawFree);
47 vp_argv.emplace_back(v_argv.back().get());
50 wchar_t** argvt = vp_argv.data();
52 PySys_SetArgv(
args.size(), argvt);
72 }
catch (pybind11::error_already_set
const&
e) {
85 command +=
"\nprocess.fillProcessDesc(processPSet)";
86 pybind11::exec(
command.c_str());
94 std::ostringstream os;
101 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, bool isFile)
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