15
0
forked from pool/python-hunter

Accepting request 1290567 from devel:languages:python

- Switch to pyproject macros.
- Actually run the testsuite.
- No more greedy globs in %files.
- Add patches:
  * support-python-313.patch, allow testsuite to build with Python 3.13.
  * use-sys.executable.patch, use sys.executable in the testsuite.

OBS-URL: https://build.opensuse.org/request/show/1290567
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/python-hunter?expand=0&rev=6
This commit is contained in:
2025-07-06 15:13:51 +00:00
committed by Git OBS Bridge
4 changed files with 116 additions and 5 deletions

View File

@@ -1,3 +1,13 @@
-------------------------------------------------------------------
Fri Jul 4 02:35:43 UTC 2025 - Steve Kowalik <steven.kowalik@suse.com>
- Switch to pyproject macros.
- Actually run the testsuite.
- No more greedy globs in %files.
- Add patches:
* support-python-313.patch, allow testsuite to build with Python 3.13.
* use-sys.executable.patch, use sys.executable in the testsuite.
-------------------------------------------------------------------
Sun Jun 30 19:18:44 UTC 2024 - Dirk Müller <dmueller@suse.com>

View File

@@ -1,7 +1,7 @@
#
# spec file for package python-hunter
#
# Copyright (c) 2024 SUSE LLC
# Copyright (c) 2025 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -23,8 +23,22 @@ Summary: Pytest plugin for coverage reporting
License: BSD-2-Clause
URL: https://github.com/ionelmc/python-hunter
Source: https://files.pythonhosted.org/packages/source/h/hunter/hunter-%{version}.tar.gz
# PATCH-FIX-OPENSUSE Fix the testsuite to build with Python 3.13
Patch0: support-python-313.patch
# PATCH-FIX-UPSTREAM gh#ionelmc/python-hunter#126
Patch1: use-sys.executable.patch
BuildRequires: %pythons
BuildRequires: %{python_module Cython}
BuildRequires: %{python_module aspectlib}
BuildRequires: %{python_module pip}
BuildRequires: %{python_module process-tests}
BuildRequires: %{python_module pytest-benchmark}
BuildRequires: %{python_module pytest}
BuildRequires: %{python_module py}
BuildRequires: %{python_module setuptools_scm}
BuildRequires: %{python_module six}
BuildRequires: %{python_module tzdata}
BuildRequires: %{python_module wheel}
BuildRequires: fdupes
BuildRequires: python-rpm-macros
Requires(post): update-alternatives
@@ -37,16 +51,37 @@ but for debugging, logging, inspection and other nefarious purposes.
%prep
%autosetup -p1 -n hunter-%{version}
cat >src/build_tests.py <<EOF
from setuptools import setup
from Cython.Build import cythonize
setup(
name='Tests',
ext_modules=cythonize("../tests/*.pyx"),
)
EOF
%build
%python_build
%pyproject_wheel
export PYTHONDONTWRITEBYTECODE=1
pushd src
%python_exec build_tests.py build_ext
find . -name 'eviltracer.cpython-*-linux-gnu.so' -exec mv "{}" ../tests \;
find . -name 'sample5.cpython-*-linux-gnu.so' -exec mv "{}" ../tests \;
rm build_tests.py
popd
%install
%python_install
%python_expand %fdupes %{buildroot}%{$python_sitearch}/
%pyproject_install
%{python_expand \
rm -r %{buildroot}%{$python_sitearch}/build_tests.py %{buildroot}%{$python_sitearch}/__pycache__
%fdupes %{buildroot}%{$python_sitearch}/
}
%python_clone -a %{buildroot}%{_bindir}/hunter-trace
%check
export PYTHONPATH=tests
%pytest_arch -k 'not (test_pdb and (postmortem-ipdb or settrace-ipdb or debugger-ipdb) or test_fullsource_cython or test_source_cython or test_safe_repr or test_profile or test_errorsnooper)' --ignore tests/test_remote.py --ignore tests/test_integration.py
%post
%python_install_alternative hunter-trace
@@ -58,6 +93,8 @@ but for debugging, logging, inspection and other nefarious purposes.
%python_alternative %{_bindir}/hunter-trace
%license LICENSE
%doc AUTHORS.rst CHANGELOG.rst README.rst
%{python_sitearch}/*
%{python_sitearch}/hunter
%{python_sitearch}/hunter.pth
%{python_sitearch}/hunter-%{version}.dist-info
%changelog

12
support-python-313.patch Normal file
View File

@@ -0,0 +1,12 @@
Index: hunter-3.7.0/tests/eviltracer.pxd
===================================================================
--- hunter-3.7.0.orig/tests/eviltracer.pxd
+++ hunter-3.7.0/tests/eviltracer.pxd
@@ -5,6 +5,7 @@ cimport cython
cdef extern from "vendor/_compat.h":
"""
#if PY_VERSION_HEX >= 0x030B00A7
+ #define Py_BUILD_CORE
#include "internal/pycore_frame.h"
#endif
"""

52
use-sys.executable.patch Normal file
View File

@@ -0,0 +1,52 @@
From 5c1c453e19fce6cc1486db4e63a120d2646af97d Mon Sep 17 00:00:00 2001
From: Steve Kowalik <steven@wedontsleep.org>
Date: Fri, 4 Jul 2025 11:45:12 +1000
Subject: [PATCH] Use sys.executable everywhere in test_remote
Not all systems use python to run the interpreter, and this also doesn't
help if the user has multiple interpreters in their path. Use
sys.executable like the other test case in this file.
---
tests/test_remote.py | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/tests/test_remote.py b/tests/test_remote.py
index 6574cc8..76e2869 100644
--- a/tests/test_remote.py
+++ b/tests/test_remote.py
@@ -15,7 +15,7 @@
@pytest.mark.skipif('platform.system() == "Windows"')
def test_manhole():
- with TestProcess('python', '-msamplemanhole') as target, dump_on_error(target.read):
+ with TestProcess(sys.executable, '-msamplemanhole') as target, dump_on_error(target.read):
wait_for_strings(target.read, TIMEOUT, 'Oneshot activation is done by signal')
with TestProcess('hunter-trace', '-p', str(target.proc.pid), 'stdlib=False') as tracer, dump_on_error(tracer.read):
@@ -32,7 +32,7 @@ def test_manhole():
@pytest.mark.skipif('platform.system() == "Windows"')
def test_manhole_reattach():
- with TestProcess('python', '-msamplemanhole') as target, dump_on_error(target.read):
+ with TestProcess(sys.executable, '-msamplemanhole') as target, dump_on_error(target.read):
wait_for_strings(target.read, TIMEOUT, 'Oneshot activation is done by signal')
with TestProcess('hunter-trace', '-p', str(target.proc.pid), 'stdlib=False') as tracer, dump_on_error(tracer.read):
@@ -61,7 +61,7 @@ def test_manhole_reattach():
@pytest.mark.skipif('platform.system() == "Windows"')
def test_manhole_clean_exit():
- with TestProcess('python', '-msamplemanhole') as target, dump_on_error(target.read):
+ with TestProcess(sys.executable, '-msamplemanhole') as target, dump_on_error(target.read):
wait_for_strings(target.read, TIMEOUT, 'Oneshot activation is done by signal')
with TestProcess('hunter-trace', '-p', str(target.proc.pid), 'stdlib=False') as tracer, dump_on_error(tracer.read):
@@ -90,7 +90,7 @@ def test_manhole_clean_exit():
@pytest.mark.skipif('platform.python_implementation() == "PyPy"')
@pytest.mark.skipif('not which("gdb")')
def test_gdb():
- with TestProcess('python', '-msamplemanhole') as target, dump_on_error(target.read):
+ with TestProcess(sys.executable, '-msamplemanhole') as target, dump_on_error(target.read):
with TestProcess('hunter-trace', '-p', str(target.proc.pid), '--gdb', 'stdlib=False') as tracer, dump_on_error(tracer.read):
wait_for_strings(
tracer.read,