小编Sea*_*mew的帖子

为 C++ 库打包 Python 扩展:要包含什么,如何将其包含在 .whl 中?

我正在为 C++ 库编写一个扩展,以便使用 Pybind11 在 Python 中可用。该库本身依赖于其他几个 C++ 库。

我不明白的是我应该在我的分发包中包含哪些文件以及如何包含。混合了Python 打包指南构建 C++ 扩展中的一些代码后,我得到了以下文件

安装程序.py


from setuptools import setup, Extension
#from distutils.core import setup, Extension #used this at first, switched to setuptools. Didn't see the difference

src = ['module.cpp', /*... other cpp files */]
include = ['MyLibrary/include', /*... other header files for 3rdparty libs*/]


module = Extension(
    'TestlibPy', 
    sources = src,
    include_dirs= include,
    libraries=[/* library names*/]
    lib_dirs=[/*library dirs*/]
    language='c++',
    )

setup(
    ext_modules = [module],
)

Run Code Online (Sandbox Code Playgroud)

安装程序.cfg

[metadata] …
Run Code Online (Sandbox Code Playgroud)

c++ python packaging setuptools python-wheel

6
推荐指数
0
解决办法
640
查看次数

标签 统计

c++ ×1

packaging ×1

python ×1

python-wheel ×1

setuptools ×1