Skip to content

English

English

Appearance

Swig

We can use Swig to develop Python modules. For a detailed introduction, please see: Python Modules with Swig

Cython

We can also use Cython to build Python modules.

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

We can also use pybind11 to build python modules.

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

We can also use the C-API interface provided by the Python Library to build Python modules directly.

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")

AltStyle によって変換されたページ (->オリジナル) /