diff --git a/gradio/__init__.py b/gradio/__init__.py index 03a9072774..3f3783ac56 100644 --- a/gradio/__init__.py +++ b/gradio/__init__.py @@ -67,5 +67,5 @@ from gradio.templates import ( Webcam, ) -current_pkg_version = pkgutil.get_data(__name__, "version.txt").decode('ascii').strip() +current_pkg_version = pkgutil.get_data(__name__, "version.txt").decode("ascii").strip() __version__ = current_pkg_version diff --git a/gradio/utils.py b/gradio/utils.py index 50477d16fe..b22040fb1b 100644 --- a/gradio/utils.py +++ b/gradio/utils.py @@ -7,6 +7,7 @@ import inspect import json import json.decoder import os +import pkgutil import random import sys import warnings @@ -38,7 +39,9 @@ JSON_PATH = os.path.join(os.path.dirname(gradio.__file__), "launches.json") def version_check(): try: - current_pkg_version = pkg_resources.require("gradio")[0].version + current_pkg_version = ( + pkgutil.get_data(__name__, "version.txt").decode("ascii").strip() + ) latest_pkg_version = requests.get(url=PKG_VERSION_URL).json()["version"] if StrictVersion(latest_pkg_version) > StrictVersion(current_pkg_version): print( @@ -49,10 +52,6 @@ def version_check(): ) ) print("--------") - except pkg_resources.DistributionNotFound: - warnings.warn( - "gradio is not setup or installed properly. Unable to get version info." - ) except json.decoder.JSONDecodeError: warnings.warn("unable to parse version details from package URL.") except KeyError: diff --git a/test/test_utils.py b/test/test_utils.py index c9de3a21ca..0103028103 100644 --- a/test/test_utils.py +++ b/test/test_utils.py @@ -37,18 +37,6 @@ os.environ["GRADIO_ANALYTICS_ENABLED"] = "False" class TestUtils(unittest.TestCase): - @mock.patch("pkg_resources.require") - def test_should_fail_with_distribution_not_found(self, mock_require): - mock_require.side_effect = pkg_resources.DistributionNotFound() - - with warnings.catch_warnings(record=True) as w: - warnings.simplefilter("always") - version_check() - self.assertEqual( - str(w[-1].message), - "gradio is not setup or installed properly. Unable to get version info.", - ) - @mock.patch("requests.get") def test_should_warn_with_unable_to_parse(self, mock_get): mock_get.side_effect = json.decoder.JSONDecodeError("Expecting value", "", 0)