Skip to content

Commit

Permalink
Try to enable coverage.py on Py3.13 by disabling the sys.monitoring s…
Browse files Browse the repository at this point in the history
…upport for these tests.

coverage.py does not (yet?) support sys.monitoring with the Cython plugin yet.
See nedbat/coveragepy#1790
  • Loading branch information
scoder committed Aug 13, 2024
1 parent 773476c commit 9f06400
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 19 deletions.
7 changes: 5 additions & 2 deletions Tools/ci-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ if [[ $PYTHON_VERSION == "3.1"[2-9]* ]]; then
python -m pip install -U pip wheel setuptools || exit 1
if [[ $PYTHON_VERSION == "3.12"* ]]; then
python -m pip install --pre -r test-requirements-312.txt || exit 1
else
# Install packages one by one, allowing failures due to missing recent wheels.
cat test-requirements-312.txt | while read package; do python -m pip install --pre --only-binary ":all:" "$package" || true; done
fi
else
python -m pip install -U pip "setuptools<60" wheel || exit 1
Expand Down Expand Up @@ -174,12 +177,12 @@ if [[ $NO_CYTHON_COMPILE != "1" && $PYTHON_VERSION != "pypy"* ]]; then
SETUP_ARGS="$SETUP_ARGS --cython-compile-all"
fi
if [[ $LIMITED_API != "" && $NO_LIMITED_COMPILE != "1" ]]; then
# in the limited API tests, also build Cython in this mode (for more thorough
# in the limited API tests, also build Cython in this mode (for more thorough
# testing rather than performance since it's currently a pessimization)
SETUP_ARGS="$SETUP_ARGS --cython-limited-api"
fi
# It looks like parallel build may be causing occasional link failures on Windows
# "with exit code 1158". DW isn't completely sure of this, but has disabled it in
# "with exit code 1158". DW isn't completely sure of this, but has disabled it in
# the hope it helps
SETUP_ARGS="$SETUP_ARGS
$(python -c 'import sys; print("-j5" if not sys.platform.startswith("win") else "")')"
Expand Down
3 changes: 0 additions & 3 deletions runtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,9 +470,6 @@ def get_openmp_compiler_flags(language):

TAG_EXCLUDERS = sorted({
'no-macos': exclude_test_on_platform('darwin'),
# coverage.py does not support sys.monitoring with the Cython plugin yet.
# See https://github.com/nedbat/coveragepy/issues/1790
'coverage': exclude_test_in_pyver((3,13)),
'pstats': exclude_test_in_pyver((3,12)),
}.items())

Expand Down
12 changes: 6 additions & 6 deletions tests/run/coverage_api.srctree
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ plugins = Cython.Coverage

######## pkg/coverage_test_py.py ########
# cython: linetrace=True
# distutils: define_macros=CYTHON_TRACE=1
# distutils: define_macros=CYTHON_TRACE=1 CYTHON_USE_SYS_MONITORING=0

def func1(a, b):
x = 1 # 5
Expand All @@ -42,7 +42,7 @@ def func2(a):

######## pkg/coverage_test_pyx.pyx ########
# cython: linetrace=True
# distutils: define_macros=CYTHON_TRACE=1
# distutils: define_macros=CYTHON_TRACE=1 CYTHON_USE_SYS_MONITORING=0

def func1(int a, int b):
cdef int x = 1 # 5
Expand All @@ -56,7 +56,7 @@ def func2(int a):

######## coverage_test_include_pyx.pyx ########
# cython: linetrace=True
# distutils: define_macros=CYTHON_TRACE=1
# distutils: define_macros=CYTHON_TRACE=1 CYTHON_USE_SYS_MONITORING=0

cdef int x = 5 # 4

Expand All @@ -74,7 +74,7 @@ def main_func(int x): # 11

######## Package2/CoverageTest_py.py ########
# cython: linetrace=True
# distutils: define_macros=CYTHON_TRACE=1
# distutils: define_macros=CYTHON_TRACE=1 CYTHON_USE_SYS_MONITORING=0

def func1(a, b):
x = 1 # 5
Expand All @@ -88,7 +88,7 @@ def func2(a):

######## Package2/CoverageTest_pyx.pyx ########
# cython: linetrace=True
# distutils: define_macros=CYTHON_TRACE=1
# distutils: define_macros=CYTHON_TRACE=1 CYTHON_USE_SYS_MONITORING=0

def func1(int a, int b):
cdef int x = 1 # 5
Expand All @@ -102,7 +102,7 @@ def func2(int a):

######## coverage_test_include_pyx.pyx ########
# cython: linetrace=True
# distutils: define_macros=CYTHON_TRACE=1
# distutils: define_macros=CYTHON_TRACE=1 CYTHON_USE_SYS_MONITORING=0

cdef int x = 5 # 4

Expand Down
6 changes: 3 additions & 3 deletions tests/run/coverage_cmd.srctree
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ plugins = Cython.Coverage

######## pkg/coverage_test_py.py ########
# cython: linetrace=True
# distutils: define_macros=CYTHON_TRACE=1
# distutils: define_macros=CYTHON_TRACE=1 CYTHON_USE_SYS_MONITORING=0
import cython


Expand Down Expand Up @@ -57,7 +57,7 @@ class A:

######## pkg/coverage_test_pyx.pyx ########
# cython: linetrace=True
# distutils: define_macros=CYTHON_TRACE=1
# distutils: define_macros=CYTHON_TRACE=1 CYTHON_USE_SYS_MONITORING=0



Expand Down Expand Up @@ -86,7 +86,7 @@ cdef class A:

######## coverage_test_include_pyx.pyx ########
# cython: linetrace=True
# distutils: define_macros=CYTHON_TRACE=1
# distutils: define_macros=CYTHON_TRACE=1 CYTHON_USE_SYS_MONITORING=0

cdef int x = 5 # 4

Expand Down
2 changes: 1 addition & 1 deletion tests/run/coverage_cmd_src_layout.srctree
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ plugins = Cython.Coverage

######## src/trivial_module.pyx ########
# cython: linetrace=True
# distutils: define_macros=CYTHON_TRACE=1
# distutils: define_macros=CYTHON_TRACE=1 CYTHON_USE_SYS_MONITORING=0

def func1(int a, int b):
cdef int x = 1 # 5
Expand Down
2 changes: 1 addition & 1 deletion tests/run/coverage_cmd_src_pkg_layout.srctree
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ plugins = Cython.Coverage

######## src/pkg/module1.pyx ########
# cython: linetrace=True
# distutils: define_macros=CYTHON_TRACE=1
# distutils: define_macros=CYTHON_TRACE=1 CYTHON_USE_SYS_MONITORING=0

def func1(int a, int b):
cdef int x = 1 # 5
Expand Down
2 changes: 1 addition & 1 deletion tests/run/coverage_installed_pkg.srctree
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ from .test_ext_import import test_add

######## pkg/test_ext_import.pyx ########
# cython: linetrace=True
# distutils: define_macros=CYTHON_TRACE=1
# distutils: define_macros=CYTHON_TRACE=1 CYTHON_USE_SYS_MONITORING=0

import ext_pkg

Expand Down
4 changes: 2 additions & 2 deletions tests/run/coverage_nogil.srctree
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ plugins = Cython.Coverage

######## coverage_test_nogil_fastgil.pyx ########
# cython: linetrace=True,fast_gil=True
# distutils: define_macros=CYTHON_TRACE=1 CYTHON_TRACE_NOGIL=1
# distutils: define_macros=CYTHON_TRACE=1 CYTHON_TRACE_NOGIL=1 CYTHON_USE_SYS_MONITORING=0
include "_coverage_test_nogil.pxi"


######## coverage_test_nogil_nofastgil.pyx ########
# cython: linetrace=True,fast_gil=False
# distutils: define_macros=CYTHON_TRACE=1 CYTHON_TRACE_NOGIL=1
# distutils: define_macros=CYTHON_TRACE=1 CYTHON_TRACE_NOGIL=1 CYTHON_USE_SYS_MONITORING=0
include "_coverage_test_nogil.pxi"


Expand Down

0 comments on commit 9f06400

Please sign in to comment.