跳转到内容

Swig

我们可以使用 Swig 来开发 Python 模块,详细的介绍可以看下:Python Modules with Swig

Cython

我们也可以使用 Cython 来构建 Python 模块。

EXPLORER
src
example.pyx
xmake.lua
Lua xmake.lua
1234567
add_rules("mode.debug", "mode.release")
add_requires("python 3.x")

target("example")
    add_rules("python.cython")
    add_files("src/*.pyx")
    add_packages("python")

PyBind

我们还可以使用 pybind11 来构建 python 模块。

EXPLORER
src
example.cpp
xmake.lua
Lua xmake.lua
12345678
add_rules("mode.release", "mode.debug")
add_requires("pybind11")

target("example")
    add_rules("python.module")
    add_files("src/*.cpp")
    add_packages("pybind11")
    set_languages("c++11")

Python Module

我们也可以使用 Python Library 提供的 C-API 接口直接构建 Python 模块。

EXPLORER
src
main.c
xmake.lua
Lua xmake.lua
1234567
add_rules("mode.debug", "mode.release")
add_requires("python 3.x")

target("example")
    add_rules("python.module")
    add_files("src/*.c")
    add_packages("python")