@@ -25,8 +25,9 @@ if sleef_dep.found() and sleef_dep.type_name() != 'internal'
2525 # SLEEF found system-wide - verify quad-precision support
2626 cpp = meson .get_compiler(' cpp' )
2727 sleefquad_lib = cpp.find_library (' sleefquad' , required : false )
28+ tlfloat_lib = cpp.find_library (' tlfloat' , required : false )
2829
29- if sleefquad_lib.found()
30+ if sleefquad_lib.found() and tlfloat_lib.found()
3031 sleefquad_test_code = '''
3132 #include <sleefquad.h>
3233
@@ -40,40 +41,48 @@ if sleef_dep.found() and sleef_dep.type_name() != 'internal'
4041 # this should compile and link
4142 quad_works = cpp.links(
4243 sleefquad_test_code,
43- dependencies : [sleef_dep, sleefquad_lib],
44+ dependencies : [sleef_dep, sleefquad_lib, tlfloat_lib ],
4445 name : ' SLEEF quad-precision support'
4546 )
4647
4748 if quad_works
4849 sleefquad_dep = declare_dependency (
4950 dependencies : [sleef_dep, sleefquad_lib]
5051 )
52+ tlfloat_dep = declare_dependency (
53+ dependencies : [tlfloat_lib]
54+ )
5155 use_system_sleef = true
5256 else
53- fallback_reason = ' quad-precision support is not working '
57+ fallback_reason = ' System-wide SLEEF installation found but a test for quad precision support failed. '
5458 endif
5559 else
56- fallback_reason = ' sleefquad library is missing '
60+ fallback_reason = ' System-wide SLEEF installation does not have a sleefquad library. '
5761 endif
5862else
59- fallback_reason = ' SLEEF not found system-wide'
63+ fallback_reason = ' Cannot find system-wide SLEEF installation. '
6064endif
6165
6266if use_system_sleef
6367 message (' Using system-wide SLEEF installation with quad-precision support' )
6468else
65- warning (' Falling back to SLEEF subproject: ' + fallback_reason)
6669 sleef_subproj = subproject (' sleef' )
6770 sleef_dep = sleef_subproj.get_variable (' sleef_dep' )
6871 sleefquad_dep = sleef_subproj.get_variable (' sleefquad_dep' )
69- message (' Using SLEEF subproject' )
72+ tlfloat_dep = sleef_subproj.get_variable (' tlfloat_dep' )
73+ warning (fallback_reason)
74+ message (' Proceeding with vendored SLEEF subproject instead' )
7075endif
7176
7277incdir_numpy = run_command (py,
7378 [' -c' , ' import numpy; print(numpy.get_include())' ],
7479 check : true
7580).stdout().strip()
7681
82+ # pythoncapi-compat for portable C API usage across Python versions
83+ pythoncapi_compat_subproj = subproject (' pythoncapi-compat' )
84+ pythoncapi_compat_inc = pythoncapi_compat_subproj.get_variable (' incdir' )
85+
7786# print numpy version used
7887numpy_version = run_command (py,
7988 [' -c' , ' import numpy; print(numpy.__version__)' ],
@@ -84,7 +93,7 @@ message('Using NumPy version: @0@'.format(numpy_version))
8493npymath_path = incdir_numpy / ' ..' / ' lib'
8594npymath_lib = c.find_library (' npymath' , dirs : npymath_path)
8695
87- dependencies = [py_dep, qblas_dep, sleef_dep, sleefquad_dep, npymath_lib]
96+ dependencies = [py_dep, qblas_dep, sleef_dep, sleefquad_dep, tlfloat_dep, npymath_lib]
8897
8998# Add OpenMP dependency (optional, for threading)
9099openmp_dep = dependency (' openmp' , required : false , static : false )
@@ -99,6 +108,11 @@ if not is_windows
99108 if cpp.has_argument(' -fext-numeric-literals' )
100109 add_project_arguments (' -fext-numeric-literals' , language : ' cpp' )
101110 endif
111+
112+ # Suppress warnings from system headers (sleefquad.h has many unused inline functions)
113+ if cpp.has_argument(' -Wno-unused-function' )
114+ add_project_arguments (' -Wno-unused-function' , language : [' c' , ' cpp' ])
115+ endif
102116endif
103117
104118# Thread-local storage detection (borrowed from NumPy)
@@ -144,6 +158,7 @@ includes = include_directories(
144158 ' numpy_quaddtype/src' ,
145159 ]
146160)
161+ pythoncapi_includes = pythoncapi_compat_inc
147162
148163srcs = [
149164 ' numpy_quaddtype/src/quad_common.h' ,
@@ -198,5 +213,5 @@ py.extension_module('_quaddtype_main',
198213 dependencies : dependencies,
199214 install : true ,
200215 subdir : ' numpy_quaddtype' ,
201- include_directories : [includes, build_includes],
216+ include_directories : [includes, build_includes, pythoncapi_includes ],
202217)
0 commit comments