mirror of
https://github.com/platformio/platformio-core.git
synced 2025-07-30 01:57:13 +02:00
Avoid RecursionError for circular_dependencies // Resolve #4228
This commit is contained in:
@ -76,6 +76,9 @@ class PackageManagerInstallMixin(object):
|
|||||||
pkg = None
|
pkg = None
|
||||||
|
|
||||||
if pkg:
|
if pkg:
|
||||||
|
# avoid RecursionError for circular_dependencies
|
||||||
|
self._INSTALL_HISTORY[spec] = pkg
|
||||||
|
|
||||||
self.log.debug(
|
self.log.debug(
|
||||||
click.style(
|
click.style(
|
||||||
"{name}@{version} is already installed".format(
|
"{name}@{version} is already installed".format(
|
||||||
@ -112,9 +115,12 @@ class PackageManagerInstallMixin(object):
|
|||||||
)
|
)
|
||||||
|
|
||||||
self.memcache_reset()
|
self.memcache_reset()
|
||||||
|
# avoid RecursionError for circular_dependencies
|
||||||
|
self._INSTALL_HISTORY[spec] = pkg
|
||||||
|
|
||||||
if not skip_dependencies:
|
if not skip_dependencies:
|
||||||
self.install_dependencies(pkg)
|
self.install_dependencies(pkg)
|
||||||
self._INSTALL_HISTORY[spec] = pkg
|
|
||||||
return pkg
|
return pkg
|
||||||
|
|
||||||
def install_dependencies(self, pkg, print_header=True):
|
def install_dependencies(self, pkg, print_header=True):
|
||||||
|
@ -386,6 +386,59 @@ if action == "preuninstall":
|
|||||||
(storage_dir / "preuninstall.flag").is_file()
|
(storage_dir / "preuninstall.flag").is_file()
|
||||||
|
|
||||||
|
|
||||||
|
def test_install_circular_dependencies(tmp_path: Path):
|
||||||
|
storage_dir = tmp_path / "storage"
|
||||||
|
# Foo
|
||||||
|
pkg_dir = storage_dir / "foo"
|
||||||
|
pkg_dir.mkdir(parents=True)
|
||||||
|
(pkg_dir / "library.json").write_text(
|
||||||
|
"""
|
||||||
|
{
|
||||||
|
"name": "Foo",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"dependencies": {
|
||||||
|
"Bar": "*"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
# Bar
|
||||||
|
pkg_dir = storage_dir / "bar"
|
||||||
|
pkg_dir.mkdir(parents=True)
|
||||||
|
(pkg_dir / "library.json").write_text(
|
||||||
|
"""
|
||||||
|
{
|
||||||
|
"name": "Bar",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"dependencies": {
|
||||||
|
"Foo": "*"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
|
||||||
|
lm = LibraryPackageManager(str(storage_dir))
|
||||||
|
lm.set_log_level(logging.ERROR)
|
||||||
|
assert len(lm.get_installed()) == 2
|
||||||
|
|
||||||
|
# root library
|
||||||
|
pkg_dir = tmp_path / "root"
|
||||||
|
pkg_dir.mkdir(parents=True)
|
||||||
|
(pkg_dir / "library.json").write_text(
|
||||||
|
"""
|
||||||
|
{
|
||||||
|
"name": "Root",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"dependencies": {
|
||||||
|
"Foo": "^1.0.0",
|
||||||
|
"Bar": "^1.0.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
lm.install("file://%s" % str(pkg_dir))
|
||||||
|
|
||||||
|
|
||||||
def test_get_installed(isolated_pio_core, tmpdir_factory):
|
def test_get_installed(isolated_pio_core, tmpdir_factory):
|
||||||
storage_dir = tmpdir_factory.mktemp("storage")
|
storage_dir = tmpdir_factory.mktemp("storage")
|
||||||
pm = ToolPackageManager(str(storage_dir))
|
pm = ToolPackageManager(str(storage_dir))
|
||||||
|
Reference in New Issue
Block a user