From 743a43ae17a0657719a6b188c2b5e0aa4af8e5f6 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Thu, 29 Oct 2020 23:17:47 +0200 Subject: [PATCH] Fixed an issue when multiple `pio lib install` command with the same local library results in duplicates in ``lib_deps`` // Resolve #3715 --- HISTORY.rst | 7 ++++--- platformio/commands/lib/helpers.py | 17 ++++++++++++----- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 7d498c78..d239b46e 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -11,14 +11,15 @@ PlatformIO Core 5 5.0.2 (2020-09-??) ~~~~~~~~~~~~~~~~~~ -- Initialize a new project or update existing passing working environment name and its options (`issue #3686 `_) +- Initialize a new project or update the existing passing working environment name and its options (`issue #3686 `_) - Automatically build PlatformIO Core extra Python dependencies on a host machine if they are missed in the registry (`issue #3700 `_) - Improved "core.call" RPC for PlatformIO Home (`issue #3671 `_) -- Fixed a "PermissionError: [WinError 5]" on Windows when external repository is used with `lib_deps `__ option (`issue #3664 `_) +- Fixed a "PermissionError: [WinError 5]" on Windows when an external repository is used with `lib_deps `__ option (`issue #3664 `_) - Fixed a "KeyError: 'versions'" when dependency does not exist in the registry (`issue #3666 `_) - Fixed an issue with GCC linker when "native" dev-platform is used in pair with library dependencies (`issue #3669 `_) - Fixed an "AssertionError: ensure_dir_exists" when checking library updates from simultaneous subprocesses (`issue #3677 `_) -- Fixed an issue when "pio package publish" command removes original archive after submitting to the registry `issue #3716 `_) +- Fixed an issue when `pio package publish `__ command removes original archive after submitting to the registry (`issue #3716 `_) +- Fixed an issue when multiple `pio lib install `__ command with the same local library results in duplicates in ``lib_deps`` (`issue #3715 `_) 5.0.1 (2020-09-10) ~~~~~~~~~~~~~~~~~~ diff --git a/platformio/commands/lib/helpers.py b/platformio/commands/lib/helpers.py index 732604a3..c720b10d 100644 --- a/platformio/commands/lib/helpers.py +++ b/platformio/commands/lib/helpers.py @@ -81,15 +81,22 @@ def save_project_libdeps(project_dir, specs, environments=None, action="add"): if environments and env not in environments: continue config.expand_interpolations = False - lib_deps = [] + candidates = [] try: - lib_deps = ignore_deps_by_specs(config.get("env:" + env, "lib_deps"), specs) + candidates = ignore_deps_by_specs( + config.get("env:" + env, "lib_deps"), specs + ) except InvalidProjectConfError: pass if action == "add": - lib_deps.extend(spec.as_dependency() for spec in specs) - if lib_deps: - config.set("env:" + env, "lib_deps", lib_deps) + candidates.extend(spec.as_dependency() for spec in specs) + if candidates: + result = [] + for item in candidates: + item = item.strip() + if item and item not in result: + result.append(item) + config.set("env:" + env, "lib_deps", result) elif config.has_option("env:" + env, "lib_deps"): config.remove_option("env:" + env, "lib_deps") config.save()