Skip to content

Commit

Permalink
Convert from pybind11 to nanobind
Browse files Browse the repository at this point in the history
  • Loading branch information
valgur committed Dec 22, 2024
1 parent 610d057 commit 2e19c9a
Show file tree
Hide file tree
Showing 3 changed files with 203 additions and 171 deletions.
8 changes: 5 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,12 @@ endif()
## Python bindings
option(BUILD_PYTHON "Build velodyne_decoder_pylib Python module" FALSE)
if(BUILD_PYTHON OR SKBUILD)
find_package(Python REQUIRED COMPONENTS Interpreter Development.Module)
find_package(pybind11 CONFIG REQUIRED)
find_package(Python
REQUIRED COMPONENTS Interpreter Development.Module
OPTIONAL_COMPONENTS Development.SABIModule)
find_package(nanobind CONFIG REQUIRED)

pybind11_add_module(python_bindings src/python.cpp)
nanobind_add_module(python_bindings STABLE_ABI NB_STATIC src/python.cpp)
set_target_properties(python_bindings PROPERTIES OUTPUT_NAME velodyne_decoder_pylib)
target_include_directories(python_bindings PRIVATE include)
target_link_libraries(python_bindings PRIVATE velodyne_decoder)
Expand Down
4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ include-package-data = true
requires = [
"scikit-build-core >=0.4.3",
"conan >=2.0.5",
"pybind11"
"nanobind"
]
build-backend = "scikit_build_core.build"

Expand All @@ -47,6 +47,8 @@ cmake.targets = ["python_bindings"]
install.components = ["python"]
wheel.license-files = ["LICENSE"]
build-dir = "build/{wheel_tag}"
# Build stable ABI wheels for CPython 3.12+
wheel.py-api = "cp312"

[tool.scikit-build.cmake.define]
BUILD_PYTHON = true
Expand Down
Loading

0 comments on commit 2e19c9a

Please sign in to comment.