我有一个 setup.py 看起来像这样:
from setuptools import setup, Extension
import glob
sources = glob.glob('src/*.cpp') + glob.glob('src/*.i')
# this is ugly, but otherwise I get the wrapper included twice
sources = [source for source in sources if '_wrap' not in source]
setup(
name = 'engine',
ext_modules = [
Extension(
'_engine',
sources = sources,
swig_opts = ['-c++'],
include_dirs = ['src']
)
],
py_modules = ['engine']
package_dir = {'' : 'src'}
)
现在只要我跑install
两次就可以了。第一次,swig 在 src 目录中创建 engine.py。但它不会被复制到目标。第二次运行 setup.py 文件时,找到并安装了 engine.py。有没有办法让这一切都在第一次工作?