From 31053f81bd715c6a828ccd9665a62b6b3278f822 Mon Sep 17 00:00:00 2001 From: Martin Larralde Date: Sun, 7 Jul 2024 22:56:40 +0200 Subject: [PATCH] Implement detection of `PyInterpreterState_GetID` in `meson.build` --- meson.build | 20 ++++++++++++++++++++ pyrodigal/meson.build | 7 +++++++ 2 files changed, 27 insertions(+) diff --git a/meson.build b/meson.build index 87d1318..3920a3f 100644 --- a/meson.build +++ b/meson.build @@ -149,5 +149,25 @@ py_mod = import('python') python = py_mod.find_installation(pure: false) py_dep = python.dependency() +# check if `PyInterpreterState_GetID` is available +getid_code = ( + ''' + #include + #include + #include + + int main(int argc, char *argv[]) { + PyInterpreterState_GetID(NULL); + return 0; + } + ''' +) +has_getid = cc.compiles( + getid_code, + dependencies : py_dep, + name : 'PyInterpreterState_GetID', + args : ['-Werror=implicit-function-declaration'], +) + subdir('pyrodigal') diff --git a/pyrodigal/meson.build b/pyrodigal/meson.build index 84e98bb..5ba8739 100644 --- a/pyrodigal/meson.build +++ b/pyrodigal/meson.build @@ -49,6 +49,12 @@ else ] endif +if not has_getid + c_args = ['-DHAS_PYINTERPRETERSTATE_GETID'] +else + c_args = [] +endif + python.extension_module('lib', ['lib.pyx'], include_directories: prodigal_inc, @@ -57,6 +63,7 @@ python.extension_module('lib', install: true, subdir : 'pyrodigal', cython_args : cython_args, + c_args : c_args, )