diff --git a/HISTORY.rst b/HISTORY.rst index a9c95e12..7401f2d6 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -19,6 +19,7 @@ PlatformIO Core 5 * `pio pkg exec `_ - run command from package tool (`issue #4163 `_) * Improved PIO Remote setup on credit-card sized computers (Raspberry Pi, BeagleBon, etc) (`issue #3865 `_) +* Dropped automatic updates of global libraries and development platforms (`issue #4179 `_) 5.2.5 (2022-02-10) ~~~~~~~~~~~~~~~~~~ diff --git a/docs b/docs index 282a9970..5a4ab6ac 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit 282a997075c0cea4adc9ca09427d953f1293031e +Subproject commit 5a4ab6acb49ee3b118e1d3aa25fb540ba0b1defb diff --git a/platformio/app.py b/platformio/app.py index 6c152c17..26b4c80b 100644 --- a/platformio/app.py +++ b/platformio/app.py @@ -35,24 +35,8 @@ def projects_dir_validate(projects_dir): DEFAULT_SETTINGS = { - "auto_update_libraries": { - "description": "Automatically update libraries (Yes/No)", - "value": False, - }, - "auto_update_platforms": { - "description": "Automatically update platforms (Yes/No)", - "value": False, - }, - "check_libraries_interval": { - "description": "Check for the library updates interval (days)", - "value": 7, - }, "check_platformio_interval": { - "description": "Check for the new PlatformIO interval (days)", - "value": 3, - }, - "check_platforms_interval": { - "description": "Check for the platform updates interval (days)", + "description": "Check for the new PlatformIO Core interval (days)", "value": 7, }, "check_prune_system_threshold": { diff --git a/platformio/maintenance.py b/platformio/maintenance.py index c08a88d6..b1e0582b 100644 --- a/platformio/maintenance.py +++ b/platformio/maintenance.py @@ -23,18 +23,13 @@ from platformio import __version__, app, exception, fs, telemetry from platformio.cache import cleanup_content_cache from platformio.clients import http from platformio.commands import PlatformioCLI -from platformio.commands.lib.command import CTX_META_STORAGE_DIRS_KEY -from platformio.commands.lib.command import lib_update as cmd_lib_update from platformio.commands.platform import platform_update as cmd_platform_update from platformio.commands.system.prune import calculate_unnecessary_system_data from platformio.commands.upgrade import get_latest_version from platformio.package.manager.core import update_core_packages -from platformio.package.manager.library import LibraryPackageManager -from platformio.package.manager.platform import PlatformPackageManager from platformio.package.manager.tool import ToolPackageManager from platformio.package.meta import PackageSpec from platformio.package.version import pepver_to_semver -from platformio.platform.factory import PlatformFactory def on_platformio_start(ctx, force, caller): @@ -54,8 +49,6 @@ def on_platformio_end(ctx, result): # pylint: disable=unused-argument try: check_platformio_upgrade() - check_internal_updates(ctx, "platforms") - check_internal_updates(ctx, "libraries") check_prune_system() except ( http.HTTPClientError, @@ -212,17 +205,20 @@ def after_upgrade(ctx): def check_platformio_upgrade(): - last_check = app.get_state_item("last_check", {}) interval = int(app.get_setting("check_platformio_interval")) * 3600 * 24 - if (time() - interval) < last_check.get("platformio_upgrade", 0): + check_state = app.get_state_item("last_check", {}) + last_checked_time = check_state.get("platformio_upgrade", 0) + if (time() - interval) < last_checked_time: return - last_check["platformio_upgrade"] = int(time()) - app.set_state_item("last_check", last_check) + check_state["platformio_upgrade"] = int(time()) + app.set_state_item("last_check", check_state) + if not last_checked_time: + return http.ensure_internet_on(raise_exception=True) - # Update PlatformIO's Core packages + # Update PlatformIO Core packages update_core_packages(silent=True) latest_version = get_latest_version() @@ -239,10 +235,7 @@ def check_platformio_upgrade(): fg="yellow", nl=False, ) - if os.getenv("PLATFORMIO_IDE"): - click.secho("PlatformIO IDE Menu: Upgrade PlatformIO", fg="cyan", nl=False) - click.secho("`.", fg="yellow") - elif os.path.join("Cellar", "platformio") in fs.get_source_dir(): + if os.path.join("Cellar", "platformio") in fs.get_source_dir(): click.secho("brew update && brew upgrade", fg="cyan", nl=False) click.secho("` command.", fg="yellow") else: @@ -256,86 +249,19 @@ def check_platformio_upgrade(): click.echo("") -def check_internal_updates(ctx, what): # pylint: disable=too-many-branches - last_check = app.get_state_item("last_check", {}) - interval = int(app.get_setting("check_%s_interval" % what)) * 3600 * 24 - if (time() - interval) < last_check.get(what + "_update", 0): - return - - last_check[what + "_update"] = int(time()) - app.set_state_item("last_check", last_check) - - http.ensure_internet_on(raise_exception=True) - - outdated_items = [] - pm = PlatformPackageManager() if what == "platforms" else LibraryPackageManager() - for pkg in pm.get_installed(): - if pkg.metadata.name in outdated_items: - continue - conds = [ - pm.outdated(pkg).is_outdated(), - what == "platforms" and PlatformFactory.new(pkg).are_outdated_packages(), - ] - if any(conds): - outdated_items.append(pkg.metadata.name) - - if not outdated_items: - return - - terminal_width, _ = shutil.get_terminal_size() - - click.echo("") - click.echo("*" * terminal_width) - click.secho( - "There are the new updates for %s (%s)" % (what, ", ".join(outdated_items)), - fg="yellow", - ) - - if not app.get_setting("auto_update_" + what): - click.secho("Please update them via ", fg="yellow", nl=False) - click.secho( - "`platformio %s update`" - % ("lib --global" if what == "libraries" else "platform"), - fg="cyan", - nl=False, - ) - click.secho(" command.\n", fg="yellow") - click.secho( - "If you want to manually check for the new versions " - "without updating, please use ", - fg="yellow", - nl=False, - ) - click.secho( - "`platformio %s update --dry-run`" - % ("lib --global" if what == "libraries" else "platform"), - fg="cyan", - nl=False, - ) - click.secho(" command.", fg="yellow") - else: - click.secho("Please wait while updating %s ..." % what, fg="yellow") - if what == "platforms": - ctx.invoke(cmd_platform_update, platforms=outdated_items) - elif what == "libraries": - ctx.meta[CTX_META_STORAGE_DIRS_KEY] = [pm.package_dir] - ctx.invoke(cmd_lib_update, libraries=outdated_items) - click.echo() - - telemetry.send_event(category="Auto", action="Update", label=what.title()) - - click.echo("*" * terminal_width) - click.echo("") - - def check_prune_system(): - last_check = app.get_state_item("last_check", {}) interval = 30 * 3600 * 24 # 1 time per month - if (time() - interval) < last_check.get("prune_system", time()): + check_state = app.get_state_item("last_check", {}) + last_checked_time = check_state.get("prune_system", 0) + if (time() - interval) < last_checked_time: + return + + check_state["prune_system"] = int(time()) + app.set_state_item("last_check", check_state) + + if not last_checked_time: return - last_check["prune_system"] = int(time()) - app.set_state_item("last_check", last_check) threshold_mb = int(app.get_setting("check_prune_system_threshold") or 0) if threshold_mb <= 0: return