commit: 96175558fb5a3e419b65fca6de7cc5cdaf3dd751 Author: Michał Górny <mgorny <AT> gentoo <DOT> org> AuthorDate: Wed Oct 16 17:19:42 2024 +0000 Commit: Michał Górny <mgorny <AT> gentoo <DOT> org> CommitDate: Wed Oct 16 17:52:53 2024 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=96175558
dev-python/httptools: New package, v0.6.2 Required again for dev-python/uvicorn's test suite, and I'm really tired of fixing it every time they add an unconditional import to their tests, so instead I'm wasting my time fixing this package. Signed-off-by: Michał Górny <mgorny <AT> gentoo.org> dev-python/httptools/Manifest | 2 + .../httptools/files/httptools-0.6.2-llhttp-9.patch | 55 ++++++++++++++++ dev-python/httptools/httptools-0.6.2.ebuild | 74 ++++++++++++++++++++++ dev-python/httptools/metadata.xml | 11 ++++ 4 files changed, 142 insertions(+) diff --git a/dev-python/httptools/Manifest b/dev-python/httptools/Manifest new file mode 100644 index 000000000000..6a4531061168 --- /dev/null +++ b/dev-python/httptools/Manifest @@ -0,0 +1,2 @@ +DIST httptools-0.6.2.gh.tar.gz 15209 BLAKE2B f9dbb15a46db4ff6d9ce418fa9854fe465d22c5ca7b758389f2d132f0e031015faea37241f68e8f47e3957da39de9930481e50d0b08e0308ad7d3bb918fc86bb SHA512 a4f79cfd82b1ab3d1bb4dc50cb4c720cdc5b2f94cb72ef693e4385726a02687f1a45d649c8cc22388f1215c9497f329b67eed90f065859380dbd54dd3046c89b +DIST httptools-0.6.2.tar.gz 244278 BLAKE2B 70105538497a8af0620f723c3119adcb2069e5ddee28b7f06dc4288d99f7205b2a87028a308936a816106d074eb014547ba72bca1f9ea7b81994031ad9cd6630 SHA512 69a303ac035f9bb683841f3477b06e2ce33bd0e3717554a85da39f61d72a83f71eeca6c68a6a8b3441a7b65ae90e4bcda1cda680104cf2c44ba6379c9857276f diff --git a/dev-python/httptools/files/httptools-0.6.2-llhttp-9.patch b/dev-python/httptools/files/httptools-0.6.2-llhttp-9.patch new file mode 100644 index 000000000000..8f5dc017d246 --- /dev/null +++ b/dev-python/httptools/files/httptools-0.6.2-llhttp-9.patch @@ -0,0 +1,55 @@ +diff --git a/tests/test_parser.py b/tests/test_parser.py +index a169a9a..d3b8db7 100644 +--- a/tests/test_parser.py ++++ b/tests/test_parser.py +@@ -6,12 +6,10 @@ from unittest import mock + + RESPONSE1_HEAD = b'''HTTP/1.1 200 OK + Date: Mon, 23 May 2005 22:38:34 GMT +-Server: Apache/1.3.3.7 +- (Unix) (Red-Hat/Linux) ++Server: Apache/1.3.3.7 (Unix) (Red-Hat/Linux) + Last-Modified: Wed, 08 Jan 2003 23:11:55 GMT + ETag: "3f80f-1b6-3e1cb03b" +-Content-Type: text/html; +- charset=UTF-8 ++Content-Type: text/html; charset=UTF-8 + Content-Length: 130 + Accept-Ranges: bytes + Connection: close +@@ -33,7 +31,7 @@ CHUNKED_REQUEST1_1 = b'''POST /test.php?a=b+c HTTP/1.1\r + User-Agent: Fooo\r + Host: bar\r + Transfer-Encoding: chunked\r +- ++\r + 5\r\nhello\r\n6\r\n world\r\n''' + + CHUNKED_REQUEST1_2 = b'''0\r\nVary: *\r\nUser-Agent: spam\r\n\r\n''' +@@ -42,7 +40,7 @@ CHUNKED_REQUEST1_3 = b'''POST /test.php?a=b+c HTTP/1.1\r + User-Agent: Fooo\r + Host: bar\r + Transfer-Encoding: chunked\r +- ++\r + b\r\n+\xce\xcfM\xb5MI,I\x04\x00\r\n0\r\n\r\n''' + + +@@ -54,7 +52,7 @@ Sec-WebSocket-Protocol: sample\r + Upgrade: WebSocket\r + Sec-WebSocket-Key1: 4 @1 46546xW%0l 1 5\r + Origin: http://example.com\r +- ++\r + Hot diggity dogg''' + + UPGRADE_RESPONSE1 = b'''HTTP/1.1 101 Switching Protocols +@@ -89,7 +87,7 @@ class TestResponseParser(unittest.TestCase): + self.assertEqual(len(headers), 8) + self.assertEqual(headers.get(b'Connection'), b'close') + self.assertEqual(headers.get(b'Content-Type'), +- b'text/html; charset=UTF-8') ++ b'text/html; charset=UTF-8') + + self.assertFalse(m.on_body.called) + p.feed_data(bytearray(RESPONSE1_BODY)) diff --git a/dev-python/httptools/httptools-0.6.2.ebuild b/dev-python/httptools/httptools-0.6.2.ebuild new file mode 100644 index 000000000000..460b421e3b33 --- /dev/null +++ b/dev-python/httptools/httptools-0.6.2.ebuild @@ -0,0 +1,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 +} diff --git a/dev-python/httptools/metadata.xml b/dev-python/httptools/metadata.xml new file mode 100644 index 000000000000..01e4e994ac2d --- /dev/null +++ b/dev-python/httptools/metadata.xml @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE pkgmetadata SYSTEM "https://www.gentoo.org/dtd/metadata.dtd"> +<pkgmetadata> + <maintainer type="project"> + <email>[email protected]</email> + </maintainer> + <upstream> + <remote-id type="github">MagicStack/httptools</remote-id> + <remote-id type="pypi">httptools</remote-id> + </upstream> +</pkgmetadata>
