feat: Deprecate Python 3.9

BREAKING CHANGE:
- Minimal supported Python version is now 3.10.
This commit is contained in:
Peter Dragun
2025-07-28 09:56:45 +02:00
parent 84b4605ffa
commit 519042a1e2
20 changed files with 49 additions and 44 deletions

View File

@@ -23,7 +23,7 @@ jobs:
- name: Set up Python environment
uses: actions/setup-python@master
with:
python-version: v3.8
python-version: 3.10
- name: Install python packages
run: |
pip install pre-commit

View File

@@ -228,7 +228,7 @@ pytest_build_system_macos:
- macos
parallel: 3
variables:
PYENV_VERSION: "3.9"
PYENV_VERSION: "3.10"
# CCACHE_DIR: "/cache/idf_ccache". On macOS, you cannot write to this folder due to insufficient permissions.
CCACHE_DIR: "" # ccache will use "$HOME/Library/Caches/ccache".
# Workaround for a bug in Parallels executor where CI_PROJECT_DIR is not an absolute path,

View File

@@ -52,9 +52,9 @@ variables:
CHECKOUT_REF_SCRIPT: "$CI_PROJECT_DIR/tools/ci/checkout_project_ref.py"
# Docker images
ESP_ENV_IMAGE: "${CI_DOCKER_REGISTRY}/esp-env-v6.0:1"
ESP_IDF_DOC_ENV_IMAGE: "${CI_DOCKER_REGISTRY}/esp-idf-doc-env-v6.0:1-1"
TARGET_TEST_ENV_IMAGE: "${CI_DOCKER_REGISTRY}/target-test-env-v6.0:1"
ESP_ENV_IMAGE: "${CI_DOCKER_REGISTRY}/esp-env-v6.0:2"
ESP_IDF_DOC_ENV_IMAGE: "${CI_DOCKER_REGISTRY}/esp-idf-doc-env-v6.0:2-1"
TARGET_TEST_ENV_IMAGE: "${CI_DOCKER_REGISTRY}/target-test-env-v6.0:2"
SONARQUBE_SCANNER_IMAGE: "${CI_DOCKER_REGISTRY}/sonarqube-scanner:5"
# cache python dependencies

View File

@@ -350,7 +350,7 @@ test_pytest_macos:
reports:
junit: XUNIT_RESULT.xml
variables:
PYENV_VERSION: "3.9"
PYENV_VERSION: "3.10"
# Workaround for a bug in Parallels executor where CI_PROJECT_DIR is not an absolute path,
# but a relative path to the build directory (builds/espressif/esp-idf instead of ~/builds/espressif/esp-idf.
# GitLab sets the project dir to this template `<builds_dir>/<namespace>/<project_name>`

View File

@@ -1,7 +1,7 @@
[mypy]
# Specifies the Python version used to parse and check the target program
python_version = 3.9
python_version = 3.10
# Disallows defining functions without type annotations or with incomplete type annotations
# True => enforce type annotation in all function definitions

View File

@@ -130,7 +130,7 @@ For more detailed information about integrating ESP-IDF with CMake into an IDE,
Setting up the Python Interpreter
---------------------------------
ESP-IDF works well with Python version 3.9+.
ESP-IDF works well with Python version 3.10+.
``idf.py`` and other Python scripts will run with the default Python interpreter, i.e., ``python``. You can switch to a different one like ``python3 $IDF_PATH/tools/idf.py ...``, or you can set up a shell alias or another script to simplify the command.

View File

@@ -1,3 +1,5 @@
.. _idf-docker-image:
****************
IDF Docker Image
****************
@@ -14,7 +16,7 @@ IDF Docker image (``espressif/idf``) is intended for building applications and l
The image contains:
- Common utilities such as ``git``, ``wget``, ``curl``, and ``zip``.
- Python 3.9 or newer.
- Python 3.10 or newer.
- A copy of a specific version of ESP-IDF. See below for information about versions. ``IDF_PATH`` environment variable is set and points to the ESP-IDF location in the container.
- All the build tools required for the specific version of ESP-IDF: CMake, Ninja, cross-compiler toolchains, etc.
- All Python packages required by ESP-IDF are installed in a virtual environment.

View File

@@ -98,25 +98,23 @@ Then you need to install Apple Rosetta 2 by running
Installing Python 3
~~~~~~~~~~~~~~~~~~~
Based on macOS `Catalina 10.15 release notes`_, use of Python 2.7 is not recommended and Python 2.7 is not included by default in future versions of macOS. Check what Python you currently have::
Ensure that you have Python 3.10 or newer installed, as this is the minimum version supported by ESP-IDF.
python --version
Note that most of the recent versions of macOS include Python 3.9 (or older) by default, which is no longer supported. You will need to install Python 3.10 or later.
If the output is like ``Python 2.7.17``, your default interpreter is Python 2.7. If so, also check if Python 3 is not already installed on your computer::
To install supported Python 3 on macOS:
python3 --version
If the above command returns an error, it means Python 3 is not installed.
Below is an overview of the steps to install Python 3.
- Installing with HomeBrew_ can be done as follows::
- With HomeBrew_, run::
brew install python3
- If you have MacPorts_, you can run::
- With MacPorts_, run::
sudo port install python38
sudo port install python313
.. note::
During installation, the install script will check for supported Python versions on your system and select the oldest version that meets the minimum requirement.
.. _get-started-get-esp-idf:

View File

@@ -160,7 +160,7 @@ With some Linux distributions, you may get the error message similar to ``Could
Python Compatibility
~~~~~~~~~~~~~~~~~~~~
ESP-IDF supports Python 3.9 or newer. It is recommended to upgrade your operating system to a recent version satisfying this requirement. Other options include the installation of Python from `sources <https://www.python.org/downloads/>`_ or the use of a Python version management system such as `pyenv <https://github.com/pyenv/pyenv>`_.
ESP-IDF supports Python 3.10 or newer. It is recommended to upgrade your operating system to a recent version satisfying this requirement. Other options include the installation of Python from `sources <https://www.python.org/downloads/>`_ or the use of a Python version management system such as `pyenv <https://github.com/pyenv/pyenv>`_.
.. only:: esp32 or esp32s2 or esp32s3

View File

@@ -30,3 +30,13 @@ We recommend to use ``idf.py gdb`` instead of ``idf.py gdbgui``, or debug in Ecl
All commands with eFuse functionality now require a serial port to be specified. This was done to prevent accidental use of the wrong port, as these operations are irreversible.
For all ``idf.py efuse*`` commands, you now need to specify the serial port with the ``--port`` argument (or ``ESPPORT`` environment variable). If the port is not specified, the command will fail with an error message.
Python 3.9 Deprecation
----------------------
Python 3.9 is no longer supported. The minimum required Python version is now 3.10. Please upgrade your Python installation to version 3.10 or later. Alternatively, you can use the provided Docker images; for more information, see :ref:`idf-docker-image`.
Refer to the official `Python documentation <https://docs.python.org/3/using/index.html>`_ for instructions on upgrading Python for your operating system.
For Linux users, it is recommended to upgrade to a newer version of your distribution that includes a supported Python version.

View File

@@ -130,7 +130,7 @@ idf.py
设置 Python 解释器
------------------
ESP-IDF 适用于 Python 3.9 以上版本。
ESP-IDF 适用于 Python 3.10 以上版本。
``idf.py`` 和其他的 Python 脚本会使用默认的 Python 解释器运行,如 ``python``。你可以通过 ``python3 $IDF_PATH/tools/idf.py ...`` 命令切换到别的 Python 解释器,或者通过设置 shell 别名或其他脚本来简化该命令。

View File

@@ -1,3 +1,5 @@
.. _idf-docker-image:
********************
IDF Docker 镜像
********************
@@ -14,7 +16,7 @@ IDF Docker 镜像 (``espressif/idf``) 为使用特定版本的 ESP-IDF 自动化
该镜像包含以下内容:
- 常见的实用工具,如 ``git````wget````curl````zip``
- Python 3.9 或更高版本。
- Python 3.10 或更高版本。
- 特定版本 ESP-IDF 的副本。有关版本信息,请参阅下文。该副本中设置了 ``IDF_PATH`` 环境变量,并指向容器中 ESP-IDF 的位置。
- 构建特定版本 ESP-IDF 所需工具CMake、Ninja、交叉编译器工具链等。
- ESP-IDF 需要的所有 Python 软件包。这些软件包均已安装在虚拟环境中。

View File

@@ -160,7 +160,7 @@
兼容的 Python 版本
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ESP-IDF 支持 Python 3.9 及以上版本,建议升级操作系统到最新版本从而更新 Python。也可选择从 `sources <https://www.python.org/downloads/>`_ 安装最新版 Python或使用 Python 管理系统如 `pyenv <https://github.com/pyenv/pyenv>`_ 对版本进行升级管理。
ESP-IDF 支持 Python 3.10 及以上版本,建议升级操作系统到最新版本从而更新 Python。也可选择从 `sources <https://www.python.org/downloads/>`_ 安装最新版 Python或使用 Python 管理系统如 `pyenv <https://github.com/pyenv/pyenv>`_ 对版本进行升级管理。
.. only:: esp32 or esp32s2 or esp32s3

View File

@@ -1,5 +1,5 @@
line-length = 120
target-version = "py38"
target-version = "py310"
[format]
quote-style = "single"
@@ -12,6 +12,7 @@ target-version = "py38"
"F", # pyflakes
"W", # pycodestyle
"I", # reorder-imports
"UP", # pyupgrade
]
ignore = [
"E203", # whitespace before ':'

View File

@@ -20,15 +20,9 @@ except ImportError:
)
sys.exit(1)
try:
from importlib.metadata import PackageNotFoundError
from importlib.metadata import requires as _requires
from importlib.metadata import version as _version
except ImportError:
# compatibility for python <=3.7
from importlib_metadata import PackageNotFoundError # type: ignore
from importlib_metadata import requires as _requires # type: ignore
from importlib_metadata import version as _version # type: ignore
from importlib.metadata import PackageNotFoundError
from importlib.metadata import requires as _requires
from importlib.metadata import version as _version
try:
from typing import Set

View File

@@ -29,7 +29,7 @@ def types_valid_ignored_rules(file_name): # type: (str) -> bool
"""
Run Mypy check with rules for ignore list on the given file, return TRUE if Mypy check passes
"""
mypy_exit_code = subprocess.call('mypy {} --python-version 3.8 --allow-untyped-defs'.format(file_name), shell=True)
mypy_exit_code = subprocess.call('mypy {} --python-version 3.10 --allow-untyped-defs'.format(file_name), shell=True)
return not bool(mypy_exit_code)

View File

@@ -3,11 +3,11 @@
# This is a port of detect_python.sh. More information are provided there.
set OLDEST_PYTHON_SUPPORTED_MAJOR 3
set OLDEST_PYTHON_SUPPORTED_MINOR 9
set OLDEST_PYTHON_SUPPORTED_MINOR 10
set -x ESP_PYTHON python
for p_cmd in python3 python python3.9 python3.10 python3.11 python3.12 python3.13;
for p_cmd in python3 python python3.10 python3.11 python3.12 python3.13;
$p_cmd --version >/dev/null 2>&1; or continue
echo "Checking \"$p_cmd\" ..."

View File

@@ -8,11 +8,11 @@
# 3. If required version of python is not found, script will fail
OLDEST_PYTHON_SUPPORTED_MAJOR=3
OLDEST_PYTHON_SUPPORTED_MINOR=9
OLDEST_PYTHON_SUPPORTED_MINOR=10
ESP_PYTHON=python
for p_cmd in python3 python python3.9 python3.10 python3.11 python3.12 python3.13; do
for p_cmd in python3 python python3.10 python3.11 python3.12 python3.13; do
$p_cmd --version >/dev/null 2>&1 || continue
echo "Checking \"$p_cmd\" ..."

View File

@@ -8,7 +8,7 @@
#
# 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.9, python3.10, ...) cannot be hardcoded there and at the end, the user is responsible to set-up a system
# (python3.10, python3.11, ...) 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
@@ -19,7 +19,7 @@ try:
except ImportError:
pass
OLDEST_PYTHON_SUPPORTED = (3, 9) # keep it as tuple for comparison with sys.version_info
OLDEST_PYTHON_SUPPORTED = (3, 10) # keep it as tuple for comparison with sys.version_info
def _ver_to_str(it): # type: (Iterable) -> str

View File

@@ -6,8 +6,6 @@
setuptools
packaging
# importlib_metadata: is part of python3.8 and newer as importlib.metadata
importlib_metadata; python_version < "3.8"
click
pyserial
cryptography