Skip to content

Commit 708c259

Browse files
authored
Backport fixes
* Update Arduino and IDF versions in README * move penv setup to platform.py * simplify * call installer with penv Python * revert * fix scons error * try again to call tl-install from penv Python * install esptool later * esptool install later * remove warning esptool noise * sort imports * Replace remaining direct setup_python_environment call with platform.setup_python_env * wrong function name * fix: parameter name shadows function * Type hints: use Optional[str] for nullable arguments * Remove unused parameter penv_python * Avoid leaving sockets open * make github_actions bool * remove duplcate python check * fix endless recursion * show 1000 chars on failure with idf_tools.py * add "GIT_SSL_CAINFO" * use importlib for penv_setup.py * remove duplicate comment * update comments * no assert * no env.subst needed * Eliminate fallback for Python environment setup (#299) Removed fallback setup for Python environment in platform configuration. * Increase subprocess timeout for installations * Modify esptool path check to return None * Improve error handling for missing Python executable * Add urllib3 dependency with version constraint * Modify _setup_certifi_env to use python_exe argument Updated _setup_certifi_env to accept an optional python executable argument for better certifi path resolution. * remove fallback for certifi environment setup in penv_setup.py * Check for Python executable file in penv_setup * Change existence check to use isfile "python" for penv_dir * Refactor _setup_certifi_env function parameters Removed unused parameters and added GIT_SSL_CAINFO environment variable setup. * Change warnings to errors in package installation and install one by one. So a failure does not stop installing other packages. * Remove '--ng' option from esp_idf_size command * Update esp-idf-size package version to 2.0.0 * Update debugger package v16.3 * Add pydantic dependency version specification * Remove unused import in espidf.py Remove unused import of 'join' from os.path
1 parent 8715c17 commit 708c259

File tree

8 files changed

+364
-145
lines changed

8 files changed

+364
-145
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Prerequisites:
2929
The Wiki is AI generated and insane detailed and accurate.
3030

3131
### Stable Arduino
32-
currently espressif Arduino 3.3.0 and IDF 5.5.0
32+
currently espressif Arduino 3.3.1 and IDF 5.5.1
3333

3434
```ini
3535
[env:stable]

builder/frameworks/arduino.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@
2222
http://arduino.cc/en/Reference/HomePage
2323
"""
2424

25+
import hashlib
2526
import os
26-
import sys
2727
import shutil
28-
import hashlib
28+
import sys
2929
import threading
3030
from contextlib import suppress
3131
from os.path import join, exists, isabs, splitdrive, commonpath, relpath
@@ -886,7 +886,7 @@ def get_frameworks_in_current_env():
886886
if flag_custom_sdkconfig and not flag_any_custom_sdkconfig:
887887
call_compile_libs()
888888

889-
# Main logic for Arduino Framework
889+
# Arduino framework configuration and build logic
890890
pioframework = env.subst("$PIOFRAMEWORK")
891891
arduino_lib_compile_flag = env.subst("$ARDUINO_LIB_COMPILE_FLAG")
892892

builder/frameworks/component_manager.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
import shutil
1313
import re
1414
import yaml
15-
from yaml import SafeLoader
1615
from pathlib import Path
1716
from typing import Set, Optional, Dict, Any, List, Tuple, Pattern
17+
from yaml import SafeLoader
1818

1919

2020
class ComponentManagerConfig:
@@ -252,7 +252,7 @@ def _get_or_create_component_yml(self) -> str:
252252
Returns:
253253
Absolute path to the component YAML file
254254
"""
255-
# Try Arduino framework first
255+
# Check Arduino framework directory first
256256
afd = self.config.arduino_framework_dir
257257
framework_yml = str(Path(afd) / "idf_component.yml") if afd else ""
258258
if framework_yml and os.path.exists(framework_yml):

builder/frameworks/espidf.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,13 @@
2323
import copy
2424
import importlib.util
2525
import json
26-
import subprocess
27-
import sys
28-
import shutil
2926
import os
30-
from os.path import join
27+
import platform as sys_platform
3128
import re
3229
import requests
33-
import platform as sys_platform
30+
import shutil
31+
import subprocess
32+
import sys
3433
from pathlib import Path
3534
from urllib.parse import urlsplit, unquote
3635

@@ -1530,6 +1529,7 @@ def _get_installed_uv_packages(python_exe_path):
15301529
# https://github.com/platformio/platform-espressif32/issues/635
15311530
"cryptography": "~=44.0.0",
15321531
"pyparsing": ">=3.1.0,<4",
1532+
"pydantic": "~=2.11.10",
15331533
"idf-component-manager": "~=2.2",
15341534
"esp-idf-kconfig": "~=2.5.0"
15351535
}
@@ -1672,8 +1672,8 @@ def get_python_exe():
16721672

16731673
ensure_python_venv_available()
16741674

1675-
# ESP-IDF package doesn't contain .git folder, instead package version is specified
1676-
# in a special file "version.h" in the root folder of the package
1675+
# ESP-IDF package version is determined from version.h file
1676+
# since the package distribution doesn't include .git metadata
16771677

16781678
create_version_file()
16791679

@@ -1712,7 +1712,7 @@ def get_python_exe():
17121712

17131713

17141714
#
1715-
# Current build script limitations
1715+
# Known build system limitations
17161716
#
17171717

17181718
if any(" " in p for p in (FRAMEWORK_DIR, BUILD_DIR)):
@@ -1751,12 +1751,12 @@ def get_python_exe():
17511751
LIBSOURCE_DIRS=[str(Path(ARDUINO_FRAMEWORK_DIR) / "libraries")]
17521752
)
17531753

1754-
# Set ESP-IDF version environment variables (needed for proper Kconfig processing)
1754+
# Configure ESP-IDF version environment variables for Kconfig processing
17551755
framework_version = get_framework_version()
17561756
major_version = framework_version.split('.')[0] + '.' + framework_version.split('.')[1]
17571757
os.environ["ESP_IDF_VERSION"] = major_version
17581758

1759-
# Configure CMake arguments with ESP-IDF version
1759+
# Setup CMake configuration arguments
17601760
extra_cmake_args = [
17611761
"-DIDF_TARGET=" + idf_variant,
17621762
"-DPYTHON_DEPS_CHECKED=1",
@@ -1850,7 +1850,7 @@ def get_python_exe():
18501850
env.Depends("$BUILD_DIR/$PROGNAME$PROGSUFFIX", build_bootloader(sdk_config))
18511851

18521852
#
1853-
# Target: ESP-IDF menuconfig
1853+
# ESP-IDF menuconfig target implementation
18541854
#
18551855

18561856
env.AddPlatformTarget(
@@ -1995,8 +1995,8 @@ def _skip_prj_source_files(node):
19951995
):
19961996
project_env = env.Clone()
19971997
if project_target_name != "__idf_main":
1998-
# Manually add dependencies to CPPPATH since ESP-IDF build system doesn't generate
1999-
# this info if the folder with sources is not named 'main'
1998+
# Add dependencies to CPPPATH for non-main source directories
1999+
# ESP-IDF build system requires manual dependency handling for custom source folders
20002000
# https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/build-system.html#rename-main
20012001
project_env.AppendUnique(CPPPATH=app_includes["plain_includes"])
20022002

@@ -2044,7 +2044,7 @@ def _skip_prj_source_files(node):
20442044
#
20452045

20462046
extra_elf2bin_flags = "--elf-sha256-offset 0xb0"
2047-
# https://github.com/espressif/esp-idf/blob/master/components/esptool_py/project_include.cmake#L58
2047+
# Reference: ESP-IDF esptool_py component configuration
20482048
# For chips that support configurable MMU page size feature
20492049
# If page size is configured to values other than the default "64KB" in menuconfig,
20502050
mmu_page_size = "64KB"

builder/main.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
import importlib.util
1516
import locale
1617
import os
1718
import re
@@ -20,7 +21,6 @@
2021
import sys
2122
from os.path import isfile, join
2223
from pathlib import Path
23-
import importlib.util
2424

2525
from SCons.Script import (
2626
ARGUMENTS,
@@ -34,9 +34,8 @@
3434
from platformio.project.helpers import get_project_dir
3535
from platformio.util import get_serial_ports
3636
from platformio.compat import IS_WINDOWS
37-
from penv_setup import setup_python_environment
3837

39-
# Initialize environment and configuration
38+
# Initialize SCons environment and project configuration
4039
env = DefaultEnvironment()
4140
platform = env.PioPlatform()
4241
projectconfig = env.GetProjectConfig()
@@ -46,10 +45,10 @@
4645
core_dir = projectconfig.get("platformio", "core_dir")
4746
build_dir = Path(projectconfig.get("platformio", "build_dir"))
4847

49-
# Setup Python virtual environment and get executable paths
50-
PYTHON_EXE, esptool_binary_path = setup_python_environment(env, platform, core_dir)
48+
# Configure Python environment through centralized platform management
49+
PYTHON_EXE, esptool_binary_path = platform.setup_python_env(env)
5150

52-
# Initialize board configuration and MCU settings
51+
# Load board configuration and determine MCU architecture
5352
board = env.BoardConfig()
5453
board_id = env.subst("$BOARD")
5554
mcu = board.get("build.mcu", "esp32")
@@ -451,7 +450,7 @@ def switch_off_ldf():
451450
if not is_xtensa:
452451
toolchain_arch = "riscv32-esp"
453452

454-
# Initialize integration extra data if not present
453+
# Ensure integration extra data structure exists
455454
if "INTEGRATION_EXTRA_DATA" not in env:
456455
env["INTEGRATION_EXTRA_DATA"] = {}
457456

@@ -461,7 +460,7 @@ def switch_off_ldf():
461460
if ' ' in esptool_binary_path
462461
else esptool_binary_path
463462
)
464-
# Configure build tools and environment variables
463+
# Configure SCons build tools and compiler settings
465464
env.Replace(
466465
__get_board_boot_mode=_get_board_boot_mode,
467466
__get_board_f_flash=_get_board_f_flash,
@@ -612,7 +611,7 @@ def firmware_metrics(target, source, env):
612611
return
613612

614613
try:
615-
cmd = [PYTHON_EXE, "-m", "esp_idf_size", "--ng"]
614+
cmd = [PYTHON_EXE, "-m", "esp_idf_size"]
616615

617616
# Parameters from platformio.ini
618617
extra_args = env.GetProjectOption("custom_esp_idf_size_args", "")
@@ -637,7 +636,7 @@ def firmware_metrics(target, source, env):
637636
if env.GetProjectOption("custom_esp_idf_size_verbose", False):
638637
print(f"Running command: {' '.join(cmd)}")
639638

640-
# Call esp-idf-size with modified environment
639+
# Execute esp-idf-size with current environment
641640
result = subprocess.run(cmd, check=False, capture_output=False, env=os.environ)
642641

643642
if result.returncode != 0:

0 commit comments

Comments
 (0)