From 20067c5736d45911670df10d32d853566949fbff Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 13 Jan 2023 19:09:19 +0200 Subject: [PATCH] Removed dependency on the "zeroconf" package and install it only when a user lists mDNS devices (issue with zeroconf's LGPL license) --- HISTORY.rst | 2 +- platformio/device/list/util.py | 10 +++++++++- setup.py | 1 - 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index c36c40b4..16b8a6a1 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -18,8 +18,8 @@ PlatformIO Core 6 * Added support for Python 3.11 * Made assets (templates, ``99-platformio-udev.rules``) part of Python's module (`issue #4458 `_) -* Import the "zeroconf" module only when a user lists mDNS devices (issue with zeroconf's LGPL license) * Updated `Clang-Tidy `__ check tool to v15.0.5 with new diagnostics and bugfixes +* Removed dependency on the "zeroconf" package and install it only when a user lists mDNS devices (issue with zeroconf's LGPL license) 6.1.5 (2022-11-01) ~~~~~~~~~~~~~~~~~~ diff --git a/platformio/device/list/util.py b/platformio/device/list/util.py index 94443f4f..3589ee26 100644 --- a/platformio/device/list/util.py +++ b/platformio/device/list/util.py @@ -82,7 +82,15 @@ def list_logical_devices(): def list_mdns_services(): - import zeroconf # pylint: disable=import-outside-toplevel + try: + import zeroconf # pylint: disable=import-outside-toplevel + except ImportError: + result = proc.exec_command( + [proc.get_pythonexe_path(), "-m", "pip", "install", "zeroconf"] + ) + if result.get("returncode") != 0: + print(result.get("err")) + import zeroconf # pylint: disable=import-outside-toplevel class mDNSListener: def __init__(self): diff --git a/setup.py b/setup.py index fbed0e1d..2e1fa86c 100644 --- a/setup.py +++ b/setup.py @@ -39,7 +39,6 @@ minimal_requirements = [ "requests==%s" % ("2.27.1" if PY36 else "2.*"), "semantic_version==2.10.*", "tabulate==%s" % ("0.8.10" if PY36 else "0.9.*"), - "zeroconf<1", ] home_requirements = [