Skip to content

Commit

Permalink
Implement detection of PyInterpreterState_GetID in meson.build
Browse files Browse the repository at this point in the history
  • Loading branch information
althonos committed Jul 7, 2024
1 parent 9545408 commit 0af7da9
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
20 changes: 20 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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 <stdint.h>
#include <stdlib.h>
#include <Python.h>
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')

7 changes: 7 additions & 0 deletions pyrodigal/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ else
]
endif

if has_getid
c_args = ['-DHAS_PYINTERPRETERSTATE_GETID']
else
c_args = []
endif

python.extension_module('lib',
['lib.pyx'],
include_directories: prodigal_inc,
Expand All @@ -57,6 +63,7 @@ python.extension_module('lib',
install: true,
subdir : 'pyrodigal',
cython_args : cython_args,
c_args : c_args,
)


0 comments on commit 0af7da9

Please sign in to comment.