diff --git a/miio/__init__.py b/miio/__init__.py index 1ebd422cc..796eee41d 100644 --- a/miio/__init__.py +++ b/miio/__init__.py @@ -1,5 +1,11 @@ # flake8: noqa -from importlib_metadata import version # type: ignore +try: + # python 3.7 and earlier + from importlib_metadata import version # type: ignore +except ImportError: + # python 3.8 and later + from importlib.metadata import version # type: ignore + from miio.airconditioningcompanion import ( AirConditioningCompanion, AirConditioningCompanionV3, diff --git a/pyproject.toml b/pyproject.toml index 716bd2a50..6f82a91f2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -32,7 +32,7 @@ appdirs = "^1" tqdm = "^4" netifaces = "^0" android_backup = { version = "^0", optional = true } -importlib_metadata = "^1" +importlib_metadata = { version = "^1", markers = "python_version <= '3.7'" } croniter = "^0" sphinx = { version = "^3", optional = true }