From 07beff3a26bfdcefb09f54d7f6564fbc72dfee27 Mon Sep 17 00:00:00 2001 From: Jon Date: Tue, 6 Oct 2020 10:40:44 -0700 Subject: [PATCH] Correct importlib_metadata python_version bounds (#828) * Correct importlib_metadata python_version bounds importlib_metadata is a backport of the python 3.8 stdlib library https://importlib-metadata.readthedocs.io/en/latest/ * Fix importlib_metadata import statement Co-authored by: @georgewhewell --- miio/__init__.py | 8 +++++++- pyproject.toml | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) 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 }