From ab70c702560beb17dc35215818297c6181210c2f Mon Sep 17 00:00:00 2001 From: Teemu R Date: Sat, 13 Mar 2021 17:21:09 +0100 Subject: [PATCH] Make netifaces optional dependency (#970) --- miio/updater.py | 10 ++++++++-- pyproject.toml | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/miio/updater.py b/miio/updater.py index 1ea89807e..a03a0c020 100644 --- a/miio/updater.py +++ b/miio/updater.py @@ -3,8 +3,6 @@ from http.server import BaseHTTPRequestHandler, HTTPServer from os.path import basename -import netifaces - _LOGGER = logging.getLogger(__name__) @@ -60,6 +58,14 @@ def __init__(self, file, interface=None): @staticmethod def find_local_ip(): + try: + import netifaces + except Exception: + _LOGGER.error( + "Unable to import netifaces, please install netifaces library" + ) + raise + ifaces_without_lo = [ x for x in netifaces.interfaces() if not x.startswith("lo") ] diff --git a/pyproject.toml b/pyproject.toml index 62714e61b..c01cc8e9b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -30,7 +30,7 @@ attrs = "*" pytz = "*" appdirs = "^1" tqdm = "^4" -netifaces = "^0" +netifaces = { version = "^0", optional = true } android_backup = { version = "^0", optional = true } importlib_metadata = { version = "^1", markers = "python_version <= '3.7'" } croniter = "^0"