-
Notifications
You must be signed in to change notification settings - Fork 177
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[python] First small example for nanobind module.
- Loading branch information
1 parent
41145e1
commit 120f12f
Showing
16 changed files
with
68 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ set(ecal_submodule_dependencies | |
GTest | ||
HDF5 | ||
#libssh2 | ||
nanobind | ||
Protobuf | ||
qwt | ||
recycle | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Try to import all Python components potentially needed by nanobind | ||
find_package(Python | ||
REQUIRED COMPONENTS Interpreter Development.Module | ||
OPTIONAL_COMPONENTS Development.SABIModule) | ||
|
||
# Import nanobind through CMake's find_package mechanism | ||
find_package(nanobind CONFIG REQUIRED) | ||
|
||
# We are now ready to compile the actual extension module | ||
nanobind_add_module( | ||
# Name of the extension | ||
nanobind_core | ||
|
||
# Target the stable ABI for Python 3.12+, which reduces | ||
# the number of binary wheels that must be built. This | ||
# does nothing on older Python versions | ||
STABLE_ABI | ||
|
||
# Source code goes here | ||
main.cpp | ||
) | ||
|
||
# Install directive for scikit-build-core | ||
install(TARGETS nanobind_core LIBRARY DESTINATION nanobind_core) | ||
|
||
if(WIN32) | ||
set_property(TARGET nanobind_core PROPERTY FOLDER lang/python/core) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#include <nanobind/nanobind.h> | ||
|
||
NB_MODULE(nanobind_core, m) { | ||
m.def("hello", []() { return "Hello world!"; }); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
include_guard(GLOBAL) | ||
|
||
message(STATUS "building nanobind") | ||
|
||
if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.25.0") | ||
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/nanobind thirdparty/nanobind EXCLUDE_FROM_ALL SYSTEM) | ||
else () | ||
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/nanobind thirdparty/nanobind EXCLUDE_FROM_ALL) | ||
endif () |