Arduino Core 3.3.7

This commit is contained in:
Jason2866
2026-02-12 00:58:14 +01:00
parent 0e894354be
commit 40fd056922
13 changed files with 439 additions and 49 deletions
+46 -27
View File
@@ -44,7 +44,7 @@ PLATFORMIO_URL_VERSION_RE = re.compile(
# Python dependencies required for ESP32 platform builds
python_deps = {
"platformio": "https://github.com/pioarduino/platformio-core/archive/refs/tags/v6.1.18.zip",
"platformio": "https://github.com/pioarduino/platformio-core/archive/refs/tags/v6.1.19.zip",
"littlefs-python": ">=0.16.0",
"fatfs-ng": ">=0.1.14",
"pyyaml": ">=6.0.2",
@@ -219,13 +219,14 @@ def get_packages_to_install(deps, installed_packages):
yield package
def install_python_deps(python_exe, external_uv_executable):
def install_python_deps(python_exe, external_uv_executable, uv_cache_dir=None):
"""
Ensure uv package manager is available in penv and install required Python dependencies.
Args:
python_exe: Path to Python executable in the penv
external_uv_executable: Path to external uv executable used to create the penv (can be None)
uv_cache_dir: Optional path to uv cache directory
Returns:
bool: True if successful, False otherwise
@@ -233,6 +234,12 @@ def install_python_deps(python_exe, external_uv_executable):
# Get the penv directory to locate uv within it
penv_dir = os.path.dirname(os.path.dirname(python_exe))
penv_uv_executable = get_executable_path(penv_dir, "uv")
# Build subprocess environment with UV_CACHE_DIR if specified
uv_env = None
if uv_cache_dir:
uv_env = dict(os.environ)
uv_env["UV_CACHE_DIR"] = str(uv_cache_dir)
# Check if uv is available in the penv
uv_in_penv_available = False
@@ -250,28 +257,21 @@ def install_python_deps(python_exe, external_uv_executable):
# Install uv into penv if not available
if not uv_in_penv_available:
if external_uv_executable:
# Use external uv to install uv into the penv
# Try external uv first to install uv into the penv
try:
subprocess.check_call(
[external_uv_executable, "pip", "install", "uv>=0.1.0", f"--python={python_exe}", "--quiet"],
stdout=subprocess.DEVNULL,
stderr=subprocess.STDOUT,
timeout=300
timeout=300,
env=uv_env
)
except subprocess.CalledProcessError as e:
print(f"Error: uv installation failed with exit code {e.returncode}")
return False
except subprocess.TimeoutExpired:
print("Error: uv installation timed out")
return False
except FileNotFoundError:
print("Error: External uv executable not found")
return False
except Exception as e:
print(f"Error installing uv package manager into penv: {e}")
return False
else:
# No external uv available, use pip to install uv into penv
uv_in_penv_available = True
except Exception:
print("Warning: uv installation via external uv failed, falling back to pip")
if not uv_in_penv_available:
# Fallback to pip to install uv into penv
try:
subprocess.check_call(
[python_exe, "-m", "pip", "install", "uv>=0.1.0", "--quiet"],
@@ -308,7 +308,8 @@ def install_python_deps(python_exe, external_uv_executable):
capture_output=True,
text=True,
encoding='utf-8',
timeout=300
timeout=300,
env=uv_env
)
if result_obj.returncode == 0:
@@ -356,7 +357,8 @@ def install_python_deps(python_exe, external_uv_executable):
cmd,
stdout=subprocess.DEVNULL,
stderr=subprocess.STDOUT,
timeout=300
timeout=300,
env=uv_env
)
except subprocess.CalledProcessError as e:
@@ -375,7 +377,7 @@ def install_python_deps(python_exe, external_uv_executable):
return True
def install_esptool(env, platform, python_exe, uv_executable):
def install_esptool(env, platform, python_exe, uv_executable, uv_cache_dir=None):
"""
Install esptool from package folder "tool-esptoolpy" using uv package manager.
Ensures esptool is installed from the specific tool-esptoolpy package directory.
@@ -385,6 +387,7 @@ def install_esptool(env, platform, python_exe, uv_executable):
platform: PlatformIO platform object
python_exe (str): Path to Python executable in virtual environment
uv_executable (str): Path to uv executable
uv_cache_dir: Optional path to uv cache directory
Raises:
SystemExit: If esptool installation fails or package directory not found
@@ -396,6 +399,12 @@ def install_esptool(env, platform, python_exe, uv_executable):
)
sys.exit(1)
# Build subprocess environment with UV_CACHE_DIR if specified
uv_env = None
if uv_cache_dir:
uv_env = dict(os.environ)
uv_env["UV_CACHE_DIR"] = str(uv_cache_dir)
# Check if esptool is already installed from the correct path
try:
result = subprocess.run(
@@ -427,7 +436,7 @@ def install_esptool(env, platform, python_exe, uv_executable):
uv_executable, "pip", "install", "--quiet", "--force-reinstall",
f"--python={python_exe}",
"-e", esptool_repo_path
], timeout=60)
], timeout=60, env=uv_env)
except subprocess.CalledProcessError as e:
sys.stderr.write(
@@ -468,6 +477,9 @@ def _setup_python_environment_core(env, platform, platformio_dir, should_install
tuple[str, str]: (Path to penv Python executable, Path to esptool script)
"""
penv_dir = str(Path(platformio_dir) / "penv")
# Determine uv cache directory inside .platformio/.cache
uv_cache_dir = str(Path(platformio_dir) / ".cache" / "uv")
# Create virtual environment if not present
if env is not None:
@@ -498,7 +510,7 @@ def _setup_python_environment_core(env, platform, platformio_dir, should_install
# Install required Python dependencies for ESP32 platform
if has_internet_connection() or github_actions:
if not install_python_deps(penv_python, used_uv_executable):
if not install_python_deps(penv_python, used_uv_executable, uv_cache_dir):
sys.stderr.write("Error: Failed to install Python dependencies into penv\n")
sys.exit(1)
else:
@@ -508,10 +520,10 @@ def _setup_python_environment_core(env, platform, platformio_dir, should_install
if should_install_esptool:
if env is not None:
# SCons version
install_esptool(env, platform, penv_python, uv_executable)
install_esptool(env, platform, penv_python, uv_executable, uv_cache_dir)
else:
# Minimal setup - install esptool from tool package
_install_esptool_from_tl_install(platform, penv_python, uv_executable)
_install_esptool_from_tl_install(platform, penv_python, uv_executable, uv_cache_dir)
# Setup certifi environment variables
_setup_certifi_env(env, penv_python)
@@ -582,7 +594,7 @@ def _setup_pipenv_minimal(penv_dir):
return None
def _install_esptool_from_tl_install(platform, python_exe, uv_executable):
def _install_esptool_from_tl_install(platform, python_exe, uv_executable, uv_cache_dir=None):
"""
Install esptool from tl-install provided path into penv.
@@ -590,6 +602,7 @@ def _install_esptool_from_tl_install(platform, python_exe, uv_executable):
platform: PlatformIO platform object
python_exe (str): Path to Python executable in virtual environment
uv_executable (str): Path to uv executable
uv_cache_dir: Optional path to uv cache directory
Raises:
SystemExit: If esptool installation fails or package directory not found
@@ -599,6 +612,12 @@ def _install_esptool_from_tl_install(platform, python_exe, uv_executable):
if not esptool_repo_path or not os.path.isdir(esptool_repo_path):
return (None, None)
# Build subprocess environment with UV_CACHE_DIR if specified
uv_env = None
if uv_cache_dir:
uv_env = dict(os.environ)
uv_env["UV_CACHE_DIR"] = str(uv_cache_dir)
# Check if esptool is already installed from the correct path
try:
result = subprocess.run(
@@ -630,7 +649,7 @@ def _install_esptool_from_tl_install(platform, python_exe, uv_executable):
uv_executable, "pip", "install", "--quiet", "--force-reinstall",
f"--python={python_exe}",
"-e", esptool_repo_path
], timeout=60)
], timeout=60, env=uv_env)
print(f"Installed esptool from tl-install path: {esptool_repo_path}")
except subprocess.CalledProcessError as e: