diff --git a/python-aiohttp.spec b/python-aiohttp.spec index 0676b93..cd16819 100644 --- a/python-aiohttp.spec +++ b/python-aiohttp.spec @@ -1,15 +1,15 @@ -%global srcname aiohttp - %bcond_without tests -Name: python-%{srcname} +Name: python-aiohttp Version: 3.8.3 -Release: 1%{?dist} +Release: 2%{?dist} Summary: Python HTTP client/server for asyncio License: ASL 2.0 URL: https://github.com/aio-libs/aiohttp -Source0: %{pypi_source} +# We use requirements/*.txt to generate test dependencies; these files are not +# present in the PyPI sdist, so we must use the GitHub archive. +Source0: %{url}/archive/v%{version}/aiohttp-%{version}.tar.gz # downstream only patch Patch: 0001-Unbundle-llhttp.patch @@ -18,89 +18,113 @@ BuildRequires: gcc BuildRequires: llhttp-devel -# EPEL8 is utilizing the CentOS Devel repo for some packages. However, this is -# not available for s390x, so exclude it. -# https://fedoraproject.org/wiki/EPEL/FAQ#RHEL_8.2B_has_binaries_in_the_release.2C_but_is_missing_some_corresponding_-devel_package._How_do_I_build_a_package_that_needs_that_missing_-devel_package.3F -%if %{defined el8} -ExcludeArch: s390x -%endif +BuildRequires: python3-devel +BuildRequires: python3dist(cython) -%description +%global common_description %{expand: Python HTTP client/server for asyncio which supports both the client and the server side of the HTTP protocol, client and server websocket, and webservers -with middlewares and pluggable routing. +with middlewares and pluggable routing.} -%package -n python3-%{srcname} +%description %{common_description} + +%package -n python3-aiohttp Summary: %{summary} -BuildRequires: python3-devel -BuildRequires: python3-setuptools -BuildRequires: python3-Cython +Recommends: python3-aiohttp+speedups -%if %{with tests} -# Test machinery -BuildRequires: python3dist(pytest) -BuildRequires: python3dist(pytest-mock) -# Test dependencies (some of which are runtime dependencies) -BuildRequires: python3dist(aiosignal) -BuildRequires: python3dist(async-generator) -BuildRequires: python3dist(async-timeout) -BuildRequires: python3dist(attrs) -BuildRequires: python3dist(brotli) -BuildRequires: python3dist(charset-normalizer) -BuildRequires: python3dist(freezegun) -BuildRequires: python3dist(frozenlist) -BuildRequires: python3dist(gunicorn) -BuildRequires: python3dist(multidict) -# Not currently packaged: -# BuildRequires: python3dist(proxy-py) -BuildRequires: python3dist(re-assert) -BuildRequires: python3dist(trustme) -BuildRequires: python3dist(yarl) -%endif +%description -n python3-aiohttp %{common_description} -Recommends: python%{python3_version}dist(aiodns) -%{?python_provide:%python_provide python3-%{srcname}} - -%description -n python3-%{srcname} -Python HTTP client/server for asyncio which supports both the client and the -server side of the HTTP protocol, client and server websocket, and webservers -with middlewares and pluggable routing. +%pyproject_extras_subpkg -n python3-aiohttp speedups %prep -%autosetup -p 1 -n %{srcname}-%{version} +%autosetup -p 1 -n aiohttp-%{version} # Remove bundled llhttp rm -rvf vendor/llhttp # Disable test coverage reports +# https://docs.fedoraproject.org/en-US/packaging-guidelines/Python/#_linters sed -r -i '/--cov=/d' setup.cfg +# We don’t use %%tox because it just runs pytest with coverage analysis; rather +# than patching out the coverage invocation, we can run pytest directly. Still, +# it is useful to generate test dependencies from tox.ini. +# Upstream supports both brotlipy and Brotli, in theory; we have the latter. +sed -r -i \ + -e 's/^[[:blank:]]*coverage$/# &/' \ + -e 's/^[[:blank:]]*-e[[:blank:]]+\.$/# &/' \ + -e 's/brotlipy/Brotli/' \ + tox.ini +# Unpin dependency versions in requirements files, so we can use them to +# generate additional dependencies. Comment out a few optional test +# dependencies that are not yet packaged, as well as coverage dependencies. +sed -r -i \ + -e 's/==[^#;]+//' \ + -e 's/^(proxy[-\.]py|python-on-whales|wait-for-it)/# &/' \ + -e 's/^(coverage|pytest-cov|mypy)/# &/' \ + requirements/*.txt # Remove files generated by Cython to regenerate them -rm $(grep -rl '/\* Generated by Cython') +grep -rl '/\* Generated by Cython' | xargs -r rm -v + +%generate_buildrequires +%{pyproject_buildrequires -x speedups \ + requirements/base.txt %{?with_tests:requirements/test.txt -t}} %build -# Recreate removed Cython files using a command extracted from the Makefile. +# Recreate removed Cython files using commands extracted from the Makefile. # We don't run make directly, as it pip-installs Cython. -cython -3 aiohttp/*.pyx -I aiohttp -%py3_build +# +# We don't need a real git checkout, but we do need a .git directory to help +# certain scripts find the root of the source tree. +mkdir -p .git +# See the aiohttp/_find_header.c target in the Makefile; this also generates +# _headers.pyi. +%{python3} tools/gen.py +# Now we can invoke Cython. +%{python3} -m cython -3 aiohttp/*.pyx -I aiohttp +# Now we need to remove the .git directory again, because its presence will +# lead the actual build astray, something like: +# Install submodules when building from git clone +# Hint: +# git submodule update --init +rm -rvf .git +# Now we can actually proceed with building the package. +%pyproject_wheel %install -%py3_install +%pyproject_install +%pyproject_save_files aiohttp -%if %{with tests} %check +%if %{with tests} +# Fixes problems importing compiled extensions from subprocesses. export PYTHONSAFEPATH=1 +# Setting PYTHONSAFEPATH works only for Python 3.11+, so we must skip any +# affected tests on older Pythons. +if %{python3} -c 'import sys; sys.exit(0 if sys.version_info < (3, 11) else 1)' +then + k="${k-}${k+ and }not test_no_warnings" +fi # test_proxy_functional.py requires python3dist(proxy-py) # test_client_session_timeout_zero requires DNS -%pytest --ignore=tests/test_proxy_functional.py \ - -k 'not test_client_session_timeout_zero' +k="${k-}${k+ and }not test_client_session_timeout_zero" +# Unexplained flaky error during teardown: +# E RuntimeError: Event loop is closed +k="${k-}${k+ and }not test_static_file_if_match" +k="${k-}${k+ and }not test_static_file_if_none_match" +%pytest --ignore=tests/test_proxy_functional.py -k "${k-}" +%else +%pyproject_check_import -e aiohttp.pytest_plugin %endif -%files -n python3-%{srcname} -%doc CHANGES.rst CONTRIBUTORS.txt README.rst -%license LICENSE.txt -%{python3_sitearch}/%{srcname}-*.egg-info/ -%{python3_sitearch}/%{srcname}/ +%files -n python3-aiohttp -f %{pyproject_files} +%doc CHANGES.rst +%doc HISTORY.rst +%doc README.rst %changelog +* Sat Oct 08 2022 Benjamin A. Beasley - 3.8.3-2 +- Port to pyproject-rpm-macros +- Add metapackage for “speedups” extra + * Mon Sep 26 2022 Tomáš Hrnčiar - 3.8.3-1 - Update to 3.8.3 diff --git a/sources b/sources index 8688d46..cc3b961 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (aiohttp-3.8.3.tar.gz) = 248c232604c91442b2fc9fa55fbf7df8e3af56dcf4cd9c516414a3a738c5c60a8a06395cd9c6e2c8ea9884728aea757423735c7b9be889e6f17e3ee6395a2f64 +SHA512 (aiohttp-3.8.3.tar.gz) = b819d8b3c4559e1589d6d05dbab6c27195667994d9371e40ea59146eb0ba57280ba2d872515a133b64b7918148b7200eb55a807eac022954b4e1b4228b7496a5