From ce4c45a0751e3904dd84b21afac717d13a49d62d Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sat, 26 Dec 2020 16:10:07 +0200 Subject: [PATCH] Show a warning message about deprecated support for Python 2 and Python 3.5 --- HISTORY.rst | 4 +++- docs | 2 +- examples | 2 +- platformio/compat.py | 7 ++++--- platformio/maintenance.py | 22 ++++++++++++++++++++-- 5 files changed, 29 insertions(+), 8 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index a28485d7..e1073378 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -16,6 +16,7 @@ PlatformIO Core 5 - Updated analysis tools: * `Cppcheck `__ v2.3 with improved C++ parser and several new MISRA rules * `PVS-Studio `__ v7.11 with new diagnostics and updated mass suppression mechanism +- Show a warning message about deprecated support for Python 2 and Python 3.5 - Do not provide "intelliSenseMode" option when generating configuration for VSCode C/C++ extension - Fixed a "git-sh-setup: file not found" error when installing project dependencies from Git VCS (`issue #3740 `_) @@ -139,7 +140,8 @@ Please check `Migration guide from 4.x to 5.0 `__ command (`issue #3521 `_) - Remove unused data using a new `pio system prune `__ command (`issue #3522 `_) - Show ignored project environments only in the verbose mode (`issue #3641 `_) - - Do not escape compiler arguments in VSCode template on Windows. + - Do not escape compiler arguments in VSCode template on Windows + - Drop support for Python 2 and 3.5. .. _release_notes_4: diff --git a/docs b/docs index 164a38d3..af6575ed 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit 164a38d3e1ef43eaa0925f3290da2f7e54482f86 +Subproject commit af6575ed9054a9203d63f124007b6a69e2895145 diff --git a/examples b/examples index 9ab96212..1ca5e8db 160000 --- a/examples +++ b/examples @@ -1 +1 @@ -Subproject commit 9ab9621241a8147d1bf96ca31f697d74b85fe5e2 +Subproject commit 1ca5e8db4bf9615f44ae8a846954961658e912d3 diff --git a/platformio/compat.py b/platformio/compat.py index 1ef2883b..974bdf2f 100644 --- a/platformio/compat.py +++ b/platformio/compat.py @@ -62,10 +62,11 @@ def ci_strings_are_equal(a, b): def ensure_python3(raise_exception=True): - if not raise_exception or not PY2: - return not PY2 + compatible = sys.version_info >= (3, 6) + if not raise_exception or compatible: + return compatible raise UserSideException( - "Python 3.5 or later is required for this operation. \n" + "Python 3.6 or later is required for this operation. \n" "Please install the latest Python 3 and reinstall PlatformIO Core using " "installation script:\n" "https://docs.platformio.org/page/core/installation.html" diff --git a/platformio/maintenance.py b/platformio/maintenance.py index 63674ad7..9d2f8245 100644 --- a/platformio/maintenance.py +++ b/platformio/maintenance.py @@ -27,6 +27,7 @@ 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.upgrade import get_latest_version +from platformio.compat import ensure_python3 from platformio.package.manager.core import update_core_packages from platformio.package.manager.library import LibraryPackageManager from platformio.package.manager.platform import PlatformPackageManager @@ -43,8 +44,25 @@ def on_platformio_start(ctx, force, caller): set_caller(caller) telemetry.on_command() - if not PlatformioCLI.in_silence(): - after_upgrade(ctx) + if PlatformioCLI.in_silence(): + return + + after_upgrade(ctx) + + if not ensure_python3(raise_exception=False): + click.secho( + """ +Python 2 and Python 3.5 are not compatible with PlatformIO Core 5.0. +Please check the migration guide on how to fix this warning message: +""", + fg="yellow", + ) + click.secho( + "https://docs.platformio.org/en/latest/core/migration.html" + "#drop-support-for-python-2-and-3-5", + fg="blue", + ) + click.echo("") def on_platformio_end(ctx, result): # pylint: disable=unused-argument