【问题标题】:How to create a Python package from a PyBind11 module created with CMake如何从使用 CMake 创建的 PyBind11 模块创建 Python 包
【发布时间】:2022-12-02 19:40:40
【问题描述】:

I have a C++ code using Cmake & make for the building part. I also have python bindings to this code thanks to PyBind11.

I use pybind11_add_module inside CMakeLists.txt and now when I build (cmake -Bbuild && cd build && make) it creates a python_module.so in the build directory.

I can move it manually elsewhere, and if the module is in the same folder I can use it in python scripts.

Now I\'d like to \"package\" this module and I don\'t know how. My goal would be to be able to pip install python_package_from_module to use it anywhere without the need to manually move/duplicate the python_module.so file. (Edit/Note : for now I don\'t want to publish my package on PiPy, just to be able to pip install locally the package)

Do you know how to do that ? I don\'t have a lot of knowledge about packaging, I\'ve only done it once with a pyproject.toml and a setup.cfg.

The only examples I found use setup.py and are way more complicated. For example I must admit that I really don\'t understand how does this Pybind11 Cmake Example work.

    标签: python python-packaging pybind11


    【解决方案1】:
    猜你喜欢
    • 2018-11-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-10-03
    • 2019-01-25
    • 2021-12-29
    • 1970-01-01
    相关资源
    最近更新 更多