From d0d7c53ee10af621d94b406866469870c98c9d17 Mon Sep 17 00:00:00 2001 From: "martin.gano" Date: Wed, 4 Nov 2020 23:32:40 +0100 Subject: [PATCH] Tools: add Python 2 deprecation warning --- components/app_update/otatool.py | 4 +++ components/efuse/efuse_table_gen.py | 4 +++ components/spiffs/spiffsgen.py | 7 +++- components/ulp/esp32ulp_mapgen.py | 6 ++++ components/xtensa/trax/traceparse.py | 6 +++- docs/en/get-started/linux-setup-scratch.rst | 17 +++++++--- docs/en/get-started/linux-setup.rst | 37 ++++++++++++++++++--- docs/en/get-started/macos-setup-scratch.rst | 4 +++ docs/en/get-started/macos-setup.rst | 5 +++ tools/ci/check_build_warnings.py | 2 ++ tools/ci/config/build.yml | 3 ++ tools/idf.py | 6 ++++ 12 files changed, 90 insertions(+), 11 deletions(-) diff --git a/components/app_update/otatool.py b/components/app_update/otatool.py index 20f69fa923..86c630f5af 100755 --- a/components/app_update/otatool.py +++ b/components/app_update/otatool.py @@ -249,6 +249,10 @@ def _erase_ota_partition(target, ota_id): def main(): + if sys.version_info[0] < 3: + print("WARNING: Support for Python 2 is deprecated and will be removed in future versions.") + elif sys.version_info[0] == 3 and sys.version_info[1] < 6: + print("WARNING: Python 3 versions older than 3.6 are not supported.") global quiet parser = argparse.ArgumentParser("ESP-IDF OTA Partitions Tool") diff --git a/components/efuse/efuse_table_gen.py b/components/efuse/efuse_table_gen.py index 6fcc35a470..c729fdebf6 100755 --- a/components/efuse/efuse_table_gen.py +++ b/components/efuse/efuse_table_gen.py @@ -458,6 +458,10 @@ def create_output_files(name, output_table, debug): def main(): + if sys.version_info[0] < 3: + print("WARNING: Support for Python 2 is deprecated and will be removed in future versions.", file=sys.stderr) + elif sys.version_info[0] == 3 and sys.version_info[1] < 6: + print("WARNING: Python 3 versions older than 3.6 are not supported.", file=sys.stderr) global quiet global max_blk_len global idf_target diff --git a/components/spiffs/spiffsgen.py b/components/spiffs/spiffsgen.py index fc22d1b36b..3314e93f0e 100755 --- a/components/spiffs/spiffsgen.py +++ b/components/spiffs/spiffsgen.py @@ -16,8 +16,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -from __future__ import division +from __future__ import division, print_function import os +import sys import io import math import struct @@ -451,6 +452,10 @@ class SpiffsFS(): def main(): + if sys.version_info[0] < 3: + print("WARNING: Support for Python 2 is deprecated and will be removed in future versions.") + elif sys.version_info[0] == 3 and sys.version_info[1] < 6: + print("WARNING: Python 3 versions older than 3.6 are not supported.") parser = argparse.ArgumentParser(description="SPIFFS Image Generator", formatter_class=argparse.ArgumentDefaultsHelpFormatter) diff --git a/components/ulp/esp32ulp_mapgen.py b/components/ulp/esp32ulp_mapgen.py index 52ad8a5f09..c40e137404 100755 --- a/components/ulp/esp32ulp_mapgen.py +++ b/components/ulp/esp32ulp_mapgen.py @@ -5,7 +5,9 @@ # Copyright (c) 2016-2017 Espressif Systems (Shanghai) PTE LTD. # Distributed under the terms of Apache License v2.0 found in the top-level LICENSE file. +from __future__ import print_function from optparse import OptionParser +import sys BASE_ADDR = 0x50000000 @@ -26,6 +28,10 @@ def gen_ld_h_from_sym(f_sym, f_ld, f_h): def main(): + if sys.version_info[0] < 3: + print("WARNING: Support for Python 2 is deprecated and will be removed in future versions.", file=sys.stderr) + elif sys.version_info[0] == 3 and sys.version_info[1] < 6: + print("WARNING: Python 3 versions older than 3.6 are not supported.", file=sys.stderr) description = ("This application generates .h and .ld files for symbols defined in input file. " "The input symbols file can be generated using nm utility like this: " "esp32-ulp-nm -g -f posix > ") diff --git a/components/xtensa/trax/traceparse.py b/components/xtensa/trax/traceparse.py index c5141227ee..119e4c9e88 100644 --- a/components/xtensa/trax/traceparse.py +++ b/components/xtensa/trax/traceparse.py @@ -49,7 +49,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. - +from __future__ import print_function import sys # Check if loaded into GDB @@ -328,6 +328,10 @@ def parse_and_dump(filename, disassemble=WITH_GDB): def main(): + if sys.version_info[0] < 3: + print("WARNING: Support for Python 2 is deprecated and will be removed in future versions.", file=sys.stderr) + elif sys.version_info[0] == 3 and sys.version_info[1] < 6: + print("WARNING: Python 3 versions older than 3.6 are not supported.", file=sys.stderr) if len(sys.argv) < 2: sys.stderr.write("Usage: %s \n") raise SystemExit(1) diff --git a/docs/en/get-started/linux-setup-scratch.rst b/docs/en/get-started/linux-setup-scratch.rst index 07b236c9ac..b52442736a 100644 --- a/docs/en/get-started/linux-setup-scratch.rst +++ b/docs/en/get-started/linux-setup-scratch.rst @@ -15,15 +15,17 @@ To compile with ESP-IDF you need to get the following packages: - CentOS 7:: - sudo yum install git wget ncurses-devel flex bison gperf python pyserial python-pyelftools cmake ninja-build ccache dfu-util + sudo yum -y update && sudo yum install git wget ncurses-devel flex bison gperf python3 python3-pip cmake ninja-build ccache dfu-util + +CentOS 7 is still supported but CentOS version 8 is recommended for a better user experience. - Ubuntu and Debian:: - sudo apt-get install git wget libncurses-dev flex bison gperf python python-pip python-setuptools python-serial python-click python-cryptography python-future python-pyparsing python-pyelftools cmake ninja-build ccache libffi-dev libssl-dev dfu-util + sudo apt-get install git wget libncurses-dev flex bison gperf python3 python3-pip python3-setuptools python3-serial python3-cryptography python3-future python3-pyparsing python3-pyelftools cmake ninja-build ccache libffi-dev libssl-dev dfu-util - Arch:: - sudo pacman -S --needed gcc git make ncurses flex bison gperf python-pyserial python-click python-cryptography python-future python-pyparsing python-pyelftools cmake ninja ccache dfu-util + sudo pacman -Sy --needed gcc git make ncurses flex bison gperf python-pyserial python-cryptography python-future python-pyparsing python-pyelftools cmake ninja ccache dfu-util .. note:: CMake version 3.5 or newer is required for use with ESP-IDF. Older Linux distributions may require updating, enabling of a "backports" repository, or installing of a "cmake3" package rather than "cmake". @@ -35,7 +37,7 @@ Compile the Toolchain from Source - CentOS 7:: - sudo yum install gawk gperf grep gettext ncurses-devel python python-devel automake bison flex texinfo help2man libtool make + sudo yum install gawk gperf grep gettext ncurses-devel python3 python3-devel automake bison flex texinfo help2man libtool make - Ubuntu pre-16.04:: @@ -51,7 +53,7 @@ Compile the Toolchain from Source - Arch:: - TODO + sudo pacman -Sy --needed python-pip Create the working directory and go into it:: @@ -98,6 +100,11 @@ You are looking for similar result containing toolchain's path at the beginning Instead of ``/home/user-name`` there should be a home path specific to your installation. +Python 2 deprecation +==================== + +Python 2 reached its `end of life `_ and support for it in ESP-IDF will be removed soon. Please install Python 3.6 or higher. Instructions for popular Linux distributions are listed above. + Next Steps ========== diff --git a/docs/en/get-started/linux-setup.rst b/docs/en/get-started/linux-setup.rst index f4e139845a..7f0793d1ca 100644 --- a/docs/en/get-started/linux-setup.rst +++ b/docs/en/get-started/linux-setup.rst @@ -11,11 +11,13 @@ To compile with ESP-IDF you need to get the following packages: - CentOS 7:: - sudo yum install git wget flex bison gperf python cmake ninja-build ccache dfu-util + sudo yum -y update && sudo yum install git wget flex bison gperf python3 cmake ninja-build ccache dfu-util + +CentOS 7 is still supported but CentOS version 8 is recommended for a better user experience. - Ubuntu and Debian:: - sudo apt-get install git wget flex bison gperf python python-pip python-setuptools cmake ninja-build ccache libffi-dev libssl-dev dfu-util + sudo apt-get install git wget flex bison gperf python3 python3-pip python3-setuptools cmake ninja-build ccache libffi-dev libssl-dev dfu-util - Arch:: @@ -32,20 +34,47 @@ Permission issues /dev/ttyUSB0 With some Linux distributions you may get the ``Failed to open port /dev/ttyUSB0`` error message when flashing the {IDF_TARGET_NAME}. :ref:`This can be solved by adding the current user to the dialout group`. +Setting up Python 3 as default for CentOS +----------------------------------------- + +CentOS 7 and older is providing Python 2.7 as the default interpreter. +Python 3 is recommended instead and can be installed in old distributions as follows, or please consult the documentation of your operating system for other recommended ways to achieve this:: + + sudo yum -y update && sudo yum install python3 python3-pip python3-setuptools + +Making Python 3 the default interpreter is possible by running:: + + sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 10 && alias pip=pip3 + Setting up Python 3 as default for Ubuntu and Debian ---------------------------------------------------- -Ubuntu and Debian are still providing Python 2.7 as the default interpreter but some required packages may be missing for newer distributions. Python 3 is recommended and can be installed as follows:: +Ubuntu (version 18.04 and older) and Debian (version 9 and older) are still providing Python 2.7 as the default interpreter. +Python 3 is recommended instead and can be installed in old distributions as follows, or please consult the documentation of your operating system for other recommended ways to achieve this:: sudo apt-get install python3 python3-pip python3-setuptools Making Python 3 the default interpreter is possible by running:: - sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 10 + sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 10 && alias pip=pip3 .. note:: This is system-wide change which may affect all of the applications. +Fixing broken pip on Ubuntu 16.04 +================================= + +Package ``python3-pip`` could be broken without possibility to upgrade it. +Package has to be removed and installed manually using script `get-pip.py `_.:: + + apt remove python3-pip python3-virtualenv; rm -r ~/.local + rm -r ~/.espressif/python_env && python get-pip.py + +Python 2 deprecation +==================== + +Python 2 reached its `end of life `_ and support for it in ESP-IDF will be removed soon. Please install Python 3.6 or higher. Instructions for popular Linux distributions are listed above. + Next Steps ========== diff --git a/docs/en/get-started/macos-setup-scratch.rst b/docs/en/get-started/macos-setup-scratch.rst index 1223730384..583c293952 100644 --- a/docs/en/get-started/macos-setup-scratch.rst +++ b/docs/en/get-started/macos-setup-scratch.rst @@ -79,6 +79,10 @@ Build the toolchain:: Toolchain will be built in ``~/esp/ctng-volume/crosstool-NG/builds/xtensa-{IDF_TARGET_TOOLCHAIN_NAME}-elf``. To use it, you need to add ``~/esp/ctng-volume/crosstool-NG/builds/xtensa-{IDF_TARGET_TOOLCHAIN_NAME}-elf/bin`` to ``PATH`` environment variable. +Python 2 deprecation +==================== + +Python 2 reached its `end of life `_ and support for it in ESP-IDF will be removed soon. Please install Python 3.6 or higher. Instructions for macOS are listed above. Next Steps ========== diff --git a/docs/en/get-started/macos-setup.rst b/docs/en/get-started/macos-setup.rst index d912aab674..3317311843 100644 --- a/docs/en/get-started/macos-setup.rst +++ b/docs/en/get-started/macos-setup.rst @@ -72,6 +72,11 @@ If the output is similar to ``Python 3.8.5``, your installation has been done su This is system-wide change which may affect all of the applications. +Python 2 deprecation +==================== + +Python 2 reached its `end of life `_ and support for it in ESP-IDF will be removed soon. Please install Python 3.6 or higher. Instructions for macOS are listed above. + Next Steps ========== diff --git a/tools/ci/check_build_warnings.py b/tools/ci/check_build_warnings.py index 3db99e8b18..5e8a7d9900 100755 --- a/tools/ci/check_build_warnings.py +++ b/tools/ci/check_build_warnings.py @@ -29,6 +29,8 @@ IGNORE_WARNS = [ r"reassigning to symbol", r"changes choice state", r"crosstool_version_check\.cmake", + r"CryptographyDeprecationWarning", + r"Python 3 versions older than 3.6 are not supported." ] ] diff --git a/tools/ci/config/build.yml b/tools/ci/config/build.yml index a4527e34c0..7e66351df0 100644 --- a/tools/ci/config/build.yml +++ b/tools/ci/config/build.yml @@ -58,6 +58,7 @@ build_ssc_esp32s2: - $BOT_LABEL_REGULAR_TEST variables: LOG_PATH: "$CI_PROJECT_DIR/log_ut_cmake" + PYTHON_VER: 3 script: - export EXTRA_CFLAGS=${PEDANTIC_CFLAGS} - export EXTRA_CXXFLAGS=${PEDANTIC_CXXFLAGS} @@ -90,6 +91,8 @@ build_esp_idf_tests_cmake_esp32s2: - $BOT_LABEL_EXAMPLE_TEST - $BOT_LABEL_REGULAR_TEST - $BOT_LABEL_WEEKEND_TEST + - PYTHON_VER: 3 + script: # it's not possible to build 100% out-of-tree and have the "artifacts" # mechanism work, but this is the next best thing diff --git a/tools/idf.py b/tools/idf.py index b8c64481d8..0de95f89ae 100755 --- a/tools/idf.py +++ b/tools/idf.py @@ -82,6 +82,12 @@ def check_environment(): print("Setting IDF_PATH environment variable: %s" % detected_idf_path) os.environ["IDF_PATH"] = detected_idf_path + # check Python version + if sys.version_info[0] < 3: + print_warning("WARNING: Support for Python 2 is deprecated and will be removed in future versions.") + elif sys.version_info[0] == 3 and sys.version_info[1] < 6: + print_warning("WARNING: Python 3 versions older than 3.6 are not supported.") + # check Python dependencies checks_output.append("Checking Python dependencies...") try: