summaryrefslogtreecommitdiff
blob: 460b421e3b331d5507e50214d191d8d272becb3f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# Copyright 2024 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

DISTUTILS_EXT=1
DISTUTILS_USE_PEP517=setuptools
PYTHON_COMPAT=( pypy3 python3_{10..13} )

inherit distutils-r1 pypi

DESCRIPTION="A collection of framework independent HTTP protocol utils"
HOMEPAGE="
	https://github.com/MagicStack/httptools/
	https://pypi.org/project/httptools/
"
# sdist is missing cython source files, and github archive is missing
# vendored libs
SRC_URI+="
	https://github.com/MagicStack/httptools/archive/v${PV}.tar.gz
		-> ${P}.gh.tar.gz
"

LICENSE="MIT"
SLOT="0"
KEYWORDS="~amd64"

# don't ask me why they use both
DEPEND="
	net-libs/http-parser:=
	net-libs/llhttp:=
"
RDEPEND="
	${DEPEND}
"
BDEPEND="
	dev-python/cython[${PYTHON_USEDEP}]
"

distutils_enable_tests pytest

PATCHES=(
	# https://github.com/MagicStack/httptools/issues/111
	# https://github.com/MagicStack/httptools/pull/112
	"${FILESDIR}/${P}-llhttp-9.patch"
)

src_configure() {
	cat > setup.cfg <<-EOF || die
		[build_ext]
		use_system_llhttp = true
		use_system_http_parser = true
		cython_always = true
	EOF
}

python_test() {
	local EPYTEST_DESELECT=()

	case ${EPYTHON} in
		pypy3)
			EPYTEST_DESELECT+=(
				# error message mismatches
				# https://github.com/MagicStack/httptools/issues/16#issuecomment-1114181747
				tests/test_parser.py::TestResponseParser::test_parser_response_2
				tests/test_parser.py::TestRequestParser::test_parser_request_4
				tests/test_parser.py::TestUrlParser::test_parser_url_10
			)
			;;
	esac

	rm -rf httptools || die
	epytest tests
}