FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

GitHub Viewer

// Copyright Stefan Seefeld 2007. // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) #include #include #include #include #include namespace bpl = boost::python; void import_test(char const *py_file_path) { // Retrieve the main module bpl::object main = bpl::import("__main__"); // Retrieve the main module's namespace bpl::object global(main.attr("__dict__")); // Inject search path for import_ module bpl::str script( "import sys, os.path\n" "path = os.path.dirname(%r)\n" "sys.path.insert(0, path)" % bpl::str(py_file_path)); bpl::object result = bpl::exec(script, global, global); // Retrieve the main module bpl::object import_ = bpl::import("import_"); int value = bpl::extract(import_.attr("value")) BOOST_EXTRACT_WORKAROUND; std::cout

Back | FazBrowse Home | New Git URL