From 8c105e5cc4df5ecdd7c7346d18436eadc63185f375b3eddc478d28e0ca9c64d7 Mon Sep 17 00:00:00 2001 From: Daniel Garcia Moreno Date: Thu, 23 Oct 2025 11:42:02 +0200 Subject: [PATCH] Convert to libalternatives, bsc#1245883 --- _multibuild | 3 +++ python-coverage.changes | 11 +++++++++++ python-coverage.spec | 43 +++++++++++++++++++++++++++++++++++++---- 3 files changed, 53 insertions(+), 4 deletions(-) create mode 100644 _multibuild diff --git a/_multibuild b/_multibuild new file mode 100644 index 0000000..fcc7b97 --- /dev/null +++ b/_multibuild @@ -0,0 +1,3 @@ + + test + diff --git a/python-coverage.changes b/python-coverage.changes index f5c78da..d8346b1 100644 --- a/python-coverage.changes +++ b/python-coverage.changes @@ -1,3 +1,14 @@ +------------------------------------------------------------------- +Tue Aug 19 10:42:47 UTC 2025 - Daniel Garcia + +- Add _multibuild for running tests, it's required to call "coverage" + command when using libalternatives. + +------------------------------------------------------------------- +Thu Aug 14 12:33:02 UTC 2025 - Markéta Machová + +- Convert to libalternatives on SLE-16-based and newer systems + ------------------------------------------------------------------- Thu Mar 27 09:44:38 UTC 2025 - Markéta Machová diff --git a/python-coverage.spec b/python-coverage.spec index 1adc00c..02d736a 100644 --- a/python-coverage.spec +++ b/python-coverage.spec @@ -1,7 +1,7 @@ # # spec file for package python-coverage # -# Copyright (c) 2025 SUSE LLC +# Copyright (c) 2025 SUSE LLC and contributors # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -16,8 +16,23 @@ # +%if 0%{?suse_version} > 1500 +%bcond_without libalternatives +%else +%bcond_with libalternatives +%endif + +%global flavor @BUILD_FLAVOR@%{nil} +%if "%{flavor}" == "test" +%define psuffix -test +%bcond_without test +%else +%define psuffix %{nil} +%bcond_with test +%endif + %{?sle15_python_module_pythons} -Name: python-coverage +Name: python-coverage%{psuffix} Version: 7.7.1 Release: 0 Summary: Code coverage measurement for Python @@ -33,11 +48,19 @@ BuildRequires: %{python_module wheel} BuildRequires: fdupes BuildRequires: python-rpm-macros Requires: python -Requires(post): update-alternatives -Requires(postun): update-alternatives # coverage[toml] Recommends: python-tomli +%if %{with libalternatives} +BuildRequires: alts +Requires: alts +%else +Requires(post): update-alternatives +Requires(postun): update-alternatives +%endif + +%if %{with test} # SECTION test requirements +BuildRequires: %{python_module coverage = %{version}} BuildRequires: %{python_module flaky} BuildRequires: %{python_module hypothesis >= 6} BuildRequires: %{python_module pytest-xdist} @@ -46,6 +69,7 @@ BuildRequires: %{python_module tomli} # for database (sqlite3) support BuildRequires: %{pythons} # /SECTION +%endif %python_subpackages %description @@ -60,15 +84,20 @@ library to determine which lines are executable, and which have been executed. sed -i -e '/addopts/d' setup.cfg %build +%if %{without test} %pyproject_wheel +%endif %install +%if %{without test} %pyproject_install rm -vf %{buildroot}%{_bindir}/coverage{2,3} %python_clone -a %{buildroot}%{_bindir}/coverage %python_expand %fdupes %{buildroot}%{$python_sitearch} +%endif %check +%if %{with test} export LANG=en_US.UTF8 %python_flavored_alternatives %{python_expand # indicate a writeable .pth directory for tests @@ -106,6 +135,10 @@ donttest+=" or test_report_wildcard or test_run_omit_vs_report_omit" %pytest_arch -n auto --no-flaky-report -k "$donttest" -rp ||: %pytest_arch -n auto --no-flaky-report -k "not ($donttest)" +%endif + +%pre +%python_libalternatives_reset_alternative coverage %post %python_install_alternative coverage @@ -113,11 +146,13 @@ donttest+=" or test_report_wildcard or test_run_omit_vs_report_omit" %postun %python_uninstall_alternative coverage +%if %{without test} %files %{python_files} %license LICENSE.txt %doc CHANGES.rst CONTRIBUTORS.txt README.rst howto.txt %python_alternative %{_bindir}/coverage %{python_sitearch}/coverage/ %{python_sitearch}/coverage-%{version}.dist-info +%endif %changelog