Skip to content

Commit

Permalink
Update CythonExtension.cmake to include the `PyInterpreterState_Get…
Browse files Browse the repository at this point in the history
…Id` patch on all Cython extensions
  • Loading branch information
althonos committed Oct 12, 2024
1 parent 200c1bb commit 97b5c74
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 20 deletions.
2 changes: 0 additions & 2 deletions src/pyhmmer/daemon.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ from pyhmmer.easel cimport Sequence, Alphabet, MSA, KeyHash
from pyhmmer.errors import UnexpectedError, AllocationError, ServerError
from pyhmmer.plan7 cimport Builder, TopHits, Pipeline, HMM, Background

include "_getid.pxi"


# --- Python imports ---------------------------------------------------------

Expand Down
1 change: 0 additions & 1 deletion src/pyhmmer/easel.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ elif TARGET_SYSTEM == "Darwin" or TARGET_SYSTEM.endswith("BSD"):
from .fileobj.bsd cimport fileobj_bsd_open as fopen_obj

include "exceptions.pxi"
include "_getid.pxi"

# --- Python imports ---------------------------------------------------------

Expand Down
2 changes: 0 additions & 2 deletions src/pyhmmer/errors.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
cimport libeasel
cimport libeasel.alphabet

include "_getid.pxi"

statuscode = {
libeasel.eslOK: "eslOK",
libeasel.eslFAIL: "eslFAIL",
Expand Down
1 change: 0 additions & 1 deletion src/pyhmmer/plan7.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,6 @@ elif TARGET_SYSTEM == "Darwin" or TARGET_SYSTEM.endswith("BSD"):
from .fileobj.bsd cimport fileobj_bsd_open as fopen_obj

include "exceptions.pxi"
include "_getid.pxi"


# --- Python imports ---------------------------------------------------------
Expand Down
15 changes: 2 additions & 13 deletions src/scripts/cmake/CythonExtension.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,9 @@ include(CheckSymbolExists)

set(SAFE_CMAKE_REQUIRED_INCLUDES "${CMAKE_REQUIRED_INCLUDES}")
set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${Python_INCLUDE_DIRS})
# set(PYINTERPRETER_STATE_SOURCE
# "
# #include <stdint.h>
# #include <stdlib.h>
# #include <Python.h>

# int main(int argc, char *argv[]) {
# PyInterpreterState_GetID(NULL);
# return 0;
# }
# ")
# check_c_source_compiles("${PYINTERPRETER_STATE_SOURCE}" HAVE_PYINTERPRETERSTATE_GETID)
check_symbol_exists(PyInterpreterState_GetID "stdint.h;stdlib.h;Python.h" HAVE_PYINTERPRETERSTATE_GETID)
set(CMAKE_REQUIRED_INCLUDES "${SAFE_CMAKE_REQUIRED_INCLUDES}")
set(PATCH_FILE "${CMAKE_CURRENT_LIST_DIR}/patch.pxi")

# --- Detect implementation ----------------------------------------------------

Expand Down Expand Up @@ -92,7 +81,7 @@ macro(cython_extension _name)
"Cythonizing ${_name}.pyx to ${_name}.c"
COMMAND
Python::Interpreter -m cython
"${CMAKE_CURRENT_SOURCE_DIR}/${_name}.pyx"
"${CMAKE_CURRENT_SOURCE_DIR}/${_name}.pyx" "${PATCH_FILE}"
--output-file ${_name}.c
--depfile
-I "${CYTHON_HEADERS_DIR}"
Expand Down
3 changes: 2 additions & 1 deletion src/pyhmmer/_getid.pxi → src/scripts/cmake/patch.pxi
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# --- Patch for PyPy 3.9 -----------------------------------------------------
# coding: utf-8
# cython: language_level=3

cdef extern from *:
"""
Expand Down

0 comments on commit 97b5c74

Please sign in to comment.