MCPcopy Create free account
hub / github.com/pybind/pybind11 / main

Function main

tests/test_cmake_build/embed.cpp:8–23  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6}
7
8int main(int argc, char *argv[]) {
9 if (argc != 2) {
10 throw std::runtime_error("Expected test.py file as the first argument");
11 }
12 auto *test_py_file = argv[1];
13
14 py::scoped_interpreter guard{};
15
16 auto m = py::module_::import("test_cmake_build");
17 if (m.attr("add")(1, 2).cast<int>() != 3) {
18 throw std::runtime_error("embed.cpp failed");
19 }
20
21 py::module_::import("sys").attr("argv") = py::make_tuple("test.py", "embed.cpp");
22 py::eval_file(test_py_file, py::globals());
23}

Callers

nothing calls this directly

Calls 5

importFunction · 0.85
make_tupleFunction · 0.85
eval_fileFunction · 0.85
globalsFunction · 0.85
attrMethod · 0.80

Tested by

no test coverage detected