|
| 1 | +# Copyright 2022-2023 Gentoo Authors |
| 2 | +# Distributed under the terms of the GNU General Public License v2 |
| 3 | + |
| 4 | +EAPI=8 |
| 5 | + |
| 6 | +DISTUTILS_USE_PEP517=hatchling |
| 7 | +PYTHON_COMPAT=( pypy3 python3_{10..12} ) |
| 8 | + |
| 9 | +inherit distutils-r1 optfeature |
| 10 | + |
| 11 | +DESCRIPTION="Fully-featured HTTP client which provides sync and async APIs" |
| 12 | +HOMEPAGE=" |
| 13 | + https://www.python-httpx.org/ |
| 14 | + https://github.com/encode/httpx/ |
| 15 | + https://pypi.org/project/httpx/ |
| 16 | +" |
| 17 | +SRC_URI=" |
| 18 | + https://github.com/encode/httpx/archive/${PV}.tar.gz |
| 19 | + -> ${P}.gh.tar.gz |
| 20 | +" |
| 21 | + |
| 22 | +LICENSE="BSD" |
| 23 | +SLOT="0" |
| 24 | +KEYWORDS="~alpha amd64 arm arm64 hppa ~ia64 ~loong ~mips ppc ppc64 ~riscv ~s390 sparc x86" |
| 25 | +IUSE="cli" |
| 26 | + |
| 27 | +RDEPEND=" |
| 28 | + dev-python/certifi[${PYTHON_USEDEP}] |
| 29 | + <dev-python/httpcore-0.19[${PYTHON_USEDEP}] |
| 30 | + >=dev-python/httpcore-0.18[${PYTHON_USEDEP}] |
| 31 | + dev-python/idna[${PYTHON_USEDEP}] |
| 32 | + dev-python/sniffio[${PYTHON_USEDEP}] |
| 33 | + cli? ( |
| 34 | + =dev-python/click-8*[${PYTHON_USEDEP}] |
| 35 | + =dev-python/pygments-2*[${PYTHON_USEDEP}] |
| 36 | + dev-python/rich[${PYTHON_USEDEP}] |
| 37 | + ) |
| 38 | +" |
| 39 | +BDEPEND=" |
| 40 | + dev-python/hatch-fancy-pypi-readme[${PYTHON_USEDEP}] |
| 41 | + test? ( |
| 42 | + dev-python/anyio[${PYTHON_USEDEP}] |
| 43 | + dev-python/brotlicffi[${PYTHON_USEDEP}] |
| 44 | + dev-python/chardet[${PYTHON_USEDEP}] |
| 45 | + dev-python/cryptography[${PYTHON_USEDEP}] |
| 46 | + dev-python/h2[${PYTHON_USEDEP}] |
| 47 | + dev-python/socksio[${PYTHON_USEDEP}] |
| 48 | + dev-python/trio[${PYTHON_USEDEP}] |
| 49 | + dev-python/trustme[${PYTHON_USEDEP}] |
| 50 | + dev-python/typing-extensions[${PYTHON_USEDEP}] |
| 51 | + dev-python/uvicorn[${PYTHON_USEDEP}] |
| 52 | + ) |
| 53 | +" |
| 54 | + |
| 55 | +distutils_enable_tests pytest |
| 56 | + |
| 57 | +src_prepare() { |
| 58 | + if ! use cli; then |
| 59 | + sed -i -e '/^httpx =/d' pyproject.toml || die |
| 60 | + fi |
| 61 | + sed -i -e '/rich/s:,<14::' pyproject.toml || die |
| 62 | + |
| 63 | + # use brotlicffi instead of brotli in tests |
| 64 | + sed -i -e 's:import brotli:import brotlicffi as brotli:' \ |
| 65 | + tests/test_decoders.py || die |
| 66 | + |
| 67 | + distutils-r1_src_prepare |
| 68 | +} |
| 69 | + |
| 70 | +python_test() { |
| 71 | + local EPYTEST_DESELECT=( |
| 72 | + # Internet |
| 73 | + tests/client/test_proxies.py::test_async_proxy_close |
| 74 | + tests/client/test_proxies.py::test_sync_proxy_close |
| 75 | + ) |
| 76 | + |
| 77 | + use cli || EPYTEST_IGNORE+=( |
| 78 | + tests/test_main.py |
| 79 | + ) |
| 80 | + |
| 81 | + epytest |
| 82 | +} |
| 83 | + |
| 84 | +pkg_postinst() { |
| 85 | + optfeature "HTTP/2 support" dev-python/h2 |
| 86 | + optfeature "SOCKS proxy support" dev-python/socksio |
| 87 | + optfeature "Decoding for brotli compressed responses" dev-python/brotlicffi |
| 88 | +} |
0 commit comments