From 160412ef1764a5ea75aec7dd600c160f32fd5dfd Mon Sep 17 00:00:00 2001 From: Benjamin A. Beasley Date: Aug 16 2022 21:12:31 +0000 Subject: Port to pyproject-rpm-macros - Clean up obsolete macros and stale dependencies/BR’s --- diff --git a/python-typeguard.spec b/python-typeguard.spec index f27261b..73cb1b2 100644 --- a/python-typeguard.spec +++ b/python-typeguard.spec @@ -1,66 +1,82 @@ -%global pypi_name typeguard - -Name: python-%{pypi_name} +Name: python-typeguard Version: 2.13.3 Release: %autorelease Summary: Run-time type checker for Python + +# SPDX License: MIT -URL: https://github.com/agronholm/%{pypi_name} -Source0: https://pypi.io/packages/source/t/%{pypi_name}/%{pypi_name}-%{version}.tar.gz +URL: https://github.com/agronholm/typeguard +Source0: %{pypi_source typeguard} + BuildArch: noarch -%package -n python3-%{pypi_name} +BuildRequires: python3-devel + +%global common_description %{expand: +This library provides run-time type checking for functions defined with PEP 484 +argument (and return) type annotations.} -Summary: %{summary} -%{?python_provide:%python_provide python3-%{pypi_name}} +%description %{common_description} -BuildRequires: python3-setuptools -BuildRequires: python3-setuptools_scm -BuildRequires: python3-devel -BuildRequires: python3-pbr -BuildRequires: python3-six >= 1.9.0 -BuildRequires: python3-tornado >= 4.5 -BuildRequires: python3-pytest -BuildRequires: python3-pytest-cov -BuildRequires: python3-typing-extensions -BuildRequires: python3-mypy -%if %{undefined __pythondist_requires} -Requires: python3-six >= 1.9.0 -%endif +%package -n python3-typeguard +Summary: %{summary} -%description -n python3-%{pypi_name} -This library provides run-time type checking for functions defined with PEP -484 argument (and return) type annotations. +%description -n python3-typeguard %{common_description} -%description -This library provides run-time type checking for functions defined with PEP -484 argument (and return) type annotations. %prep -%autosetup -n %{pypi_name}-%{version} -rm -rf %{pypi_name}.egg-info -%if 0%{?rhel} < 9 -# older setuptools generates PKG-INFO with version=='0.0.0' unless specified -sed -i '/name = typeguard/a version = %{version}' setup.cfg -%endif +%autosetup -n typeguard-%{version} + +# Normally, we should skip linters and typecheckers +# (https://docs.fedoraproject.org/en-US/packaging-guidelines/Python/#_linters). +# In this case, it could make sense to allow the tests to depend on mypy for +# this package since it is itself a typechecker, and some tests seem to want to +# compare results against mypy. However, the tests are brittle in that they +# depend on the exact messages produced by a particular version of mypy, which +# makes them unsuitable for downstream testing. +sed -r -i '/\b(mypy)\b/d' setup.cfg +# In future versions, with project metadata migrated to pyproject.toml: +# sed -r -i 's/^([[:blank:]]*)(.(mypy))\b/\1# \2/' \ +# pyproject.toml + + +%generate_buildrequires +%pyproject_buildrequires -x test + %build -%py3_build +%pyproject_wheel + %install -%py3_install +%pyproject_install +%pyproject_save_files typeguard + %check -%pytest \ - --deselect tests/test_importhook.py::test_cached_module \ - --ignore tests/mypy/test_type_annotations.py +# The test_cached_module test fails to find a byte-compiled .pyc module where +# it is expecting it. Manually byte-compiling the tests (%%py_byte_compile +# %%{python3} tests) doesn’t help. This is almost certainly specific to the RPM +# build environment and not a real bug. +# +# See also: +# 2.13.3: pytest is failing in three units +# https://github.com/agronholm/typeguard/issues/248 +k="${k-}${k+ and }not test_cached_module" + +# Tests comparing against mypy output are too brittle—tightly coupled to +# particular mypy versions—so we skip them downstream. +k="${k-}${k+ and }not test_positive" +k="${k-}${k+ and }not test_negative" -%files -n python3-%{pypi_name} +%pytest -k "${k-}" + + +%files -n python3-typeguard -f %{pyproject_files} +# pyproject_files handles LICENSE; verify with “rpm -qL -p …” %doc README.rst -%license LICENSE -%{python3_sitelib}/%{pypi_name}/ -%{python3_sitelib}/%{pypi_name}-*.egg-info/ + %changelog %autochangelog