|
| 1 | +# Copyright 1999-2024 Gentoo Authors |
| 2 | +# Distributed under the terms of the GNU General Public License v2 |
| 3 | + |
| 4 | +EAPI=8 |
| 5 | + |
| 6 | +DISTUTILS_EXT=1 |
| 7 | +DISTUTILS_USE_PEP517=setuptools |
| 8 | +PYTHON_COMPAT=( python3_{11..12} ) |
| 9 | + |
| 10 | +inherit distutils-r1 pypi |
| 11 | + |
| 12 | +DESCRIPTION="HTTP client/server for asyncio" |
| 13 | +HOMEPAGE=" |
| 14 | + https://github.com/aio-libs/aiohttp/ |
| 15 | + https://pypi.org/project/aiohttp/ |
| 16 | +" |
| 17 | + |
| 18 | +LICENSE="Apache-2.0" |
| 19 | +SLOT="0" |
| 20 | +KEYWORDS="amd64 arm arm64 x86" |
| 21 | +IUSE="test-rust speedups" |
| 22 | + |
| 23 | +RDEPEND=" |
| 24 | + >=dev-python/aiohappyeyeballs-2.3.0[${PYTHON_USEDEP}] |
| 25 | + >=dev-python/aiosignal-1.1.2[${PYTHON_USEDEP}] |
| 26 | + >=dev-python/attrs-17.3.0[${PYTHON_USEDEP}] |
| 27 | + dev-python/brotlicffi[${PYTHON_USEDEP}] |
| 28 | + >=dev-python/frozenlist-1.1.1[${PYTHON_USEDEP}] |
| 29 | + >=dev-python/multidict-4.5.0[${PYTHON_USEDEP}] |
| 30 | + >=dev-python/yarl-1.0[${PYTHON_USEDEP}] |
| 31 | + $(python_gen_cond_dep ' |
| 32 | + <dev-python/async-timeout-5[${PYTHON_USEDEP}] |
| 33 | + >=dev-python/async-timeout-4.0[${PYTHON_USEDEP}] |
| 34 | + ' 3.10) |
| 35 | + speedups? ( |
| 36 | + >=dev-python/aiodns-3.2.0[${PYTHON_USEDEP}] |
| 37 | + dev-python/brotlipy[${PYTHON_USEDEP}] |
| 38 | + dev-python/brotlicffi[${PYTHON_USEDEP}] |
| 39 | + ) |
| 40 | +" |
| 41 | +BDEPEND=" |
| 42 | + dev-python/cython[${PYTHON_USEDEP}] |
| 43 | + test? ( |
| 44 | + dev-python/freezegun[${PYTHON_USEDEP}] |
| 45 | + www-servers/gunicorn[${PYTHON_USEDEP}] |
| 46 | + dev-python/pytest-forked[${PYTHON_USEDEP}] |
| 47 | + dev-python/pytest-mock[${PYTHON_USEDEP}] |
| 48 | + dev-python/pytest-xdist[${PYTHON_USEDEP}] |
| 49 | + dev-python/re-assert[${PYTHON_USEDEP}] |
| 50 | + $(python_gen_cond_dep ' |
| 51 | + dev-python/time-machine[${PYTHON_USEDEP}] |
| 52 | + ' 'python3*') |
| 53 | + test-rust? ( |
| 54 | + dev-python/trustme[${PYTHON_USEDEP}] |
| 55 | + ) |
| 56 | + ) |
| 57 | +" |
| 58 | + |
| 59 | +DOCS=( CHANGES.rst CONTRIBUTORS.txt README.rst ) |
| 60 | + |
| 61 | +EPYTEST_XDIST=1 |
| 62 | +distutils_enable_tests pytest |
| 63 | + |
| 64 | +src_prepare() { |
| 65 | + # increase the timeout a little |
| 66 | + sed -e '/abs=/s/0.001/0.01/' -i tests/test_helpers.py || die |
| 67 | + # xfail_strict fails on py3.10 |
| 68 | + sed -i -e '/--cov/d' -e '/xfail_strict/d' setup.cfg || die |
| 69 | + sed -i -e 's:-Werror::' Makefile || die |
| 70 | + |
| 71 | + distutils-r1_src_prepare |
| 72 | +} |
| 73 | + |
| 74 | +python_configure_all() { |
| 75 | + # workaround missing files |
| 76 | + mkdir tools || die |
| 77 | + > requirements/cython.txt || die |
| 78 | + > tools/gen.py || die |
| 79 | + chmod +x tools/gen.py || die |
| 80 | + # force rehashing first |
| 81 | + emake requirements/.hash/cython.txt.hash |
| 82 | + > .update-pip || die |
| 83 | + > .install-cython || die |
| 84 | + emake cythonize |
| 85 | +} |
| 86 | + |
| 87 | +python_test() { |
| 88 | + local EPYTEST_IGNORE=( |
| 89 | + # proxy is not packaged |
| 90 | + tests/test_proxy_functional.py |
| 91 | + # python_on_whales is not packaged |
| 92 | + tests/autobahn/test_autobahn.py |
| 93 | + ) |
| 94 | + |
| 95 | + local EPYTEST_DESELECT=( |
| 96 | + # Internet |
| 97 | + tests/test_client_session.py::test_client_session_timeout_zero |
| 98 | + # broken by irrelevant deprecation warnings |
| 99 | + tests/test_circular_imports.py::test_no_warnings |
| 100 | + # TODO |
| 101 | + tests/test_client_session.py::test_request_tracing_url_params |
| 102 | + # fragile timing test |
| 103 | + tests/test_imports.py::test_import_time |
| 104 | + # crash in time-machine |
| 105 | + # https://github.com/aio-libs/aiohttp/issues/7851 |
| 106 | + # https://github.com/adamchainz/time-machine/issues/403 |
| 107 | + tests/test_cookiejar.py::TestCookieJarSafe::test_max_age |
| 108 | + ) |
| 109 | + |
| 110 | + case ${EPYTHON} in |
| 111 | + pypy3) |
| 112 | + # upstream unconditionally blocks building C extensions |
| 113 | + # on PyPy3 but the test suite needs an explicit switch, |
| 114 | + # sigh |
| 115 | + local -x AIOHTTP_NO_EXTENSIONS=1 |
| 116 | + ;; |
| 117 | + esac |
| 118 | + |
| 119 | + local -x PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 |
| 120 | + local -x PYTEST_PLUGINS=pytest_mock,xdist.plugin,pytest_forked |
| 121 | + rm -rf aiohttp || die |
| 122 | + epytest --forked |
| 123 | +} |
0 commit comments