Skip to content

Commit 1b44305

Browse files
committed
python-nb : send nanobind module coal_pywrap_v2 to new Python module "coal.v2"
1 parent ea9673e commit 1b44305

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

python-nb/CMakeLists.txt

+23-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ find_package(nanobind CONFIG REQUIRED)
44
set(PYTHON_LIB_NAME_V2 coal_pywrap_v2)
55
set(coal_pywrap_v2_SOURCES coal.cc)
66

7-
nanobind_add_module(${PYTHON_LIB_NAME_V2} NB_STATIC NB_SUPPRESS_WARNINGS ${coal_pywrap_v2_SOURCES})
7+
nanobind_add_module(${PYTHON_LIB_NAME_V2} NB_STATIC LTO NB_SUPPRESS_WARNINGS ${coal_pywrap_v2_SOURCES})
88
target_link_libraries(
99
${PYTHON_LIB_NAME_V2}
1010
PRIVATE ${PROJECT_NAME} Boost::system
@@ -13,3 +13,25 @@ target_compile_definitions(
1313
${PYTHON_LIB_NAME_V2}
1414
PRIVATE COAL_PYTHON_LIBNAME=${PYTHON_LIB_NAME_V2}
1515
)
16+
17+
set(MODULE_DIR ${PROJECT_NAME}/v2)
18+
string(REPLACE "/" "." MODULE_NAME ${MODULE_DIR})
19+
20+
set_target_properties(
21+
${PYTHON_LIB_NAME_V2}
22+
PROPERTIES
23+
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${MODULE_DIR}"
24+
)
25+
26+
set(PYTHON_FILES __init__.py v2/__init__.py)
27+
28+
foreach(pyfile ${PYTHON_FILES})
29+
PYTHON_BUILD(${PROJECT_NAME} ${pyfile})
30+
endforeach(pyfile)
31+
32+
nanobind_add_stub(
33+
coal_pywrap_v2_stub
34+
MODULE ${MODULE_NAME}
35+
OUTPUT ${MODULE_NAME}.pyi
36+
DEPENDS ${PYTHON_LIB_NAME_V2}
37+
)

python-nb/coal/__init__.py

Whitespace-only changes.

python-nb/coal/v2/__init__.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# ruff: noqa: F401, F403
2+
from .coal_pywrap_v2 import * # noqa
3+
from .coal_pywrap_v2 import __version__

0 commit comments

Comments
 (0)