我正在开发一个python包,它基本上是c后端的python包装器。c-backend通过ctypes称为formpython。在
如果我给ctypes一个指向库的绝对路径来加载它,它会很好地工作。但是如果库是通过distutils编译的,我不知道如何找到库的绝对路径setup.py?(安装脚本成功地构建了库。)
以下是setup.py
的重要片段:
libreboundmodule = Extension('librebound',
sources = [ 'librebound/librebound.c' ],
)
setup(name='rebound',
...
ext_modules = [libreboundmodule])
这是反弹模块的一部分__init__.py
。如何让ctypes知道我的库的路径?在
编辑:
可以做以下事情吗?在
import ctypes
PATH = os.path.dirname(__file__)
librebound = ctypes.CDLL(PATH+"/../librebound.so", RTLD_GLOBAL)
目前没有回答
相关问题 更多 >
编程相关推荐