6 #include <pybind11/embed.h> 7 #include <pybind11/pybind11.h> 17 pybind11::initialize_interpreter();
29 pybind11::initialize_interpreter();
33 #if PY_MAJOR_VERSION >= 3 34 typedef std::unique_ptr<wchar_t[], decltype(&PyMem_RawFree)> WArgUPtr;
35 std::vector<WArgUPtr> v_argv;
36 std::vector<wchar_t*> vp_argv;
38 vp_argv.reserve(argc);
39 for (
int i = 0;
i <
argc;
i++) {
40 v_argv.emplace_back(Py_DecodeLocale(argv[
i],
nullptr), &PyMem_RawFree);
41 vp_argv.emplace_back(v_argv.back().get());
44 wchar_t** argvt = vp_argv.data();
49 PySys_SetArgv(argc, argvt);
57 pybind11::finalize_interpreter();
71 if (config.substr(config.size() - 3) ==
".py") {
76 }
catch (pybind11::error_already_set
const&
e) {
82 pybind11::eval_file(fileName);
84 pybind11::exec(command);
89 command +=
"\nprocess.fillProcessDesc(processPSet)";
90 pybind11::exec(command.c_str());
98 std::ostringstream os;
105 return std::make_unique<edm::ProcessDesc>(
parameterSet());
void pythonToCppException(const std::string &iType, const std::string &error)
Python11ParameterSet theProcessPSet
void initializePyBind11Module()
void readString(std::string const &pyConfig)
void readFile(std::string const &fileName)
std::unique_ptr< edm::ParameterSet > parameterSet() const
pybind11::object theMainModule
cond::Hash import(Session &source, const cond::Hash &sourcePayloadId, const std::string &inputTypeName, const void *inputPtr, Session &destination)
std::unique_ptr< edm::ProcessDesc > processDesc() const
edm::ParameterSet & pset()
void read(std::string const &config)