diff --git a/gradio/cli_env_info.py b/gradio/cli_env_info.py index c7ef83ade183b..7b73c93d648bc 100644 --- a/gradio/cli_env_info.py +++ b/gradio/cli_env_info.py @@ -3,27 +3,25 @@ """ import platform -import importlib.resources as pkg_resources - +from importlib.metadata import version, distribution, PackageNotFoundError def print_environment_info(): print("Gradio Environment Information:") - print("Operating System: ", platform.system()) print("\n") for package_name in ["gradio", "gradio_client"]: try: - package_dist = pkg_resources.get_distribution(package_name) - package_version = package_dist.version + package_version = version(package_name) print(f"{package_name} version: ", package_version) print(f"\n{package_name} Dependencies:") - for req in package_dist.requires(): - print( - f" {req.project_name}: {pkg_resources.get_distribution(req.project_name).version}" - ) - + dist = distribution(package_name) + for req in dist.requires: + try: + print(f" {req}: {version(req)}") + except PackageNotFoundError: + print(f"{req} is not installed.") print("\n") - except pkg_resources.DistributionNotFound: + except PackageNotFoundError: print(f"{package_name} package is not installed.") diff --git a/gradio/flagging.py b/gradio/flagging.py index 3777f9e269327..45d42b0d2e0b9 100644 --- a/gradio/flagging.py +++ b/gradio/flagging.py @@ -15,6 +15,7 @@ import filelock import huggingface_hub import importlib.resources as pkg_resources +from importlib.metadata import version from gradio_client import utils as client_utils from gradio_client.documentation import document, set_documentation_group @@ -242,7 +243,7 @@ def setup(self, components: list[IOComponent], flagging_dir: str): flagging_dir (str): local directory where the dataset is cloned, updated, and pushed from. """ - hh_version = pkg_resources.get_distribution("huggingface_hub").version + hh_version = version("huggingface_hub") try: if StrictVersion(hh_version) < StrictVersion("0.12.0"): raise ImportError( diff --git a/gradio/routes.py b/gradio/routes.py index 96f2fbf32e21e..7cf57dee09e59 100644 --- a/gradio/routes.py +++ b/gradio/routes.py @@ -52,9 +52,9 @@ mimetypes.init() -STATIC_TEMPLATE_LIB = pkg_resources.path("gradio", "templates/") -STATIC_PATH_LIB = pkg_resources.path("gradio", "templates/frontend/static") -BUILD_PATH_LIB = pkg_resources.path("gradio", "templates/frontend/assets") +STATIC_TEMPLATE_LIB = pkg_resources.path("gradio", "templates") +STATIC_PATH_LIB = pkg_resources.path("gradio", "templates.frontend.static") +BUILD_PATH_LIB = pkg_resources.path("gradio", "templates.frontend.assets") VERSION_FILE = pkg_resources.path("gradio", "version.txt") with open(VERSION_FILE) as version_file: VERSION = version_file.read()