File tree 3 files changed +15
-2
lines changed
3 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -42,6 +42,13 @@ def _env(var, default=False):
42
42
_SPDL_BUILD_STUB = _env ("SPDL_BUILD_STUB" )
43
43
44
44
45
+ def _is_gil_enabled ():
46
+ try :
47
+ return sys ._is_gil_enabled ()
48
+ except AttributeError :
49
+ return True
50
+
51
+
45
52
def _get_ext_modules ():
46
53
ext_modules = []
47
54
for v in ["4" , "5" , "6" , "7" ]:
@@ -101,6 +108,7 @@ def _b(var):
101
108
f"-DPython_EXECUTABLE={ sys .executable } " ,
102
109
"-DSPDL_BUILD_PYTHON_BINDING=ON" ,
103
110
f"-DSPDL_PYTHON_BINDING_INSTALL_PREFIX={ install_dir } " ,
111
+ f"-DSPDL_IS_GIL_ENABLED={ _b (_is_gil_enabled ())} " ,
104
112
###################################################################
105
113
# Options based on env vars
106
114
###################################################################
Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ option(SPDL_USE_NPPI "Enable NVIDIA 2D Image And Signal Performance Primitives s
9
9
option (SPDL_LINK_STATIC_NVJPEG "Link nvJPEG and NPPI statically." OFF )
10
10
11
11
option (SPDL_DEBUG_REFCOUNT "Enable debug print for reference counting of AVFrame objects." OFF )
12
+ option (SPDL_IS_GIL_ENABLED "Whether the target Python has the GIL enabled" ON )
12
13
option (SPDL_HOLD_GIL "Hold GIL in IO functions." OFF )
13
14
option (SPDL_BUILD_STUB "Build Python binding stub file" OFF )
14
15
option (SPDL_BUILD_PYTHON_BINDING "Build Python binding" ON )
@@ -64,6 +65,7 @@ endif ()
64
65
add_subdirectory (libspdl)
65
66
66
67
if (SPDL_BUILD_PYTHON_BINDING)
68
+ find_package (Python COMPONENTS Interpreter Development.Module REQUIRED)
67
69
add_subdirectory (third_party/nanobind)
68
70
add_subdirectory (spdl/io/lib)
69
71
endif ()
Original file line number Diff line number Diff line change @@ -31,6 +31,10 @@ set(src
31
31
io/encoding .cpp
32
32
)
33
33
34
+ if (NOT SPDL_IS_GIL_ENABLED)
35
+ set (ft FREE_THREADED)
36
+ endif ()
37
+
34
38
function (add_spdl_extension ffmpeg_version)
35
39
set (name "_spdl_ffmpeg${ffmpeg_version} " )
36
40
message (STATUS "Building ${name} " )
@@ -46,11 +50,10 @@ function(add_spdl_extension ffmpeg_version)
46
50
list (APPEND defs SPDL_HOLD_GIL)
47
51
endif ()
48
52
49
- nanobind_add_module(${name} ${src} )
53
+ nanobind_add_module(${name} ${ft} ${ src} )
50
54
target_compile_definitions (${name} PRIVATE "${defs} " )
51
55
target_link_libraries (${name} PRIVATE "spdl_ffmpeg${ffmpeg_version} " )
52
56
target_include_directories (${name} PRIVATE "${Python_INCLUDE_DIR} " )
53
- target_include_directories (nanobind-static PRIVATE "${Python_INCLUDE_DIR} " )
54
57
55
58
install (
56
59
TARGETS ${name}
You can’t perform that action at this time.
0 commit comments