I've already created a so file using boost.python , and importing it in bash is just fine.
But now I'm wondering if it is possible to make it a regular python module . That means I don't want to mannually place the so file and it's dependencies in system path, or add LD_LIBRARY_PATH every time I use it. Are there any ways to achieve that?
You can make a module by using distutils . For example setup.py
from distutils.core import setup, Extension
ext_instance = Extension(
'mylib_ext',
sources=['main.cpp'],
libraries=['boost_python-mt'],
)
setup(
name='mylib',
version='0.1',
ext_modules=[ext_instance],
)
then build locally python setup.py build
or install python setup.py install
in the current environment
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.