Skip to content

Commit

Permalink
Make netifaces optional dependency (#970)
Browse files Browse the repository at this point in the history
  • Loading branch information
rytilahti authored Mar 13, 2021
1 parent cf64f8f commit ab70c70
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 8 additions & 2 deletions miio/updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
from http.server import BaseHTTPRequestHandler, HTTPServer
from os.path import basename

import netifaces

_LOGGER = logging.getLogger(__name__)


Expand Down Expand Up @@ -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")
]
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit ab70c70

Please sign in to comment.