diff --git a/HISTORY.rst b/HISTORY.rst index 09b76252..8adebc07 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -18,6 +18,7 @@ PlatformIO Core 5 - Fixed an issue when the package manager tries to install a built-in library from the registry (`issue #3662 `_) - Fixed an issue with incorrect value for C++ language standard in IDE projects when an in-progress language standard is used (`issue #3653 `_) - Fixed an issue with "Invalid simple block (semantic_version)" from library dependency that refs to an external source (repository, ZIP/Tar archives) (`issue #3658 `_) +- Fixed an issue when can not remove update or remove external dev-platform using PlatformIO Home (`issue #3663 `_) 5.0.0 (2020-09-03) ~~~~~~~~~~~~~~~~~~ diff --git a/platformio/package/meta.py b/platformio/package/meta.py index 147a1faf..edc5d0ff 100644 --- a/platformio/package/meta.py +++ b/platformio/package/meta.py @@ -209,6 +209,7 @@ class PackageSpec(object): # pylint: disable=too-many-instance-attributes raw = raw.strip() parsers = ( + self._parse_local_file, self._parse_requirements, self._parse_custom_name, self._parse_id, @@ -227,10 +228,16 @@ class PackageSpec(object): # pylint: disable=too-many-instance-attributes # the leftover is a package name self.name = raw - def _parse_requirements(self, raw): - if "@" not in raw: + @staticmethod + def _parse_local_file(raw): + if raw.startswith("file://") or not any(c in raw for c in ("/", "\\")): return raw - if raw.startswith("file://") and os.path.exists(raw[7:]): + if os.path.exists(raw): + return "file://%s" % raw + return raw + + def _parse_requirements(self, raw): + if "@" not in raw or raw.startswith("file://"): return raw tokens = raw.rsplit("@", 1) if any(s in tokens[1] for s in (":", "/")): diff --git a/tests/package/test_meta.py b/tests/package/test_meta.py index 0629f274..32b3d56a 100644 --- a/tests/package/test_meta.py +++ b/tests/package/test_meta.py @@ -90,12 +90,13 @@ def test_spec_local_urls(tmpdir_factory): assert PackageSpec("file:///tmp/some-lib/") == PackageSpec( url="file:///tmp/some-lib/", name="some-lib" ) - assert PackageSpec("file:///tmp/foo.tar.gz@~2.3.0-beta.1") == PackageSpec( - url="file:///tmp/foo.tar.gz", name="foo", requirements="~2.3.0-beta.1" + # detached package + assert PackageSpec("file:///tmp/some-lib@src-67e1043a673d2") == PackageSpec( + url="file:///tmp/some-lib@src-67e1043a673d2", name="some-lib" ) - # detached folder with "@" symbol + # detached folder without scheme pkg_dir = tmpdir_factory.mktemp("storage").join("detached@1.2.3").mkdir() - assert PackageSpec("file://%s" % str(pkg_dir)) == PackageSpec( + assert PackageSpec(str(pkg_dir)) == PackageSpec( name="detached", url="file://%s" % pkg_dir )