mirror of
https://github.com/platformio/platformio-core.git
synced 2025-07-29 17:47:14 +02:00
Fixed an issue when the package manager tries to install a built-in library from the registry // Resolve #3662
This commit is contained in:
@ -15,6 +15,7 @@ PlatformIO Core 5
|
||||
- Fixed an issue when using a custom git/ssh package with `platform_packages <https://docs.platformio.org/page/projectconf/section_env_platform.html#platform-packages>`__ option (`issue #3624 <https://github.com/platformio/platformio-core/issues/3624>`_)
|
||||
- Fixed an issue with "ImportError: cannot import name '_get_backend' from 'cryptography.hazmat.backends'" when using `Remote Development <https://docs.platformio.org/page/plus/pio-remote.html>`__ on RaspberryPi device (`issue #3652 <https://github.com/platformio/platformio-core/issues/3652>`_)
|
||||
- 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>`_)
|
||||
- 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>`_)
|
||||
|
||||
5.0.0 (2020-09-03)
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
|
@ -22,11 +22,7 @@ from tabulate import tabulate
|
||||
|
||||
from platformio import exception, fs, util
|
||||
from platformio.commands import PlatformioCLI
|
||||
from platformio.commands.lib.helpers import (
|
||||
get_builtin_libs,
|
||||
is_builtin_lib,
|
||||
save_project_libdeps,
|
||||
)
|
||||
from platformio.commands.lib.helpers import get_builtin_libs, save_project_libdeps
|
||||
from platformio.compat import dump_json_to_unicode
|
||||
from platformio.package.exception import NotGlobalLibDir, UnknownPackageError
|
||||
from platformio.package.manager.library import LibraryPackageManager
|
||||
@ -164,15 +160,8 @@ def lib_install( # pylint: disable=too-many-arguments,unused-argument
|
||||
}
|
||||
|
||||
elif storage_dir in storage_libdeps:
|
||||
builtin_lib_storages = None
|
||||
for library in storage_libdeps[storage_dir]:
|
||||
try:
|
||||
lm.install(library, silent=silent, force=force)
|
||||
except UnknownPackageError as e:
|
||||
if builtin_lib_storages is None:
|
||||
builtin_lib_storages = get_builtin_libs()
|
||||
if not silent or not is_builtin_lib(builtin_lib_storages, library):
|
||||
click.secho("Warning! %s" % e, fg="yellow")
|
||||
lm.install(library, silent=silent, force=force)
|
||||
|
||||
if save and installed_pkgs:
|
||||
_save_deps(ctx, installed_pkgs)
|
||||
|
@ -45,10 +45,11 @@ def get_builtin_libs(storage_names=None):
|
||||
return items
|
||||
|
||||
|
||||
def is_builtin_lib(storages, name):
|
||||
for storage in storages or []:
|
||||
if any(lib.get("name") == name for lib in storage["items"]):
|
||||
return True
|
||||
def is_builtin_lib(name, storages=None):
|
||||
for storage in storages or get_builtin_libs():
|
||||
for lib in storage["items"]:
|
||||
if lib.get("name") == name:
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
|
@ -15,7 +15,10 @@
|
||||
import json
|
||||
import os
|
||||
|
||||
from platformio.package.exception import MissingPackageManifestError
|
||||
from platformio.package.exception import (
|
||||
MissingPackageManifestError,
|
||||
UnknownPackageError,
|
||||
)
|
||||
from platformio.package.manager.base import BasePackageManager
|
||||
from platformio.package.meta import PackageItem, PackageSpec, PackageType
|
||||
from platformio.project.helpers import get_project_global_lib_dir
|
||||
@ -63,6 +66,33 @@ class LibraryPackageManager(BasePackageManager): # pylint: disable=too-many-anc
|
||||
return root
|
||||
return path
|
||||
|
||||
def _install( # pylint: disable=too-many-arguments
|
||||
self,
|
||||
spec,
|
||||
search_filters=None,
|
||||
silent=False,
|
||||
skip_dependencies=False,
|
||||
force=False,
|
||||
):
|
||||
try:
|
||||
return super(LibraryPackageManager, self)._install(
|
||||
spec,
|
||||
search_filters=search_filters,
|
||||
silent=silent,
|
||||
skip_dependencies=skip_dependencies,
|
||||
force=force,
|
||||
)
|
||||
except UnknownPackageError as e:
|
||||
# pylint: disable=import-outside-toplevel
|
||||
from platformio.commands.lib.helpers import is_builtin_lib
|
||||
|
||||
spec = self.ensure_spec(spec)
|
||||
if is_builtin_lib(spec.name):
|
||||
self.print_message("Already installed, built-in library", fg="yellow")
|
||||
return True
|
||||
|
||||
raise e
|
||||
|
||||
def install_dependencies(self, pkg, silent=False):
|
||||
assert isinstance(pkg, PackageItem)
|
||||
manifest = self.load_manifest(pkg)
|
||||
|
Reference in New Issue
Block a user