mirror of
https://github.com/gradio-app/gradio.git
synced 2025-04-06 12:30:29 +08:00
Add an explicit dependency of urllib3~=2.0
and update processing_utils.save_url_to_cache
to use urllib3
for Lite support (#8011)
* Add an explicit dependency of `urllib3` and update `processing_utils.save_url_to_cache` to use `urllib3` for Lite support * add changeset * Update requirements.txt Co-authored-by: Abubakar Abid <abubakar@huggingface.co> * add changeset * update test requirements * update test reqs * add changeset --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> Co-authored-by: Abubakar Abid <abubakar@huggingface.co>
This commit is contained in:
parent
e10ec6a612
commit
f17d1a0a6f
5
.changeset/nine-melons-follow.md
Normal file
5
.changeset/nine-melons-follow.md
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
"gradio": minor
|
||||
---
|
||||
|
||||
fix:Add an explicit dependency of `urllib3~=2.0` and update `processing_utils.save_url_to_cache` to use `urllib3` for Lite support
|
@ -16,6 +16,7 @@ from typing import TYPE_CHECKING, Any
|
||||
import aiofiles
|
||||
import httpx
|
||||
import numpy as np
|
||||
import urllib3
|
||||
from gradio_client import utils as client_utils
|
||||
from PIL import Image, ImageOps, PngImagePlugin
|
||||
|
||||
@ -208,10 +209,15 @@ def save_url_to_cache(url: str, cache_dir: str) -> str:
|
||||
full_temp_file_path = str(abspath(temp_dir / name))
|
||||
|
||||
if not Path(full_temp_file_path).exists():
|
||||
with httpx.stream("GET", url, follow_redirects=True) as r, open(
|
||||
full_temp_file_path, "wb"
|
||||
) as f:
|
||||
for chunk in r.iter_raw():
|
||||
# NOTE: We use urllib3 instead of httpx because it works in the Wasm environment. See https://github.com/gradio-app/gradio/issues/6837.
|
||||
http = urllib3.PoolManager()
|
||||
response = http.request(
|
||||
"GET",
|
||||
url,
|
||||
preload_content=False,
|
||||
)
|
||||
with open(full_temp_file_path, "wb") as f:
|
||||
for chunk in response.stream():
|
||||
f.write(chunk)
|
||||
|
||||
return full_temp_file_path
|
||||
|
@ -20,6 +20,7 @@ pydub
|
||||
pyyaml>=5.0,<7.0
|
||||
semantic_version~=2.0
|
||||
typing_extensions~=4.0
|
||||
urllib3~=2.0 # urllib3 is used for Lite support. Version spec can be omitted because urllib3==2.1.0 is prebuilt for Pyodide and urllib>=2.2.0 supports Pyodide as well.
|
||||
uvicorn>=0.14.0; sys.platform != 'emscripten'
|
||||
typer[all]>=0.9,<1.0; sys.platform != 'emscripten'
|
||||
tomlkit==0.12.0
|
||||
|
@ -26,9 +26,9 @@ attrs==21.4.0
|
||||
# pytest
|
||||
backcall==0.2.0
|
||||
# via ipython
|
||||
boto3==1.26.65
|
||||
boto3==1.34.84
|
||||
# via -r requirements.in
|
||||
botocore==1.29.87
|
||||
botocore==1.34.84
|
||||
# via
|
||||
# boto3
|
||||
# s3transfer
|
||||
@ -273,7 +273,7 @@ ruff==0.2.2
|
||||
# via
|
||||
# -r requirements.in
|
||||
# gradio
|
||||
s3transfer==0.6.0
|
||||
s3transfer==0.10.0
|
||||
# via boto3
|
||||
safetensors==0.4.2
|
||||
# via
|
||||
|
Loading…
x
Reference in New Issue
Block a user