aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPo-Chuan Hsieh <sunpoet@FreeBSD.org>2022-11-19 08:13:09 +0000
committerPo-Chuan Hsieh <sunpoet@FreeBSD.org>2022-11-19 08:13:09 +0000
commit255ca6bac8ef59c39a98b96c5d92dc03cab97f77 (patch)
treee9b14a236ea9dd2a6af0cee4fae0bd17cb3ed494
parentd31205f2df49eaea23b9e750988aba31672e0c74 (diff)
downloadports-255ca6bac8ef59c39a98b96c5d92dc03cab97f77.tar.gz
ports-255ca6bac8ef59c39a98b96c5d92dc03cab97f77.zip
www/py-httpcore: Fix build after 7f9c0a770d4cb27d603401d526f22c3abc310db6 (py-h11 0.14.0 update)
-rw-r--r--www/py-httpcore/Makefile3
-rw-r--r--www/py-httpcore/files/patch-httpcore-_async-http11.py78
-rw-r--r--www/py-httpcore/files/patch-httpcore-_sync-http11.py78
-rw-r--r--www/py-httpcore/files/patch-setup.py6
4 files changed, 162 insertions, 3 deletions
diff --git a/www/py-httpcore/Makefile b/www/py-httpcore/Makefile
index 1b15b44ae54c..6d80408f8123 100644
--- a/www/py-httpcore/Makefile
+++ b/www/py-httpcore/Makefile
@@ -1,5 +1,6 @@
PORTNAME= httpcore
PORTVERSION= 0.15.0
+PORTREVISION= 1
CATEGORIES= www python
MASTER_SITES= CHEESESHOP
PKGNAMEPREFIX= ${PYTHON_PKGNAMEPREFIX}
@@ -13,7 +14,7 @@ LICENSE_FILE= ${WRKSRC}/LICENSE.md
RUN_DEPENDS= ${PYTHON_PKGNAMEPREFIX}anyio>=3.0<4:devel/py-anyio@${PY_FLAVOR} \
${PYTHON_PKGNAMEPREFIX}certifi>=0:security/py-certifi@${PY_FLAVOR} \
- ${PYTHON_PKGNAMEPREFIX}h11>=0.11<0.14:net/py-h11@${PY_FLAVOR} \
+ ${PYTHON_PKGNAMEPREFIX}h11>=0.13<0.15:net/py-h11@${PY_FLAVOR} \
${PYTHON_PKGNAMEPREFIX}sniffio>=1.0<2:devel/py-sniffio@${PY_FLAVOR}
USES= python:3.7+
diff --git a/www/py-httpcore/files/patch-httpcore-_async-http11.py b/www/py-httpcore/files/patch-httpcore-_async-http11.py
new file mode 100644
index 000000000000..41c562a0ec95
--- /dev/null
+++ b/www/py-httpcore/files/patch-httpcore-_async-http11.py
@@ -0,0 +1,78 @@
+Obtained from: https://github.com/encode/httpcore/commit/4cf288e0007cb73561b9020af9228f076ba2a94e
+
+--- httpcore/_async/http11.py.orig 2022-05-17 12:45:06 UTC
++++ httpcore/_async/http11.py
+@@ -1,7 +1,16 @@
+ import enum
+ import time
+ from types import TracebackType
+-from typing import AsyncIterable, AsyncIterator, List, Optional, Tuple, Type, Union
++from typing import (
++ AsyncIterable,
++ AsyncIterator,
++ List,
++ Optional,
++ Tuple,
++ Type,
++ Union,
++ cast,
++)
+
+ import h11
+
+@@ -17,13 +26,11 @@ from .._trace import Trace
+ from ..backends.base import AsyncNetworkStream
+ from .interfaces import AsyncConnectionInterface
+
+-H11Event = Union[
++# A subset of `h11.Event` types supported by `_send_event`
++H11SendEvent = Union[
+ h11.Request,
+- h11.Response,
+- h11.InformationalResponse,
+ h11.Data,
+ h11.EndOfMessage,
+- h11.ConnectionClosed,
+ ]
+
+
+@@ -127,14 +134,14 @@ class AsyncHTTP11Connection(AsyncConnectionInterface):
+ event = h11.Data(data=chunk)
+ await self._send_event(event, timeout=timeout)
+
+- event = h11.EndOfMessage()
+- await self._send_event(event, timeout=timeout)
++ await self._send_event(h11.EndOfMessage(), timeout=timeout)
+
+ async def _send_event(
+- self, event: H11Event, timeout: Optional[float] = None
++ self, event: h11.Event, timeout: Optional[float] = None
+ ) -> None:
+ bytes_to_send = self._h11_state.send(event)
+- await self._network_stream.write(bytes_to_send, timeout=timeout)
++ if bytes_to_send is not None:
++ await self._network_stream.write(bytes_to_send, timeout=timeout)
+
+ # Receiving the response...
+
+@@ -168,7 +175,9 @@ class AsyncHTTP11Connection(AsyncConnectionInterface):
+ elif isinstance(event, (h11.EndOfMessage, h11.PAUSED)):
+ break
+
+- async def _receive_event(self, timeout: Optional[float] = None) -> H11Event:
++ async def _receive_event(
++ self, timeout: Optional[float] = None
++ ) -> Union[h11.Event, Type[h11.PAUSED]]:
+ while True:
+ with map_exceptions({h11.RemoteProtocolError: RemoteProtocolError}):
+ event = self._h11_state.next_event()
+@@ -192,7 +201,8 @@ class AsyncHTTP11Connection(AsyncConnectionInterface):
+
+ self._h11_state.receive_data(data)
+ else:
+- return event
++ # mypy fails to narrow the type in the above if statement above
++ return cast(Union[h11.Event, Type[h11.PAUSED]], event)
+
+ async def _response_closed(self) -> None:
+ async with self._state_lock:
diff --git a/www/py-httpcore/files/patch-httpcore-_sync-http11.py b/www/py-httpcore/files/patch-httpcore-_sync-http11.py
new file mode 100644
index 000000000000..3091478c3ac3
--- /dev/null
+++ b/www/py-httpcore/files/patch-httpcore-_sync-http11.py
@@ -0,0 +1,78 @@
+Obtained from: https://github.com/encode/httpcore/commit/4cf288e0007cb73561b9020af9228f076ba2a94e
+
+--- httpcore/_sync/http11.py.orig 2022-05-17 12:45:06 UTC
++++ httpcore/_sync/http11.py
+@@ -1,7 +1,16 @@
+ import enum
+ import time
+ from types import TracebackType
+-from typing import Iterable, Iterator, List, Optional, Tuple, Type, Union
++from typing import (
++ Iterable,
++ Iterator,
++ List,
++ Optional,
++ Tuple,
++ Type,
++ Union,
++ cast,
++)
+
+ import h11
+
+@@ -17,13 +26,11 @@ from .._trace import Trace
+ from ..backends.base import NetworkStream
+ from .interfaces import ConnectionInterface
+
+-H11Event = Union[
++# A subset of `h11.Event` types supported by `_send_event`
++H11SendEvent = Union[
+ h11.Request,
+- h11.Response,
+- h11.InformationalResponse,
+ h11.Data,
+ h11.EndOfMessage,
+- h11.ConnectionClosed,
+ ]
+
+
+@@ -127,14 +134,14 @@ class HTTP11Connection(ConnectionInterface):
+ event = h11.Data(data=chunk)
+ self._send_event(event, timeout=timeout)
+
+- event = h11.EndOfMessage()
+- self._send_event(event, timeout=timeout)
++ self._send_event(h11.EndOfMessage(), timeout=timeout)
+
+ def _send_event(
+- self, event: H11Event, timeout: Optional[float] = None
++ self, event: h11.Event, timeout: Optional[float] = None
+ ) -> None:
+ bytes_to_send = self._h11_state.send(event)
+- self._network_stream.write(bytes_to_send, timeout=timeout)
++ if bytes_to_send is not None:
++ self._network_stream.write(bytes_to_send, timeout=timeout)
+
+ # Receiving the response...
+
+@@ -168,7 +175,9 @@ class HTTP11Connection(ConnectionInterface):
+ elif isinstance(event, (h11.EndOfMessage, h11.PAUSED)):
+ break
+
+- def _receive_event(self, timeout: Optional[float] = None) -> H11Event:
++ def _receive_event(
++ self, timeout: Optional[float] = None
++ ) -> Union[h11.Event, Type[h11.PAUSED]]:
+ while True:
+ with map_exceptions({h11.RemoteProtocolError: RemoteProtocolError}):
+ event = self._h11_state.next_event()
+@@ -192,7 +201,8 @@ class HTTP11Connection(ConnectionInterface):
+
+ self._h11_state.receive_data(data)
+ else:
+- return event
++ # mypy fails to narrow the type in the above if statement above
++ return cast(Union[h11.Event, Type[h11.PAUSED]], event)
+
+ def _response_closed(self) -> None:
+ with self._state_lock:
diff --git a/www/py-httpcore/files/patch-setup.py b/www/py-httpcore/files/patch-setup.py
index d70a1b2e8e61..d804a6bc020a 100644
--- a/www/py-httpcore/files/patch-setup.py
+++ b/www/py-httpcore/files/patch-setup.py
@@ -1,11 +1,13 @@
---- setup.py.orig 2022-01-18 11:44:56 UTC
+Obtained from: https://github.com/encode/httpcore/commit/4cf288e0007cb73561b9020af9228f076ba2a94e
+
+--- setup.py.orig 2022-05-17 12:45:06 UTC
+++ setup.py
@@ -54,7 +54,7 @@ setup(
include_package_data=True,
zip_safe=False,
install_requires=[
- "h11>=0.11,<0.13",
-+ "h11>=0.11,<0.14",
++ "h11>=0.13,<0.15",
"sniffio==1.*",
"anyio==3.*",
"certifi",