diff --git a/0001-Stop-using-deprecated-app-shortcut-in-httpx.AsyncCli.patch b/0001-Stop-using-deprecated-app-shortcut-in-httpx.AsyncCli.patch new file mode 100644 index 0000000..493e027 --- /dev/null +++ b/0001-Stop-using-deprecated-app-shortcut-in-httpx.AsyncCli.patch @@ -0,0 +1,133 @@ +From 62e52f30f75b42290e32adb85dd1319b9c5a0072 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Dan=20=C4=8Cerm=C3=A1k?= +Date: Mon, 25 Mar 2024 21:48:07 +0100 +Subject: [PATCH] Stop using deprecated app shortcut in httpx.AsyncClient + +This keyword parameter has been deprecated with httpx 0.27 +--- + tests/middleware/test_message_logger.py | 8 ++++---- + tests/middleware/test_proxy_headers.py | 6 +++--- + tests/middleware/test_wsgi.py | 23 ++++++++--------------- + 3 files changed, 15 insertions(+), 22 deletions(-) + +diff --git a/tests/middleware/test_message_logger.py b/tests/middleware/test_message_logger.py +index 3f5c3af..d066e99 100644 +--- a/tests/middleware/test_message_logger.py ++++ b/tests/middleware/test_message_logger.py +@@ -17,8 +17,8 @@ async def test_message_logger(caplog): + caplog.set_level(TRACE_LOG_LEVEL, logger="uvicorn.asgi") + caplog.set_level(TRACE_LOG_LEVEL) + +- app = MessageLoggerMiddleware(app) +- async with httpx.AsyncClient(app=app, base_url="http://testserver") as client: ++ transport = httpx.ASGITransport(MessageLoggerMiddleware(app)) ++ async with httpx.AsyncClient(transport=transport, base_url="http://testserver") as client: + response = await client.get("/") + assert response.status_code == 200 + messages = [record.msg % record.args for record in caplog.records] +@@ -37,8 +37,8 @@ async def test_message_logger_exc(caplog): + with caplog_for_logger(caplog, "uvicorn.asgi"): + caplog.set_level(TRACE_LOG_LEVEL, logger="uvicorn.asgi") + caplog.set_level(TRACE_LOG_LEVEL) +- app = MessageLoggerMiddleware(app) +- async with httpx.AsyncClient(app=app, base_url="http://testserver") as client: ++ transport = httpx.ASGITransport(MessageLoggerMiddleware(app)) ++ async with httpx.AsyncClient(transport=transport, base_url="http://testserver") as client: + with pytest.raises(RuntimeError): + await client.get("/") + messages = [record.msg % record.args for record in caplog.records] +diff --git a/tests/middleware/test_proxy_headers.py b/tests/middleware/test_proxy_headers.py +index 6d7fc8c..e50defa 100644 +--- a/tests/middleware/test_proxy_headers.py ++++ b/tests/middleware/test_proxy_headers.py +@@ -49,7 +49,7 @@ async def app( + ) + async def test_proxy_headers_trusted_hosts(trusted_hosts: list[str] | str, response_text: str) -> None: + app_with_middleware = ProxyHeadersMiddleware(app, trusted_hosts=trusted_hosts) +- async with httpx.AsyncClient(app=app_with_middleware, base_url="http://testserver") as client: ++ async with httpx.AsyncClient(transport=httpx.ASGITransport(app=app_with_middleware), base_url="http://testserver") as client: + headers = {"X-Forwarded-Proto": "https", "X-Forwarded-For": "1.2.3.4"} + response = await client.get("/", headers=headers) + +@@ -79,7 +79,7 @@ async def test_proxy_headers_trusted_hosts(trusted_hosts: list[str] | str, respo + ) + async def test_proxy_headers_multiple_proxies(trusted_hosts: list[str] | str, response_text: str) -> None: + app_with_middleware = ProxyHeadersMiddleware(app, trusted_hosts=trusted_hosts) +- async with httpx.AsyncClient(app=app_with_middleware, base_url="http://testserver") as client: ++ async with httpx.AsyncClient(transport=httpx.ASGITransport(app=app_with_middleware), base_url="http://testserver") as client: + headers = { + "X-Forwarded-Proto": "https", + "X-Forwarded-For": "1.2.3.4, 10.0.2.1, 192.168.0.2", +@@ -93,7 +93,7 @@ async def test_proxy_headers_multiple_proxies(trusted_hosts: list[str] | str, re + @pytest.mark.anyio + async def test_proxy_headers_invalid_x_forwarded_for() -> None: + app_with_middleware = ProxyHeadersMiddleware(app, trusted_hosts="*") +- async with httpx.AsyncClient(app=app_with_middleware, base_url="http://testserver") as client: ++ async with httpx.AsyncClient(transport=httpx.ASGITransport(app=app_with_middleware), base_url="http://testserver") as client: + headers = httpx.Headers( + { + "X-Forwarded-Proto": "https", +diff --git a/tests/middleware/test_wsgi.py b/tests/middleware/test_wsgi.py +index adc8e24..478dd84 100644 +--- a/tests/middleware/test_wsgi.py ++++ b/tests/middleware/test_wsgi.py +@@ -59,8 +59,8 @@ def wsgi_middleware(request: pytest.FixtureRequest) -> Callable: + + @pytest.mark.anyio + async def test_wsgi_get(wsgi_middleware: Callable) -> None: +- app = wsgi_middleware(hello_world) +- async with httpx.AsyncClient(app=app, base_url="http://testserver") as client: ++ transport = httpx.ASGITransport(wsgi_middleware(hello_world)) ++ async with httpx.AsyncClient(transport=transport, base_url="http://testserver") as client: + response = await client.get("/") + assert response.status_code == 200 + assert response.text == "Hello World!\n" +@@ -68,8 +68,8 @@ async def test_wsgi_get(wsgi_middleware: Callable) -> None: + + @pytest.mark.anyio + async def test_wsgi_post(wsgi_middleware: Callable) -> None: +- app = wsgi_middleware(echo_body) +- async with httpx.AsyncClient(app=app, base_url="http://testserver") as client: ++ transport = httpx.ASGITransport(wsgi_middleware(echo_body)) ++ async with httpx.AsyncClient(transport=transport, base_url="http://testserver") as client: + response = await client.post("/", json={"example": 123}) + assert response.status_code == 200 + assert response.text == '{"example": 123}' +@@ -81,8 +81,8 @@ async def test_wsgi_put_more_body(wsgi_middleware: Callable) -> None: + for _ in range(1024): + yield b"123456789abcdef\n" * 64 + +- app = wsgi_middleware(echo_body) +- async with httpx.AsyncClient(app=app, base_url="http://testserver") as client: ++ transport = httpx.ASGITransport(wsgi_middleware(echo_body)) ++ async with httpx.AsyncClient(transport=transport, base_url="http://testserver") as client: + response = await client.put("/", content=generate_body()) + assert response.status_code == 200 + assert response.text == "123456789abcdef\n" * 64 * 1024 +@@ -92,21 +92,14 @@ async def test_wsgi_put_more_body(wsgi_middleware: Callable) -> None: + async def test_wsgi_exception(wsgi_middleware: Callable) -> None: + # Note that we're testing the WSGI app directly here. + # The HTTP protocol implementations would catch this error and return 500. +- app = wsgi_middleware(raise_exception) +- async with httpx.AsyncClient(app=app, base_url="http://testserver") as client: ++ transport = httpx.ASGITransport(wsgi_middleware(raise_exception)) ++ async with httpx.AsyncClient(transport=transport, base_url="http://testserver") as client: + with pytest.raises(RuntimeError): + await client.get("/") + + + @pytest.mark.anyio + async def test_wsgi_exc_info(wsgi_middleware: Callable) -> None: +- # Note that we're testing the WSGI app directly here. +- # The HTTP protocol implementations would catch this error and return 500. +- app = wsgi_middleware(return_exc_info) +- async with httpx.AsyncClient(app=app, base_url="http://testserver") as client: +- with pytest.raises(RuntimeError): +- response = await client.get("/") +- + app = wsgi_middleware(return_exc_info) + transport = httpx.ASGITransport( + app=app, +-- +2.44.0 + diff --git a/python-uvicorn.changes b/python-uvicorn.changes index 4022c9f..a46db61 100644 --- a/python-uvicorn.changes +++ b/python-uvicorn.changes @@ -1,3 +1,39 @@ +------------------------------------------------------------------- +Mon Mar 25 20:19:46 UTC 2024 - Dan Čermák + +- New upstream release 0.29.0 + + * Cooperative signal handling (#1600) 19/03/24 + * Revert raise `ClientDisconnected` on HTTP (#2276) 19/03/24 + +- Add patch: + * 0001-Stop-using-deprecated-app-shortcut-in-httpx.AsyncCli.patch + upstream fix for the testsuite with httpx 0.27 + +- Remove pointless Suggests: + +------------------------------------------------------------------- +Sun Mar 17 10:11:10 UTC 2024 - Dirk Müller + +- update to 0.28.0: + * Raise `ClientDisconnected` on `send()` when client + disconnected (#2220) 12/02/24 + * Except `AttributeError` on `sys.stdin.fileno()` for Windows + IIS10 (#1947) 29/02/24 + * Use `X-Forwarded-Proto` for WebSockets scheme when the proxy + provides it (#2258) 01/03/24 + * Fix spurious LocalProtocolError errors when processing + pipelined requests (#2243) 10/02/24 + * Fix nav overrides for newer version of Mkdocs Material + (#2233) 26/01/24 + * Raise `ClientDisconnect(IOError)` on `send()` when client + disconnected (#2218) 19/01/24 + * Bump ASGI WebSocket spec version to 2.4 (#2221) 20/01/24 + * Update `--root-path` to include the root path prefix in the + full ASGI `path` as per the ASGI spec (#2213) 16/01/24 + * Use `__future__.annotations` on some internal modules (#2199) + 16/01/24 + ------------------------------------------------------------------- Tue Jan 30 12:43:20 UTC 2024 - Daniel Garcia diff --git a/python-uvicorn.spec b/python-uvicorn.spec index e5a4935..b19dc62 100644 --- a/python-uvicorn.spec +++ b/python-uvicorn.spec @@ -18,7 +18,7 @@ %{?sle15_python_module_pythons} Name: python-uvicorn -Version: 0.25.0 +Version: 0.29.0 Release: 0 Summary: An Asynchronous Server Gateway Interface server License: BSD-3-Clause @@ -26,6 +26,8 @@ URL: https://github.com/encode/uvicorn Source: https://github.com/encode/uvicorn/archive/%{version}.tar.gz#/uvicorn-%{version}.tar.gz # PATCH-FIX-UPSTREAM fix-websocket-tests.patch -- gh#encode/uvicorn#1929 Patch0: fix-websocket-tests.patch +# https://github.com/encode/uvicorn/pull/2288 +Patch1: 0001-Stop-using-deprecated-app-shortcut-in-httpx.AsyncCli.patch BuildRequires: %{python_module base >= 3.8} BuildRequires: %{python_module hatchling} BuildRequires: %{python_module pip} @@ -40,10 +42,6 @@ Requires: (python-typing-extensions >= 4 if python-base < 3.11) Recommends: python-PyYAML >= 5.1 Recommends: python-httptools >= 0.4.0 Recommends: python-websockets >= 8.0 -Suggests: python-uvloop >= 0.14.0 -Suggests: python-watchfiles >= 0.13 -Suggests: python-wsproto >= 1.2.0 -Suggests: python-websockets Requires(post): update-alternatives Requires(postun): update-alternatives BuildArch: noarch @@ -52,7 +50,7 @@ BuildRequires: %{python_module PyYAML >= 5.1} BuildRequires: %{python_module click >= 7.0} BuildRequires: %{python_module h11 >= 0.8.0} BuildRequires: %{python_module httptools >= 0.4.0} -BuildRequires: %{python_module httpx >= 0.18} +BuildRequires: %{python_module httpx >= 0.27} BuildRequires: %{python_module pytest-asyncio} BuildRequires: %{python_module pytest-mock} BuildRequires: %{python_module pytest} @@ -62,7 +60,7 @@ BuildRequires: %{python_module trustme} %if 0%{?suse_version} > 1500 BuildRequires: %{python_module uvloop >= 0.14.0} %endif -BuildRequires: %{python_module websockets >= 8.0} +BuildRequires: %{python_module websockets >= 10.4} BuildRequires: %{python_module wsproto >= 1.2.0} # We don't want watchfiles in Ring1 #BuildRequires: #{python_module watchfiles >= 0.13} diff --git a/uvicorn-0.25.0.tar.gz b/uvicorn-0.25.0.tar.gz deleted file mode 100644 index 98436b9..0000000 --- a/uvicorn-0.25.0.tar.gz +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:ae1b49d8406d3fec8f63195644546e6ee18de841beecce3fba86de5422cee09e -size 717386 diff --git a/uvicorn-0.29.0.tar.gz b/uvicorn-0.29.0.tar.gz new file mode 100644 index 0000000..8a2bd93 --- /dev/null +++ b/uvicorn-0.29.0.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b12a6866e7bc70fb89bd54c2d1a6b0382183657e369deed3a2d0535c280e46c9 +size 719202