Skip to content

Commit

Permalink
Fixed an issue when can not remove update or remove external dev-plat…
Browse files Browse the repository at this point in the history
…form using PlatformIO Home // Resolve #3663
  • Loading branch information
ivankravets committed Sep 9, 2020
1 parent de2b5ea commit 6987d6c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
1 change: 1 addition & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://github.com/platformio/platformio-core/issues/3662>`_)
- 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>`_)
- 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>`_)
- Fixed an issue when can not remove update or remove external dev-platform using PlatformIO Home (`issue #3663 <https://github.com/platformio/platformio-core/issues/3663>`_)

5.0.0 (2020-09-03)
~~~~~~~~~~~~~~~~~~
Expand Down
13 changes: 10 additions & 3 deletions platformio/package/meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ def _parse(self, raw):
raw = raw.strip()

parsers = (
self._parse_local_file,
self._parse_requirements,
self._parse_custom_name,
self._parse_id,
Expand All @@ -227,10 +228,16 @@ def _parse(self, raw):
# 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 (":", "/")):
Expand Down
9 changes: 5 additions & 4 deletions tests/package/test_meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand Down

0 comments on commit 6987d6c

Please sign in to comment.