开发者

How does python load Boost.Python libraries?

开发者 https://www.devze.com 2023-01-14 12:24 出处:网络
Considering the following archetypal Boost.Python module, which brings a class \"D\" from a separate C++ header file.

Considering the following archetypal Boost.Python module, which brings a class "D" from a separate C++ header file.

/* file: a/b.cpp */
BOOST_PYTHON_MODULE(c)
{
    class_<d>("D")
}

When I compile this to a shared library, I'm confused how I can expose it to Python.

  1. What should I call the library? a.so? liba.so? b.so? libb.so?
  2. Where does the library need to be? Can I leave it in开发者_如何学运维 a subdirectory?


We prefer to call the library _c.so, put it in a module, and then add an __init__.py that basically does from _c import *. So you have:

  • package
    • _c.so
    • __init__.py
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号