Skip to content

Commit 0889453

Browse files
committed
SWIG: Use raw docstrings
1 parent 962fdfd commit 0889453

File tree

8 files changed

+12
-186
lines changed

8 files changed

+12
-186
lines changed

CMakeLists.txt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required (VERSION 3.13)
1+
cmake_minimum_required (VERSION 3.18)
22

33
option (BUILD_PYTHON "Build the python module for the library" ON)
44
option (USE_SPHINX "Use sphinx for documentation" OFF)
@@ -31,6 +31,7 @@ find_package (OpenTURNS CONFIG REQUIRED)
3131
message (STATUS "Found OpenTURNS: ${OPENTURNS_ROOT_DIR} (found version \"${OPENTURNS_VERSION_STRING}\")")
3232

3333
find_package (vinecopulib 0.7.1 CONFIG REQUIRED)
34+
message (STATUS "Found vinecopulib: ${vinecopulib_DIR} (found version \"${vinecopulib_VERSION}\")")
3435

3536
if (NOT BUILD_SHARED_LIBS)
3637
list ( APPEND OTVINE_DEFINITIONS "-DOTVINE_STATIC" )
@@ -52,21 +53,20 @@ set (OTVINE_CONFIG_CMAKE_PATH ${CMAKE_INSTALL_LIBDIR}/cmake/otvine)
5253
set (OTVINE_DOC_PATH ${CMAKE_INSTALL_DOCDIR})
5354

5455
if (BUILD_PYTHON)
55-
find_package (SWIG 3)
56+
find_package (SWIG 4)
5657
include (${SWIG_USE_FILE})
5758

58-
if (CMAKE_VERSION VERSION_LESS 3.28)
59-
find_package (Python 3.6 COMPONENTS Interpreter Development)
59+
option (USE_PYTHON_SABI "Use Python stable ABI" OFF)
60+
if (USE_PYTHON_SABI AND CMAKE_VERSION VERSION_GREATER_EQUAL 3.26)
61+
find_package (Python 3.6 COMPONENTS Interpreter Development.SABIModule)
62+
add_library (Python::Module ALIAS Python::SABIModule)
6063
else ()
61-
find_package (Python 3.6 COMPONENTS Interpreter Development.Module Development.SABIModule)
64+
find_package (Python 3.6 COMPONENTS Interpreter Development.Module)
6265
endif ()
6366

6467
if (Python_FOUND)
6568
include (FindPythonModule)
6669
find_python_module (matplotlib)
67-
if (NOT TARGET Python::Module)
68-
include (TargetLinkLibrariesWithDynamicLookup)
69-
endif ()
7070

7171
if (USE_SPHINX)
7272
find_program (SPHINX_EXECUTABLE NAMES sphinx-build DOC "Sphinx Documentation Builder (sphinx-doc.org)")

cmake/TargetLinkLibrariesWithDynamicLookup.cmake

Lines changed: 0 additions & 100 deletions
This file was deleted.

cmake/escape_backslash.cmake

Lines changed: 0 additions & 13 deletions
This file was deleted.

lib/test/CMakeLists.txt

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
11

2-
if (MINGW AND CMAKE_SIZEOF_VOID_P EQUAL 4)
3-
add_library (CRT_fp8 STATIC CRT_fp8.c)
4-
endif ()
5-
62
set (CHECK_ENVIRONMENT)
73

84
set (CHECK_TO_BE_RUN)
@@ -12,9 +8,6 @@ macro (ot_check_test TESTNAME)
128
add_dependencies(tests ${TEST_TARGET})
139
target_include_directories (${TEST_TARGET} PRIVATE ${INTERNAL_INCLUDE_DIRS})
1410
target_link_libraries (${TEST_TARGET} PRIVATE otvine)
15-
if (MINGW AND CMAKE_SIZEOF_VOID_P EQUAL 4)
16-
target_link_libraries (${TEST_TARGET} PRIVATE CRT_fp8)
17-
endif ()
1811
set_target_properties (${TEST_TARGET} PROPERTIES
1912
UNITY_BUILD OFF
2013
INSTALL_RPATH "${PROJECT_BINARY_DIR}/lib/src;${CMAKE_INSTALL_RPATH}")

lib/test/CRT_fp8.c

Lines changed: 0 additions & 23 deletions
This file was deleted.

python/src/CMakeLists.txt

Lines changed: 4 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -15,56 +15,25 @@ macro (ot_add_python_module MODULENAME SOURCEFILE)
1515
endif ()
1616

1717
set (swig_other_sources)
18-
set (docstring_sources)
1918
foreach (it ${ARGN})
2019
if (${it} MATCHES ".*\\.i$")
2120
ot_install_swig_file (${it})
22-
elseif (${it} MATCHES ".*_doc\\.i\\.in$")
23-
list (APPEND docstring_sources ${it})
24-
25-
get_filename_component (DOCSTRING_FILE_BASENAME ${it} NAME_WE)
26-
ot_install_swig_file (${CMAKE_CURRENT_BINARY_DIR}/${DOCSTRING_FILE_BASENAME}.i)
2721
else ()
2822
list (APPEND swig_other_sources "${it}")
2923
endif ()
3024
endforeach ()
3125

32-
# https://github.com/swig/swig/issues/1273
33-
option (SWIG_FORCE_DOUBLE_ESCAPE_BACKSLASH "Force double escaping of backslashes" OFF)
34-
mark_as_advanced (SWIG_FORCE_DOUBLE_ESCAPE_BACKSLASH)
35-
set (TIMES x1)
36-
if ((SWIG_VERSION VERSION_LESS 4) OR SWIG_FORCE_DOUBLE_ESCAPE_BACKSLASH)
37-
set (TIMES x2)
38-
endif ()
39-
40-
# handle docstring generation
41-
add_custom_target (generate_${MODULENAME}_docstrings
42-
COMMAND ${CMAKE_COMMAND} -DDOCSTRING_SOURCES="${docstring_sources}"
43-
-DCURRENT_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR} -DTIMES=${TIMES}
44-
-P ${CMAKE_SOURCE_DIR}/cmake/escape_backslash.cmake
45-
DEPENDS ${docstring_sources})
46-
list (APPEND SWIG_MODULE_${MODULENAME}_python_EXTRA_DEPS generate_${MODULENAME}_docstrings)
47-
4826
set (module_target ${MODULENAME}_python)
4927

5028
swig_add_library (${module_target} LANGUAGE python SOURCES ${SOURCEFILE} ${swig_other_sources})
5129

52-
# UseSWIG generates now standard target names
53-
5430
target_include_directories(${module_target} PRIVATE ${INTERNAL_INCLUDE_DIRS})
55-
swig_link_libraries (${module_target} otvine)
5631

57-
if (TARGET Python::Module)
58-
target_link_libraries (${module_target} Python::Module)
59-
else ()
60-
target_include_directories (${module_target} PRIVATE ${Python_INCLUDE_DIRS})
61-
target_link_libraries_with_dynamic_lookup (${module_target} ${Python_LIBRARIES})
62-
endif ()
32+
target_link_libraries (${module_target} otvine)
33+
target_link_libraries (${module_target} Python::Module)
6334

6435
set_target_properties (${module_target} PROPERTIES OUTPUT_NAME ${MODULENAME})
65-
6636
set_target_properties (${module_target} PROPERTIES COMPILE_FLAGS "${SWIG_COMPILE_FLAGS}")
67-
6837
set_target_properties (${module_target} PROPERTIES UNITY_BUILD OFF)
6938

7039
install (FILES ${CMAKE_CURRENT_BINARY_DIR}/${MODULENAME}.py
@@ -78,8 +47,8 @@ endmacro ()
7847

7948

8049
ot_add_python_module( ${PACKAGE_NAME} ${PACKAGE_NAME}_module.i
81-
VineCopula.i VineCopula_doc.i.in
82-
VineCopulaFactory.i VineCopulaFactory_doc.i.in
50+
VineCopula.i VineCopula_doc.i
51+
VineCopulaFactory.i VineCopulaFactory_doc.i
8352
)
8453

8554

0 commit comments

Comments
 (0)