Skip to content

Commit

Permalink
Remove two dependencies: importlib_resources and urllib3 (if not …
Browse files Browse the repository at this point in the history
…in Wasm) (#9321)

* remove-importlib_resources

* add changeset

* urllib only on wasm

* add changeset

* format

* format

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
  • Loading branch information
abidlabs and gradio-pr-bot authored Sep 11, 2024
1 parent 34f46b0 commit 81a356d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/cute-rules-write.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"gradio": minor
---

feat:Remove two dependencies: `importlib_resources` and `urllib3` (if not in Wasm)
12 changes: 8 additions & 4 deletions gradio/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import asyncio
import contextlib
import hashlib
import importlib.resources
import inspect
import json
import math
Expand Down Expand Up @@ -45,7 +46,6 @@
from gradio_client import utils as client_utils
from gradio_client.documentation import document
from gradio_client.utils import ServerMessage
from importlib_resources import files
from jinja2.exceptions import TemplateNotFound
from multipart.multipart import parse_options_header
from starlette.background import BackgroundTask
Expand Down Expand Up @@ -103,15 +103,19 @@

STATIC_TEMPLATE_LIB = cast(
DeveloperPath,
files("gradio").joinpath("templates").as_posix(), # type: ignore
importlib.resources.files("gradio").joinpath("templates").as_posix(), # type: ignore
)
STATIC_PATH_LIB = cast(
DeveloperPath,
files("gradio").joinpath("templates", "frontend", "static").as_posix(), # type: ignore
importlib.resources.files("gradio")
.joinpath("templates/frontend/static")
.as_posix(), # type: ignore
)
BUILD_PATH_LIB = cast(
DeveloperPath,
files("gradio").joinpath("templates", "frontend", "assets").as_posix(), # type: ignore
importlib.resources.files("gradio")
.joinpath("templates/frontend/assets")
.as_posix(), # type: ignore
)
VERSION = get_package_version()
XSS_SAFE_MIMETYPES = {
Expand Down
3 changes: 1 addition & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ ffmpy
gradio_client==1.4.0-beta.1
httpx>=0.24.1
huggingface_hub>=0.19.3
importlib_resources>=1.3,<7.0
Jinja2<4.0
markupsafe~=2.0
numpy>=1.0,<3.0
Expand All @@ -19,7 +18,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.
urllib3~=2.0; sys.platform == 'emscripten' # 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>=0.12,<1.0; sys.platform != 'emscripten'
tomlkit==0.12.0
Expand Down

0 comments on commit 81a356d

Please sign in to comment.