Skip to content

Commit 4f47ca5

Browse files
committed
Fixed an issue with "Invalid simple block (semantic_version)" from library dependency that refs to an external source (repository, ZIP/Tar archives) // Resolve platformio#3658
1 parent 54b51fc commit 4f47ca5

File tree

3 files changed

+46
-5
lines changed

3 files changed

+46
-5
lines changed

HISTORY.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ PlatformIO Core 5
1717
- Fixed an issue when `pio package unpublish <https://docs.platformio.org/page/core/userguide/package/cmd_unpublish.html>`__ command crashes (`issue #3660 <https://github.com/platformio/platformio-core/issues/3660>`_)
1818
- Fixed an issue when the package manager tries to install a built-in library from the registry (`issue #3662 <https://github.com/platformio/platformio-core/issues/3662>`_)
1919
- Fixed an issue with incorrect value for C++ language standard in IDE projects when an in-progress language standard is used (`issue #3653 <https://github.com/platformio/platformio-core/issues/3653>`_)
20+
- Fixed an issue with "Invalid simple block (semantic_version)" from library dependency that refs to an external source (repository, ZIP/Tar archives) (`issue #3658 <https://github.com/platformio/platformio-core/issues/3658>`_)
2021

2122
5.0.0 (2020-09-03)
2223
~~~~~~~~~~~~~~~~~~

platformio/package/manager/library.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,16 @@ def install_dependencies(self, pkg, silent=False):
109109
)
110110

111111
def _install_dependency(self, dependency, silent=False):
112-
spec = PackageSpec(
113-
owner=dependency.get("owner"),
114-
name=dependency.get("name"),
115-
requirements=dependency.get("version"),
116-
)
112+
if set(["name", "version"]) <= set(dependency.keys()) and any(
113+
c in dependency["version"] for c in (":", "/", "@")
114+
):
115+
spec = PackageSpec("%s=%s" % (dependency["name"], dependency["version"]))
116+
else:
117+
spec = PackageSpec(
118+
owner=dependency.get("owner"),
119+
name=dependency.get("name"),
120+
requirements=dependency.get("version"),
121+
)
117122
search_filters = {
118123
key: value
119124
for key, value in dependency.items()

tests/package/test_manager.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,41 @@ def test_install_from_registry(isolated_pio_core, tmpdir_factory):
230230
tm.install("owner/unknown-package-tool", silent=True)
231231

232232

233+
def test_install_lib_depndencies(isolated_pio_core, tmpdir_factory):
234+
tmp_dir = tmpdir_factory.mktemp("tmp")
235+
236+
src_dir = tmp_dir.join("lib-with-deps").mkdir()
237+
root_dir = src_dir.mkdir("root")
238+
root_dir.mkdir("src").join("main.cpp").write("#include <stdio.h>")
239+
root_dir.join("library.json").write(
240+
"""
241+
{
242+
"name": "lib-with-deps",
243+
"version": "2.0.0",
244+
"dependencies": [
245+
{
246+
"owner": "bblanchon",
247+
"name": "ArduinoJson",
248+
"version": "^6.16.1"
249+
},
250+
{
251+
"name": "external-repo",
252+
"version": "https://github.com/milesburton/Arduino-Temperature-Control-Library.git#4a0ccc1"
253+
}
254+
]
255+
}
256+
"""
257+
)
258+
259+
lm = LibraryPackageManager(str(tmpdir_factory.mktemp("lib-storage")))
260+
lm.install("file://%s" % str(src_dir), silent=True)
261+
installed = lm.get_installed()
262+
assert len(installed) == 4
263+
assert set(["external-repo", "ArduinoJson", "lib-with-deps", "OneWire"]) == set(
264+
p.metadata.name for p in installed
265+
)
266+
267+
233268
def test_install_force(isolated_pio_core, tmpdir_factory):
234269
lm = LibraryPackageManager(str(tmpdir_factory.mktemp("lib-storage")))
235270
# install #64 ArduinoJson

0 commit comments

Comments
 (0)