38 #include <pybind11/embed.h> 42 namespace py = pybind11;
46 main(
int argc,
char **argv) {
47 py::scoped_interpreter guard{};
50 std::cerr <<
"Usage: marshal PYSOURCE\n" << std::endl;
54 auto locals = py::dict(
"source"_a=argv[1]);
58 "with open(source, 'r') as f: src = f.read()\n" 59 "compiled = compile(src, source, 'exec')\n" 60 "marshalled = marshal.dumps(compiled)\n",
63 auto marshalled = locals[
"marshalled"].cast<std::string>();
64 std::cout << marshalled;
Globals globals
The one and only instance of the Globals class.
int main(int argc, char **argv)