1 // Copyright Stefan Seefeld 2005. 2 // Distributed under the Boost Software License, Version 1.0. (See 3 // accompanying file LICENSE_1_0.txt or copy at 4 // http://www.boost.org/LICENSE_1_0.txt) 5 6 #include <boost/python/import.hpp> 7 #include <boost/python/borrowed.hpp> 8 #include <boost/python/extract.hpp> 9 #include <boost/python/handle.hpp> 10 11 namespace boost 12 { 13 namespace python 14 { 15 import(str name)16object BOOST_PYTHON_DECL import(str name) 17 { 18 // should be 'char const *' but older python versions don't use 'const' yet. 19 char *n = python::extract<char *>(name); 20 python::handle<> module(PyImport_ImportModule(n)); 21 return python::object(module); 22 } 23 24 } // namespace boost::python 25 } // namespace boost 26