Merge branch 'feature/drop_py2_support' into 'master'
Drop support for unsupported Python versions Closes IDF-1676 See merge request espressif/esp-idf!13622
This commit is contained in:
@@ -35,8 +35,6 @@ IGNORE_WARNS = [
|
||||
r'changes choice state',
|
||||
r'crosstool_version_check\.cmake',
|
||||
r'CryptographyDeprecationWarning',
|
||||
r'Python 3 versions older than 3.6 are not supported.',
|
||||
r'Support for Python 2 is deprecated and will be removed in future versions.',
|
||||
r'Warning: \d+/\d+ app partitions are too small for binary'
|
||||
]
|
||||
]
|
||||
|
||||
@@ -141,7 +141,7 @@ class PublicHeaderChecker:
|
||||
|
||||
def join(self):
|
||||
for t in self.check_threads:
|
||||
while t.isAlive and not self.terminate.is_set():
|
||||
while t.is_alive() and not self.terminate.is_set():
|
||||
t.join(1) # joins with timeout to respond to keyboard interrupt
|
||||
|
||||
# Checks one header calling:
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
|
||||
if [ -z ${PYTHON_VER+x} ]; then
|
||||
# Use this version of the Python interpreter if it was not defined before.
|
||||
# 3.4.8 is the default python3 interpreter in esp32-ci-env
|
||||
# 3.6.13 is the default python3 interpreter in esp32-ci-env
|
||||
# Jobs which doesn't support this version should define PYTHON_VER themselves
|
||||
PYTHON_VER=3.4.8
|
||||
PYTHON_VER=3.6.13
|
||||
fi
|
||||
|
||||
if [ -f /opt/pyenv/activate ];
|
||||
|
||||
34
tools/idf.py
34
tools/idf.py
@@ -1,26 +1,13 @@
|
||||
#!/usr/bin/env python
|
||||
#
|
||||
# SPDX-FileCopyrightText: 2019-2021 Espressif Systems (Shanghai) CO LTD
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
# 'idf.py' is a top-level config/build command line tool for ESP-IDF
|
||||
#
|
||||
# You don't have to use idf.py, you can use cmake directly
|
||||
# (or use cmake in an IDE)
|
||||
#
|
||||
#
|
||||
#
|
||||
# Copyright 2019 Espressif Systems (Shanghai) PTE LTD
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# 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.
|
||||
#
|
||||
|
||||
# WARNING: we don't check for Python build-time dependencies until
|
||||
# check_environment() function below. If possible, avoid importing
|
||||
@@ -44,6 +31,7 @@ from pkgutil import iter_modules
|
||||
# idf.py extensions. Therefore, pyc file generation is turned off:
|
||||
sys.dont_write_bytecode = True
|
||||
|
||||
import python_version_checker # noqa: E402
|
||||
from idf_py_actions.errors import FatalError # noqa: E402
|
||||
from idf_py_actions.tools import executable_exists, idf_version, merge_action_lists, realpath # noqa: E402
|
||||
|
||||
@@ -93,11 +81,13 @@ def check_environment():
|
||||
print_warning('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.')
|
||||
try:
|
||||
# The Python compatibility check could have been done earlier (tools/detect_python.{sh,fish}) but PATH is
|
||||
# not set for import at that time. Even if the check would be done before, the same check needs to be done
|
||||
# here as well (for example one can call idf.py from a not properly set-up environment).
|
||||
python_version_checker.check()
|
||||
except RuntimeError as e:
|
||||
raise FatalError(e)
|
||||
|
||||
# check Python dependencies
|
||||
checks_output.append('Checking Python dependencies...')
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
#!/usr/bin/env python
|
||||
# coding=utf-8
|
||||
#
|
||||
# SPDX-FileCopyrightText: 2019-2021 Espressif Systems (Shanghai) CO LTD
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
# This script helps installing tools required to use the ESP-IDF, and updating PATH
|
||||
# to use the installed tools. It can also create a Python virtual environment,
|
||||
# and install Python requirements into it.
|
||||
@@ -23,22 +27,6 @@
|
||||
# * To start using the tools, run `eval "$(idf_tools.py export)"` — this will update
|
||||
# the PATH to point to the installed tools and set up other environment variables
|
||||
# needed by the tools.
|
||||
#
|
||||
###
|
||||
#
|
||||
# Copyright 2019 Espressif Systems (Shanghai) PTE LTD
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# 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.
|
||||
|
||||
import argparse
|
||||
import contextlib
|
||||
@@ -60,19 +48,22 @@ from ssl import SSLContext # noqa: F401
|
||||
from tarfile import TarFile # noqa: F401
|
||||
from zipfile import ZipFile
|
||||
|
||||
# Important notice: Please keep the lines above compatible with old Pythons so it won't fail with ImportError but with
|
||||
# a nice message printed by python_version_checker.check()
|
||||
try:
|
||||
from typing import IO, Callable, Optional, Tuple, Union # noqa: F401
|
||||
except ImportError:
|
||||
pass
|
||||
import python_version_checker
|
||||
|
||||
try:
|
||||
from urllib.error import ContentTooShortError
|
||||
from urllib.request import urlopen
|
||||
# the following is only for typing annotation
|
||||
from urllib.response import addinfourl # noqa: F401
|
||||
except ImportError:
|
||||
# Python 2
|
||||
from urllib import ContentTooShortError, urlopen # type: ignore
|
||||
# check the Python version before it will fail with an exception on syntax or package incompatibility.
|
||||
python_version_checker.check()
|
||||
except RuntimeError as e:
|
||||
print(e)
|
||||
raise SystemExit(1)
|
||||
|
||||
from typing import IO, Callable, Optional, Tuple, Union # noqa: F401
|
||||
from urllib.error import ContentTooShortError
|
||||
from urllib.request import urlopen
|
||||
# the following is only for typing annotation
|
||||
from urllib.response import addinfourl # noqa: F401
|
||||
|
||||
try:
|
||||
from exceptions import WindowsError
|
||||
|
||||
36
tools/python_version_checker.py
Normal file
36
tools/python_version_checker.py
Normal file
@@ -0,0 +1,36 @@
|
||||
# SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
# Script for checking the compatibility of the Python interpreter with ESP-IDF.
|
||||
#
|
||||
# There are related tools/detect_python.{sh,fish} scripts which are called earlier when the paths are not properly
|
||||
# set-up and they only intend to prefer the use of Python 3 over Python 2. Why not more? All possible executables
|
||||
# (python3.6, python3.7, ...) cannot be hardcoded there and at the end, the user is responsible to set-up a system
|
||||
# where "python" or "python3" of compatible version is available.
|
||||
|
||||
import sys
|
||||
|
||||
try:
|
||||
# Python 2 is not supported anymore but still the old way of typing is used here in order to give a nice Python
|
||||
# version failure and not a typing exception.
|
||||
from typing import Iterable
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
OLDEST_PYTHON_SUPPORTED = (3, 6) # keep it as tuple for comparison with sys.version_info
|
||||
|
||||
|
||||
def _ver_to_str(it): # type: (Iterable) -> str
|
||||
return '.'.join(str(x) for x in it)
|
||||
|
||||
|
||||
def is_supported(): # type: () -> bool
|
||||
return sys.version_info[:2] >= OLDEST_PYTHON_SUPPORTED[:2]
|
||||
|
||||
|
||||
def check(): # type: () -> None
|
||||
if not is_supported():
|
||||
raise RuntimeError('ESP-IDF supports Python {} or newer but you are using Python {}. Please upgrade your '
|
||||
'installation as described in the documentation.'.format(_ver_to_str(OLDEST_PYTHON_SUPPORTED),
|
||||
_ver_to_str(sys.version_info[:3])))
|
||||
Reference in New Issue
Block a user