Skip to content

Commit 6987d6c

Browse files
committed
Fixed an issue when can not remove update or remove external dev-platform using PlatformIO Home // Resolve platformio#3663
1 parent de2b5ea commit 6987d6c

File tree

3 files changed

+16
-7
lines changed

3 files changed

+16
-7
lines changed

HISTORY.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ PlatformIO Core 5
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>`_)
2020
- 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>`_)
21+
- 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>`_)
2122

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

platformio/package/meta.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ def _parse(self, raw):
209209
raw = raw.strip()
210210

211211
parsers = (
212+
self._parse_local_file,
212213
self._parse_requirements,
213214
self._parse_custom_name,
214215
self._parse_id,
@@ -227,10 +228,16 @@ def _parse(self, raw):
227228
# the leftover is a package name
228229
self.name = raw
229230

230-
def _parse_requirements(self, raw):
231-
if "@" not in raw:
231+
@staticmethod
232+
def _parse_local_file(raw):
233+
if raw.startswith("file://") or not any(c in raw for c in ("/", "\\")):
232234
return raw
233-
if raw.startswith("file://") and os.path.exists(raw[7:]):
235+
if os.path.exists(raw):
236+
return "file://%s" % raw
237+
return raw
238+
239+
def _parse_requirements(self, raw):
240+
if "@" not in raw or raw.startswith("file://"):
234241
return raw
235242
tokens = raw.rsplit("@", 1)
236243
if any(s in tokens[1] for s in (":", "/")):

tests/package/test_meta.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,13 @@ def test_spec_local_urls(tmpdir_factory):
9090
assert PackageSpec("file:///tmp/some-lib/") == PackageSpec(
9191
url="file:///tmp/some-lib/", name="some-lib"
9292
)
93-
assert PackageSpec("file:///tmp/foo.tar.gz@~2.3.0-beta.1") == PackageSpec(
94-
url="file:///tmp/foo.tar.gz", name="foo", requirements="~2.3.0-beta.1"
93+
# detached package
94+
assert PackageSpec("file:///tmp/some-lib@src-67e1043a673d2") == PackageSpec(
95+
url="file:///tmp/some-lib@src-67e1043a673d2", name="some-lib"
9596
)
96-
# detached folder with "@" symbol
97+
# detached folder without scheme
9798
pkg_dir = tmpdir_factory.mktemp("storage").join("detached@1.2.3").mkdir()
98-
assert PackageSpec("file://%s" % str(pkg_dir)) == PackageSpec(
99+
assert PackageSpec(str(pkg_dir)) == PackageSpec(
99100
name="detached", url="file://%s" % pkg_dir
100101
)
101102

0 commit comments

Comments
 (0)