Skip to content

Commit

Permalink
Use runtime detection of sys.implementation in lib.pyx
Browse files Browse the repository at this point in the history
  • Loading branch information
althonos committed Nov 2, 2024
1 parent 3cc40e8 commit a1835db
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
28 changes: 18 additions & 10 deletions src/pyrodigal/lib.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ References:
"""

# ----------------------------------------------------------------------------
# --- Cython imports -----------------------------------------------------------

cimport cython
from cpython cimport Py_buffer
Expand Down Expand Up @@ -137,17 +137,10 @@ if NEON_BUILD_SUPPORT:
cdef int MVIEW_READ
cdef int MVIEW_WRITE

if PYPY:
MVIEW_READ = PyBUF_READ | PyBUF_WRITE
MVIEW_WRITE = PyBUF_READ | PyBUF_WRITE
else:
MVIEW_READ = PyBUF_READ
MVIEW_WRITE = PyBUF_WRITE

cdef extern from *:
Py_UCS4 PyUnicode_READ(int kind, const void* data, size_t i) noexcept nogil

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

import array
import datetime
Expand All @@ -156,10 +149,25 @@ import itertools
import textwrap
import threading
import warnings
import sys

__version__ = PROJECT_VERSION

# --- Module-level constants -------------------------------------------------
# --- PyPy handling ------------------------------------------------------------

import sys

cdef bint PYPY = sys.implementation.name == "pypy"

if PYPY:
MVIEW_READ = PyBUF_READ | PyBUF_WRITE
MVIEW_WRITE = PyBUF_READ | PyBUF_WRITE
else:
MVIEW_READ = PyBUF_READ
MVIEW_WRITE = PyBUF_WRITE


# --- Module-level constants ---------------------------------------------------

cdef size_t MIN_MASKS_ALLOC = 8
cdef size_t MIN_GENES_ALLOC = 32
Expand Down
1 change: 0 additions & 1 deletion src/scripts/cmake/CythonExtension.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ set(CYTHON_DIRECTIVES
-E SYS_VERSION_INFO_MAJOR=${Python_VERSION_MAJOR}
-E SYS_VERSION_INFO_MINOR=${Python_VERSION_MINOR}
-E TARGET_CPU=$<LOWER_CASE:${CMAKE_SYSTEM_PROCESSOR}>
-E PYPY=$<IF:$<STREQUAL:${Python_INTERPRETER_ID},PyPy>,True,False>
-E PROJECT_VERSION=${CMAKE_PROJECT_VERSION}
)

Expand Down

0 comments on commit a1835db

Please sign in to comment.