From 3a5735d8b59ce1b30048e48c2c67257a1e2df85b Mon Sep 17 00:00:00 2001 From: Claudia Pellegrino Date: Fri, 2 Dec 2022 10:23:26 +0100 Subject: [PATCH] Fix httpx usage Follow redirects when downloading from GitHub via httpx. Fixes issue #686 [1]. [1]: https://github.com/deezer/spleeter/issues/686 Reported-by: Antonio Petricca --- poetry.lock | 42 ++++++++++++++++++------------- pyproject.toml | 2 +- spleeter/model/provider/github.py | 4 +-- 3 files changed, 28 insertions(+), 20 deletions(-) diff --git a/poetry.lock b/poetry.lock index 299bdbf4..1abf8286 100644 --- a/poetry.lock +++ b/poetry.lock @@ -525,16 +525,19 @@ protobuf = ["grpcio-tools (>=1.51.1)"] [[package]] name = "h11" -version = "0.12.0" +version = "0.14.0" description = "A pure-Python, bring-your-own-I/O implementation of HTTP/1.1" category = "main" optional = false -python-versions = ">=3.6" +python-versions = ">=3.7" files = [ - {file = "h11-0.12.0-py3-none-any.whl", hash = "sha256:36a3cb8c0a032f56e2da7084577878a035d3b61d104230d4bd49c0c6b555a9c6"}, - {file = "h11-0.12.0.tar.gz", hash = "sha256:47222cb6067e4a307d535814917cd98fd0a57b6788ce715755fa2b6c28b56042"}, + {file = "h11-0.14.0-py3-none-any.whl", hash = "sha256:e3fe4ac4b851c468cc8363d500db52c2ead036020723024a109d37346efaa761"}, + {file = "h11-0.14.0.tar.gz", hash = "sha256:8f19fbbe99e72420ff35c00b27a34cb9937e902a8b810e2c88300c6f0a3b699d"}, ] +[package.dependencies] +typing-extensions = {version = "*", markers = "python_version < \"3.8\""} + [[package]] name = "h2" version = "4.1.0" @@ -603,47 +606,50 @@ files = [ [[package]] name = "httpcore" -version = "0.13.7" +version = "0.16.3" description = "A minimal low-level HTTP client." category = "main" optional = false -python-versions = ">=3.6" +python-versions = ">=3.7" files = [ - {file = "httpcore-0.13.7-py3-none-any.whl", hash = "sha256:369aa481b014cf046f7067fddd67d00560f2f00426e79569d99cb11245134af0"}, - {file = "httpcore-0.13.7.tar.gz", hash = "sha256:036f960468759e633574d7c121afba48af6419615d36ab8ede979f1ad6276fa3"}, + {file = "httpcore-0.16.3-py3-none-any.whl", hash = "sha256:da1fb708784a938aa084bde4feb8317056c55037247c787bd7e19eb2c2949dc0"}, + {file = "httpcore-0.16.3.tar.gz", hash = "sha256:c5d6f04e2fc530f39e0c077e6a30caa53f1451096120f1f38b954afd0b17c0cb"}, ] [package.dependencies] -anyio = ">=3.0.0,<4.0.0" -h11 = ">=0.11,<0.13" +anyio = ">=3.0,<5.0" +certifi = "*" +h11 = ">=0.13,<0.15" sniffio = ">=1.0.0,<2.0.0" [package.extras] http2 = ["h2 (>=3,<5)"] +socks = ["socksio (>=1.0.0,<2.0.0)"] [[package]] name = "httpx" -version = "0.19.0" +version = "0.23.3" description = "The next generation HTTP client." category = "main" optional = false -python-versions = ">=3.6" +python-versions = ">=3.7" files = [ - {file = "httpx-0.19.0-py3-none-any.whl", hash = "sha256:9bd728a6c5ec0a9e243932a9983d57d3cc4a87bb4f554e1360fce407f78f9435"}, - {file = "httpx-0.19.0.tar.gz", hash = "sha256:92ecd2c00c688b529eda11cedb15161eaf02dee9116712f621c70d9a40b2cdd0"}, + {file = "httpx-0.23.3-py3-none-any.whl", hash = "sha256:a211fcce9b1254ea24f0cd6af9869b3d29aba40154e947d2a07bb499b3e310d6"}, + {file = "httpx-0.23.3.tar.gz", hash = "sha256:9818458eb565bb54898ccb9b8b251a28785dd4a55afbc23d0eb410754fe7d0f9"}, ] [package.dependencies] certifi = "*" -charset-normalizer = "*" h2 = {version = ">=3,<5", optional = true, markers = "extra == \"http2\""} -httpcore = ">=0.13.3,<0.14.0" +httpcore = ">=0.15.0,<0.17.0" rfc3986 = {version = ">=1.3,<2", extras = ["idna2008"]} sniffio = "*" [package.extras] brotli = ["brotli", "brotlicffi"] +cli = ["click (>=8.0.0,<9.0.0)", "pygments (>=2.0.0,<3.0.0)", "rich (>=10,<13)"] http2 = ["h2 (>=3,<5)"] +socks = ["socksio (>=1.0.0,<2.0.0)"] [[package]] name = "hyperframe" @@ -803,6 +809,7 @@ optional = false python-versions = "*" files = [ {file = "libclang-15.0.6.1-py2.py3-none-macosx_10_9_x86_64.whl", hash = "sha256:8621795e07b87e17fc7aac9f071bc7fe6b52ed6110c0a96a9975d8113c8c2527"}, + {file = "libclang-15.0.6.1-py2.py3-none-macosx_11_0_arm64.whl", hash = "sha256:0bf192c48a8d2992fc5034393ddc99e772ac30e105df84927d62fc88ef8a659f"}, {file = "libclang-15.0.6.1-py2.py3-none-manylinux2010_x86_64.whl", hash = "sha256:69b01a23ab543908a661532595daa23cf88bd96d80e41f58ba0eaa6a378fe0d8"}, {file = "libclang-15.0.6.1-py2.py3-none-manylinux2014_aarch64.whl", hash = "sha256:4a5188184b937132c198ee9de9a8a2316d5fdd1a825398d5ad1a8f5e06f9b40e"}, {file = "libclang-15.0.6.1-py2.py3-none-manylinux2014_armv7l.whl", hash = "sha256:f7ffa02ac5e586cfffde039dcccc439d88d0feac7d77bf9426d9ba7543d16545"}, @@ -1745,6 +1752,7 @@ files = [ {file = "soundfile-0.12.1-py2.py3-none-any.whl", hash = "sha256:828a79c2e75abab5359f780c81dccd4953c45a2c4cd4f05ba3e233ddf984b882"}, {file = "soundfile-0.12.1-py2.py3-none-macosx_10_9_x86_64.whl", hash = "sha256:d922be1563ce17a69582a352a86f28ed8c9f6a8bc951df63476ffc310c064bfa"}, {file = "soundfile-0.12.1-py2.py3-none-macosx_11_0_arm64.whl", hash = "sha256:bceaab5c4febb11ea0554566784bcf4bc2e3977b53946dda2b12804b4fe524a8"}, + {file = "soundfile-0.12.1-py2.py3-none-manylinux_2_17_x86_64.whl", hash = "sha256:2dc3685bed7187c072a46ab4ffddd38cef7de9ae5eb05c03df2ad569cf4dacbc"}, {file = "soundfile-0.12.1-py2.py3-none-manylinux_2_31_x86_64.whl", hash = "sha256:074247b771a181859d2bc1f98b5ebf6d5153d2c397b86ee9e29ba602a8dfe2a6"}, {file = "soundfile-0.12.1-py2.py3-none-win32.whl", hash = "sha256:59dfd88c79b48f441bbf6994142a19ab1de3b9bb7c12863402c2bc621e49091a"}, {file = "soundfile-0.12.1-py2.py3-none-win_amd64.whl", hash = "sha256:0d86924c00b62552b650ddd28af426e3ff2d4dc2e9047dae5b3d8452e0a49a77"}, @@ -2198,4 +2206,4 @@ evaluation = ["musdb", "museval"] [metadata] lock-version = "2.0" python-versions = ">=3.7.1,<3.11" -content-hash = "1a08da1a000648f4dfa3b6dc19b299271b0592a664d5abfd718c730fd568f66a" +content-hash = "9ba86b33551632cae1f0c799f19c25aa1f9f087caa21691c4ae3e8dff3cfe162" diff --git a/pyproject.toml b/pyproject.toml index db723e61..b1ac9399 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -47,7 +47,7 @@ include = ["LICENSE", "spleeter/resources/*.json"] [tool.poetry.dependencies] python = ">=3.7.1,<3.11" ffmpeg-python = "^0.2.0" -httpx = {extras = ["http2"], version = "^0.19.0"} +httpx = {extras = ["http2"], version = "^0.23.1"} typer = "^0.3.2" musdb = {version = "^0.4.0", optional = true} museval = {version = "^0.4.0", optional = true} diff --git a/spleeter/model/provider/github.py b/spleeter/model/provider/github.py index 10a1232b..4ec60bc1 100644 --- a/spleeter/model/provider/github.py +++ b/spleeter/model/provider/github.py @@ -121,7 +121,7 @@ def checksum(self, name: str) -> str: self.CHECKSUM_INDEX, ) ) - response: httpx.Response = httpx.get(url) + response: httpx.Response = httpx.get(url, follow_redirects=True) response.raise_for_status() index: Dict = response.json() if name not in index: @@ -144,7 +144,7 @@ def download(self, name: str, path: str) -> None: url = f"{url}.tar.gz" logger.info(f"Downloading model archive {url}") with httpx.Client(http2=True) as client: - with client.stream("GET", url) as response: + with client.stream("GET", url, follow_redirects=True) as response: response.raise_for_status() archive = NamedTemporaryFile(delete=False) try: