如何将预编译的 .so
库和 Python 模块打包在一起?具体来说,我该如何编写 setup.py
,以便在 Python 中执行以下操作:
>>> import top_secret_wrapper
不需要设置 LD_LIBRARY_PATH
,就可以轻松找到 top_secret.so
吗?
在我的模块开发环境中,我有以下文件结构:
.
├── top_secret_wrapper
│ ├── top_secret.so
│ └── __init__.py
└── setup.py
在__init__.py
中,我有以下代码:
import top_secret
这是我的setup.py
文件
from setuptools import setup, Extension
setup(
name = 'top_secret_wrapper',
version = '0.1',
description = 'A Python wrapper for a top secret algorithm',
url = None,
author = 'James Bond',
author_email = 'James.Bond.007@mi6.org',
license = 'Spy Game License',
zip_safe = True,
)
我确定我的setup.py
缺少一个设置,用于指定top_secret.so
的位置,尽管我不确定如何做到这一点。