From aa0df36c8a3d1f4c901fedb2dcba1b4b530df783 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 11 Aug 2023 13:49:03 +0300 Subject: [PATCH 01/69] Remove CLion from tests --- tests/commands/test_init.py | 80 ------------------------------------- 1 file changed, 80 deletions(-) diff --git a/tests/commands/test_init.py b/tests/commands/test_init.py index 80ef0d91..651cf579 100644 --- a/tests/commands/test_init.py +++ b/tests/commands/test_init.py @@ -16,7 +16,6 @@ import json import os from platformio.commands.boards import cli as cmd_boards -from platformio.package.commands.exec import package_exec_cmd from platformio.project.commands.init import project_init_cmd from platformio.project.config import ProjectConfig from platformio.project.exception import ProjectEnvsNotAvailableError @@ -216,82 +215,3 @@ def test_init_incorrect_board(clirunner): assert result.exit_code == 2 assert "Error: Invalid value for" in result.output assert isinstance(result.exception, SystemExit) - - -def test_init_ide_clion(clirunner, validate_cliresult, tmpdir): - project_dir = tmpdir.join("project").mkdir() - # Add extra libraries to cover cases with possible unwanted backslashes - lib_extra_dirs = tmpdir.join("extra_libs").mkdir() - extra_lib = lib_extra_dirs.join("extra_lib").mkdir() - extra_lib.join("extra_lib.h").write(" ") - extra_lib.join("extra_lib.cpp").write(" ") - - with project_dir.as_cwd(): - result = clirunner.invoke( - project_init_cmd, - [ - "-b", - "uno", - "--ide", - "clion", - "--project-option", - "framework=arduino", - "--project-option", - "platform_packages=platformio/tool-ninja", - "--project-option", - "lib_extra_dirs=%s" % str(lib_extra_dirs), - ], - ) - - validate_cliresult(result) - assert all( - os.path.isfile(f) for f in ("CMakeLists.txt", "CMakeListsPrivate.txt") - ) - - project_dir.join("src").join("main.cpp").write( - """#include -#include "extra_lib.h" -void setup(){} -void loop(){} -""" - ) - project_dir.join("build_dir").mkdir() - result = clirunner.invoke( - package_exec_cmd, - [ - "-p", - "tool-cmake", - "--", - "cmake", - "-DCMAKE_BUILD_TYPE=uno", - "-DCMAKE_MAKE_PROGRAM=%s" - % os.path.join( - ProjectConfig().get("platformio", "packages_dir"), - "tool-ninja", - "ninja", - ), - "-G", - "Ninja", - "-S", - str(project_dir), - "-B", - "build_dir", - ], - ) - validate_cliresult(result) - - # build - result = clirunner.invoke( - package_exec_cmd, - [ - "-p", - "tool-cmake", - "--", - "cmake", - "--build", - "build_dir", - "--target", - "Debug", - ], - ) - validate_cliresult(result) From 897844ebc172bd8a2e313bdb9011fc7d986863c2 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 18 Aug 2023 14:39:03 +0300 Subject: [PATCH 02/69] Docs: Sync dev-platforms --- docs | 2 +- examples | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs b/docs index 1c8479f3..fb5dbb92 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit 1c8479f3d0af2b9ac6f3a2b7f9405bd9a4cdac3f +Subproject commit fb5dbb92e5865de7f96b49704ea8383e877ab99a diff --git a/examples b/examples index 4bed26fd..28c58d3b 160000 --- a/examples +++ b/examples @@ -1 +1 @@ -Subproject commit 4bed26fd0d0b559dcf52f6088c9c2b4ebffd5fd6 +Subproject commit 28c58d3b7c4b88d3b1e0c1d2f7d99119a9c89c39 From b88c393b4e974ff571e867944a0acf4c50d48e89 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Thu, 31 Aug 2023 15:53:29 +0300 Subject: [PATCH 03/69] Ensure SCons is installed on "project init" --- platformio/package/commands/install.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/platformio/package/commands/install.py b/platformio/package/commands/install.py index 82c377d0..d2976644 100644 --- a/platformio/package/commands/install.py +++ b/platformio/package/commands/install.py @@ -20,6 +20,7 @@ import click from platformio import fs from platformio.package.exception import UnknownPackageError +from platformio.package.manager.core import get_core_package_dir from platformio.package.manager.library import LibraryPackageManager from platformio.package.manager.platform import PlatformPackageManager from platformio.package.manager.tool import ToolPackageManager @@ -120,7 +121,7 @@ def install_project_env_dependencies(project_env, options=None): # custom tools if options.get("tools"): installed_conds.append(_install_project_env_custom_tools(project_env, options)) - # custom ibraries + # custom libraries if options.get("libraries"): installed_conds.append( _install_project_env_custom_libraries(project_env, options) @@ -152,6 +153,8 @@ def _install_project_env_platform(project_env, options): skip_dependencies=options.get("skip_dependencies"), force=options.get("force"), ) + # ensure SCons is installed + get_core_package_dir("tool-scons") return not already_up_to_date From f1c445be150fa5af9030cdeec16efe92a38af9cc Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Thu, 31 Aug 2023 17:54:11 +0300 Subject: [PATCH 04/69] Bump version to 6.1.11 --- HISTORY.rst | 2 +- docs | 2 +- platformio/__init__.py | 2 +- tests/commands/pkg/test_install.py | 6 ++++-- tests/commands/pkg/test_uninstall.py | 3 ++- tests/commands/pkg/test_update.py | 4 +++- 6 files changed, 12 insertions(+), 7 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 251c7b80..6a5b2a0b 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -17,7 +17,7 @@ Unlock the true potential of embedded software development with PlatformIO's collaborative ecosystem, embracing declarative principles, test-driven methodologies, and modern toolchains for unrivaled success. -6.1.11 (2023-??-??) +6.1.11 (2023-08-31) ~~~~~~~~~~~~~~~~~~~ * Resolved a possible issue that may cause generated projects for `PlatformIO IDE for VSCode `__ to fail to launch a debug session because of a missing "objdump" binary when GDB is not part of the toolchain package diff --git a/docs b/docs index fb5dbb92..fb83b09c 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit fb5dbb92e5865de7f96b49704ea8383e877ab99a +Subproject commit fb83b09c415516ec37018b10d801ddf5c946d794 diff --git a/platformio/__init__.py b/platformio/__init__.py index 4a563660..c0226cf3 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -VERSION = (6, 1, "11a2") +VERSION = (6, 1, 11) __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" diff --git a/tests/commands/pkg/test_install.py b/tests/commands/pkg/test_install.py index ea995c68..edcbc241 100644 --- a/tests/commands/pkg/test_install.py +++ b/tests/commands/pkg/test_install.py @@ -18,7 +18,7 @@ import os import pytest -from platformio import fs +from platformio import __core_packages__, fs from platformio.package.commands.install import package_install_cmd from platformio.package.manager.library import LibraryPackageManager from platformio.package.manager.platform import PlatformPackageManager @@ -148,7 +148,7 @@ def test_skip_dependencies( ), PackageSpec("ESPAsyncWebServer-esphome@2.1.0"), ] - assert len(ToolPackageManager().get_installed()) == 0 + assert len(ToolPackageManager().get_installed()) == 1 # SCons def test_baremetal_project( @@ -177,6 +177,7 @@ def test_baremetal_project( ), ] assert pkgs_to_specs(ToolPackageManager().get_installed()) == [ + PackageSpec("tool-scons@%s" % __core_packages__["tool-scons"][1:]), PackageSpec("toolchain-atmelavr@1.70300.191015"), ] @@ -209,6 +210,7 @@ def test_project( ] assert pkgs_to_specs(ToolPackageManager().get_installed()) == [ PackageSpec("framework-arduino-avr-attiny@1.5.2"), + PackageSpec("tool-scons@%s" % __core_packages__["tool-scons"][1:]), PackageSpec("toolchain-atmelavr@1.70300.191015"), ] assert config.get("env:devkit", "lib_deps") == [ diff --git a/tests/commands/pkg/test_uninstall.py b/tests/commands/pkg/test_uninstall.py index d776b142..73e2179a 100644 --- a/tests/commands/pkg/test_uninstall.py +++ b/tests/commands/pkg/test_uninstall.py @@ -198,6 +198,7 @@ def test_project(clirunner, validate_cliresult, isolated_pio_core, tmp_path): assert pkgs_to_names(lm.get_installed()) == ["DallasTemperature", "OneWire"] assert pkgs_to_names(ToolPackageManager().get_installed()) == [ "framework-arduino-avr-attiny", + "tool-scons", "toolchain-atmelavr", ] assert config.get("env:devkit", "lib_deps") == [ @@ -224,7 +225,7 @@ def test_project(clirunner, validate_cliresult, isolated_pio_core, tmp_path): os.path.join(config.get("platformio", "libdeps_dir"), "devkit") ) assert not pkgs_to_names(lm.get_installed()) - assert not pkgs_to_names(ToolPackageManager().get_installed()) + assert pkgs_to_names(ToolPackageManager().get_installed()) == ["tool-scons"] assert config.get("env:devkit", "lib_deps") == [ "milesburton/DallasTemperature@^3.9.1" ] diff --git a/tests/commands/pkg/test_update.py b/tests/commands/pkg/test_update.py index 06ab92a7..5656daac 100644 --- a/tests/commands/pkg/test_update.py +++ b/tests/commands/pkg/test_update.py @@ -16,7 +16,7 @@ import os -from platformio import fs +from platformio import __core_packages__, fs from platformio.package.commands.install import package_install_cmd from platformio.package.commands.update import package_update_cmd from platformio.package.exception import UnknownPackageError @@ -172,6 +172,7 @@ def test_project( ] assert pkgs_to_specs(ToolPackageManager().get_installed()) == [ PackageSpec("framework-arduino-avr-attiny@1.3.2"), + PackageSpec("tool-scons@%s" % __core_packages__["tool-scons"][1:]), PackageSpec("toolchain-atmelavr@1.50400.190710"), ] assert config.get("env:devkit", "lib_deps") == [ @@ -201,6 +202,7 @@ def test_project( ] assert pkgs_to_specs(ToolPackageManager().get_installed()) == [ PackageSpec("framework-arduino-avr-attiny@1.3.2"), + PackageSpec("tool-scons@%s" % __core_packages__["tool-scons"][1:]), PackageSpec("toolchain-atmelavr@1.70300.191015"), PackageSpec("toolchain-atmelavr@1.50400.190710"), ] From bd34c0f4377b23d5e73a66d3a0401be7a79a9c30 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Thu, 31 Aug 2023 17:55:04 +0300 Subject: [PATCH 05/69] Bump version to 6.1.12a1 --- platformio/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio/__init__.py b/platformio/__init__.py index c0226cf3..d8e1515b 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -VERSION = (6, 1, 11) +VERSION = (6, 1, "12a1") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" From 5cac6d8b88aed99a002284778662ba5241dd955b Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Thu, 31 Aug 2023 19:31:37 +0300 Subject: [PATCH 06/69] Bump version to 6.1.11 --- platformio/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio/__init__.py b/platformio/__init__.py index d8e1515b..c0226cf3 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -VERSION = (6, 1, "12a1") +VERSION = (6, 1, 11) __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" From f2eead6ece8dbd05eac8dc564b803c0c6b54db2b Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Thu, 31 Aug 2023 19:32:15 +0300 Subject: [PATCH 07/69] Bump version to 6.1.12a1 --- platformio/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio/__init__.py b/platformio/__init__.py index c0226cf3..d8e1515b 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -VERSION = (6, 1, 11) +VERSION = (6, 1, "12a1") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" From 091c96eb078964dd18eaa1cb9d84ee0079584e53 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Thu, 31 Aug 2023 19:40:20 +0300 Subject: [PATCH 08/69] Sync docs --- docs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs b/docs index fb83b09c..7299f77c 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit fb83b09c415516ec37018b10d801ddf5c946d794 +Subproject commit 7299f77c7cebe139d2ea60add841ea2da2b919a5 From fe52b79eb219045e84b3198e7281f0d28ea71d6b Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 13 Sep 2023 20:21:22 +0300 Subject: [PATCH 09/69] Docs: Fix example with the custom common options --- docs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs b/docs index 7299f77c..325ff802 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit 7299f77c7cebe139d2ea60add841ea2da2b919a5 +Subproject commit 325ff802d21a63d11958a266ccfcbfb5a74609d1 From 51b4cd88dbb5c717bffcbeda0c833eeea62699fa Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 22 Sep 2023 20:02:48 +0300 Subject: [PATCH 10/69] Docs: Add image with PlatformIO CLI for VSCode --- docs | 2 +- scripts/docspregen.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs b/docs index 325ff802..e44aa4b5 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit 325ff802d21a63d11958a266ccfcbfb5a74609d1 +Subproject commit e44aa4b57c93bb14437449784e8be9143e314438 diff --git a/scripts/docspregen.py b/scripts/docspregen.py index a4d56c03..1b595b3f 100644 --- a/scripts/docspregen.py +++ b/scripts/docspregen.py @@ -39,7 +39,7 @@ RST_COPYRIGHT = """.. Copyright (c) 2014-present PlatformIO Date: Sat, 23 Sep 2023 20:51:47 +0300 Subject: [PATCH 11/69] Sync docs --- docs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs b/docs index e44aa4b5..65bd3a5b 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit e44aa4b57c93bb14437449784e8be9143e314438 +Subproject commit 65bd3a5b71d98781236c2dfdf33f14711d00c22f From 3e95134721add8548f1f89b3234b8260ce218c62 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 29 Sep 2023 23:24:03 +0300 Subject: [PATCH 12/69] Sync docs --- docs | 2 +- examples | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs b/docs index 65bd3a5b..bfe7cb79 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit 65bd3a5b71d98781236c2dfdf33f14711d00c22f +Subproject commit bfe7cb790d911a45694ef0796b94562266e98df6 diff --git a/examples b/examples index 28c58d3b..2aa3bb92 160000 --- a/examples +++ b/examples @@ -1 +1 @@ -Subproject commit 28c58d3b7c4b88d3b1e0c1d2f7d99119a9c89c39 +Subproject commit 2aa3bb92c79ceb3b09e0b2c23eab724073ff7d8d From 7229e1cce4a06cc2f3b2cb6fbcb2ddddb77b0320 Mon Sep 17 00:00:00 2001 From: valeros Date: Sat, 30 Sep 2023 12:09:36 +0300 Subject: [PATCH 13/69] Add missing Zephyr project files in tests for PIO Check --- tests/commands/test_check.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/commands/test_check.py b/tests/commands/test_check.py index 5403ee0f..d50a79a4 100644 --- a/tests/commands/test_check.py +++ b/tests/commands/test_check.py @@ -540,6 +540,16 @@ int main() { """ ) + if framework == "zephyr": + zephyr_dir = tmpdir.mkdir("zephyr") + zephyr_dir.join("prj.conf").write("# nothing here") + zephyr_dir.join("CMakeLists.txt").write( + """cmake_minimum_required(VERSION 3.16.0) +find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) +project(hello_world) +target_sources(app PRIVATE ../src/main.c)""" + ) + tmpdir.join("platformio.ini").write(config) result = clirunner.invoke(cmd_check, ["--project-dir", str(tmpdir)]) validate_cliresult(result) From 2458309d553d2a5bdf99be16dc8f386a7d042fdc Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Mon, 9 Oct 2023 11:41:01 +0300 Subject: [PATCH 14/69] Update SPDX to 3.22 --- docs | 2 +- platformio/package/manifest/schema.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs b/docs index bfe7cb79..2b5c9e4b 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit bfe7cb790d911a45694ef0796b94562266e98df6 +Subproject commit 2b5c9e4bda50a0992f8e7628bc6ef5bf25b883ea diff --git a/platformio/package/manifest/schema.py b/platformio/package/manifest/schema.py index 95e08108..eeffd83e 100644 --- a/platformio/package/manifest/schema.py +++ b/platformio/package/manifest/schema.py @@ -276,7 +276,7 @@ class ManifestSchema(BaseSchema): @staticmethod @memoized(expire="1h") def load_spdx_licenses(): - version = "3.21" + version = "3.22" spdx_data_url = ( "https://raw.githubusercontent.com/spdx/license-list-data/" f"v{version}/json/licenses.json" From 5548197a749fbba981fc09ca03e8ba8ccbb1981d Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Mon, 9 Oct 2023 11:41:22 +0300 Subject: [PATCH 15/69] Update "pyelftools" to 0.30 --- platformio/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio/__init__.py b/platformio/__init__.py index d8e1515b..2ea56425 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -59,7 +59,7 @@ __install_requires__ = [ "click >=8.0.4, <=8.2", "colorama", "marshmallow == 3.*", - "pyelftools == 0.29", + "pyelftools == 0.30", "pyserial == 3.5.*", # keep in sync "device/monitor/terminal.py" "requests == 2.*", "semantic_version == 2.10.*", From 9c61ef544d8013f9eae2d9e78d0105391bdc3db4 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Mon, 16 Oct 2023 00:01:05 +0300 Subject: [PATCH 16/69] Fix test --- tests/package/test_manager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/package/test_manager.py b/tests/package/test_manager.py index c1de90b1..fa3f215c 100644 --- a/tests/package/test_manager.py +++ b/tests/package/test_manager.py @@ -651,4 +651,4 @@ def test_update_without_metadata(isolated_pio_core, tmpdir_factory): lm.set_log_level(logging.ERROR) new_pkg = lm.update(pkg) assert len(lm.get_installed()) == 4 - assert new_pkg.metadata.spec.owner == "ottowinter" + assert new_pkg.metadata.spec.owner == "heman" From 5f8c15b96a0fe4d2f9dd490c34834f0fa17295fa Mon Sep 17 00:00:00 2001 From: Jakob <78532991+jake-is-ESD-protected@users.noreply.github.com> Date: Sun, 15 Oct 2023 23:01:23 +0200 Subject: [PATCH 17/69] add Espressif USB JTAG/serial debug unit to udev (#4759) --- platformio/assets/system/99-platformio-udev.rules | 3 +++ 1 file changed, 3 insertions(+) diff --git a/platformio/assets/system/99-platformio-udev.rules b/platformio/assets/system/99-platformio-udev.rules index a5897f8f..992676db 100644 --- a/platformio/assets/system/99-platformio-udev.rules +++ b/platformio/assets/system/99-platformio-udev.rules @@ -171,3 +171,6 @@ ATTRS{product}=="*CMSIS-DAP*", MODE="0666", ENV{ID_MM_DEVICE_IGNORE}="1", ENV{ID # Atmel AVR Dragon ATTRS{idVendor}=="03eb", ATTRS{idProduct}=="2107", MODE="0666", ENV{ID_MM_DEVICE_IGNORE}="1", ENV{ID_MM_PORT_IGNORE}="1" + +# Espressif USB JTAG/serial debug unit +ATTRS{idVendor}=="303a", ATTR{idProduct}=="1001", MODE="0666", ENV{ID_MM_DEVICE_IGNORE}="1", ENV{ID_MM_PORT_IGNORE}="1" \ No newline at end of file From e78bf51f68dd57554b3c7d9b0ad7518fda552b58 Mon Sep 17 00:00:00 2001 From: Pierre Baudin <34721711+pvbaudin@users.noreply.github.com> Date: Thu, 16 Nov 2023 08:44:32 -0800 Subject: [PATCH 18/69] Issue #4762 compiledb include toolchains with user defined libs (#4763) Issue #4762 separated out the optional addition of toolchains to compiledb include paths and added a call to it in the library building step for user defined libraries, allowing the automatic inclusion of toolchains in private lib compiledb generation --- platformio/builder/tools/piobuild.py | 8 ++++++++ platformio/builder/tools/piolib.py | 2 ++ 2 files changed, 10 insertions(+) diff --git a/platformio/builder/tools/piobuild.py b/platformio/builder/tools/piobuild.py index 74725a02..f3f583c5 100644 --- a/platformio/builder/tools/piobuild.py +++ b/platformio/builder/tools/piobuild.py @@ -126,6 +126,12 @@ def ProcessProgramDeps(env): # remove specified flags env.ProcessUnFlags(env.get("BUILD_UNFLAGS")) + env.ProcessCompileDbToolchainOption() + + +def ProcessCompileDbToolchainOption( + env, +): # separated out to selectively add to lib build step if "compiledb" in COMMAND_LINE_TARGETS: # Resolve absolute path of toolchain for cmd in ("CC", "CXX", "AS"): @@ -138,6 +144,7 @@ def ProcessProgramDeps(env): ) if env.get("COMPILATIONDB_INCLUDE_TOOLCHAIN"): + print("Warning! `COMPILATIONDB_INCLUDE_TOOLCHAIN` is scoping") for scope, includes in env.DumpIntegrationIncludes().items(): if scope in ("toolchain",): env.Append(CPPPATH=includes) @@ -376,6 +383,7 @@ def generate(env): env.AddMethod(GetBuildType) env.AddMethod(BuildProgram) env.AddMethod(ProcessProgramDeps) + env.AddMethod(ProcessCompileDbToolchainOption) env.AddMethod(ProcessProjectDeps) env.AddMethod(ParseFlagsExtended) env.AddMethod(ProcessFlags) diff --git a/platformio/builder/tools/piolib.py b/platformio/builder/tools/piolib.py index dee1d5bc..a6833680 100644 --- a/platformio/builder/tools/piolib.py +++ b/platformio/builder/tools/piolib.py @@ -478,6 +478,8 @@ class LibBuilderBase: self.env.PrependUnique(CPPPATH=self.get_include_dirs()) + self.env.ProcessCompileDbToolchainOption() + if self.lib_ldf_mode == "off": for lb in self.env.GetLibBuilders(): if self == lb or not lb.is_built: From 7ab27ddf9dfc11d3421c13385e328d1651514d96 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Thu, 16 Nov 2023 18:54:45 +0200 Subject: [PATCH 19/69] Resolved an issue where the ``COMPILATIONDB_INCLUDE_TOOLCHAIN`` setting was not correctly applying to private libraries // Resolve #4762 --- HISTORY.rst | 5 +++++ docs | 2 +- platformio/__init__.py | 2 +- platformio/builder/tools/piobuild.py | 4 +--- platformio/builder/tools/piolib.py | 1 - 5 files changed, 8 insertions(+), 6 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 6a5b2a0b..18f5a313 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -17,6 +17,11 @@ Unlock the true potential of embedded software development with PlatformIO's collaborative ecosystem, embracing declarative principles, test-driven methodologies, and modern toolchains for unrivaled success. +6.1.12 (2023-??-??) +~~~~~~~~~~~~~~~~~~~ + +* Resolved an issue where the ``COMPILATIONDB_INCLUDE_TOOLCHAIN`` setting was not correctly applying to private libraries (`issue #4762 `_) + 6.1.11 (2023-08-31) ~~~~~~~~~~~~~~~~~~~ diff --git a/docs b/docs index 2b5c9e4b..07f966a6 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit 2b5c9e4bda50a0992f8e7628bc6ef5bf25b883ea +Subproject commit 07f966a65c2392cae4bcfc1b0e4f9f8a85b831d0 diff --git a/platformio/__init__.py b/platformio/__init__.py index 2ea56425..9a8932bc 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -VERSION = (6, 1, "12a1") +VERSION = (6, 1, "12a2") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" diff --git a/platformio/builder/tools/piobuild.py b/platformio/builder/tools/piobuild.py index f3f583c5..047090c7 100644 --- a/platformio/builder/tools/piobuild.py +++ b/platformio/builder/tools/piobuild.py @@ -129,9 +129,7 @@ def ProcessProgramDeps(env): env.ProcessCompileDbToolchainOption() -def ProcessCompileDbToolchainOption( - env, -): # separated out to selectively add to lib build step +def ProcessCompileDbToolchainOption(env): if "compiledb" in COMMAND_LINE_TARGETS: # Resolve absolute path of toolchain for cmd in ("CC", "CXX", "AS"): diff --git a/platformio/builder/tools/piolib.py b/platformio/builder/tools/piolib.py index a6833680..70b0811c 100644 --- a/platformio/builder/tools/piolib.py +++ b/platformio/builder/tools/piolib.py @@ -477,7 +477,6 @@ class LibBuilderBase: self.is_built = True self.env.PrependUnique(CPPPATH=self.get_include_dirs()) - self.env.ProcessCompileDbToolchainOption() if self.lib_ldf_mode == "off": From 0b3c0144e6b086d1c46aa515c57227ae5a48d10d Mon Sep 17 00:00:00 2001 From: "D. Stuart Freeman" Date: Thu, 16 Nov 2023 11:57:16 -0500 Subject: [PATCH 20/69] fix get_systype() on raspbian (#4784) fix get_systype on raspbian fixes #4777 --- platformio/util.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/platformio/util.py b/platformio/util.py index 004ac5c9..bb3679fe 100644 --- a/platformio/util.py +++ b/platformio/util.py @@ -143,6 +143,8 @@ def get_systype(): arch = "x86_" + platform.architecture()[0] if "x86" in arch: arch = "amd64" if "64" in arch else "x86" + if arch == "aarch64" and platform.architecture()[0] == "32bit": + arch = "armv7l" return "%s_%s" % (system, arch) if arch else system From 540465291a3a0aacbf7c82a5b9928e55c872f579 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Thu, 16 Nov 2023 19:01:24 +0200 Subject: [PATCH 21/69] Resolved an issue where ``get_systype()`` inaccurately returned the architecture // Resolve #4777 --- HISTORY.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/HISTORY.rst b/HISTORY.rst index 18f5a313..2587d2bc 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -21,6 +21,7 @@ test-driven methodologies, and modern toolchains for unrivaled success. ~~~~~~~~~~~~~~~~~~~ * Resolved an issue where the ``COMPILATIONDB_INCLUDE_TOOLCHAIN`` setting was not correctly applying to private libraries (`issue #4762 `_) +* Resolved an issue where ``get_systype()`` inaccurately returned the architecture when executed within a Docker container on a 64-bit kernel with a 32-bit userspace (`issue #4777 `_) 6.1.11 (2023-08-31) ~~~~~~~~~~~~~~~~~~~ From f70e6d50c6e77df01b443066a171236a0ecc7846 Mon Sep 17 00:00:00 2001 From: Ryan Govostes Date: Thu, 16 Nov 2023 09:59:30 -0800 Subject: [PATCH 22/69] Remove unused build output buffer (#4786) * Remove unused build output buffer * Update proc.py * Update proc.py --------- Co-authored-by: Ivan Kravets --- platformio/proc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio/proc.py b/platformio/proc.py index acfce4d9..707245a1 100644 --- a/platformio/proc.py +++ b/platformio/proc.py @@ -69,7 +69,7 @@ class BuildAsyncPipe(AsyncPipeBase): print_immediately = False for char in iter(lambda: self._pipe_reader.read(1), ""): - self._buffer += char + # self._buffer += char if line and char.strip() and line[-3:] == (char * 3): print_immediately = True From e1f34c7ea064f923dd9481a919e198642f957595 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Thu, 16 Nov 2023 20:05:44 +0200 Subject: [PATCH 23/69] Drastically enhanced the speed of project building when operating in verbose mode // Resolve #4783 --- HISTORY.rst | 1 + tests/commands/pkg/test_install.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/HISTORY.rst b/HISTORY.rst index 2587d2bc..8f2ee0ca 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -20,6 +20,7 @@ test-driven methodologies, and modern toolchains for unrivaled success. 6.1.12 (2023-??-??) ~~~~~~~~~~~~~~~~~~~ +* Drastically enhanced the speed of project building when operating in verbose mode (`issue #4783 `_) * Resolved an issue where the ``COMPILATIONDB_INCLUDE_TOOLCHAIN`` setting was not correctly applying to private libraries (`issue #4762 `_) * Resolved an issue where ``get_systype()`` inaccurately returned the architecture when executed within a Docker container on a 64-bit kernel with a 32-bit userspace (`issue #4777 `_) diff --git a/tests/commands/pkg/test_install.py b/tests/commands/pkg/test_install.py index edcbc241..22963ef9 100644 --- a/tests/commands/pkg/test_install.py +++ b/tests/commands/pkg/test_install.py @@ -445,7 +445,7 @@ def test_custom_project_libraries( ) assert pkgs_to_specs(lm.get_installed()) == [ PackageSpec("ArduinoJson@5.13.4"), - PackageSpec("Nanopb@0.4.7"), + PackageSpec("Nanopb@0.4.8"), ] assert config.get("env:devkit", "lib_deps") == [ "bblanchon/ArduinoJson@^5", From 961ab6b35ea6cf4fd917694545f9b474248001f0 Mon Sep 17 00:00:00 2001 From: valeros Date: Fri, 17 Nov 2023 13:12:40 +0200 Subject: [PATCH 24/69] Properly handle the `check_src_filters` option per environment Resolves #4788 --- HISTORY.rst | 2 ++ platformio/check/cli.py | 4 ++-- tests/commands/test_check.py | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 2 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 8f2ee0ca..579c1e70 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -23,6 +23,8 @@ test-driven methodologies, and modern toolchains for unrivaled success. * Drastically enhanced the speed of project building when operating in verbose mode (`issue #4783 `_) * Resolved an issue where the ``COMPILATIONDB_INCLUDE_TOOLCHAIN`` setting was not correctly applying to private libraries (`issue #4762 `_) * Resolved an issue where ``get_systype()`` inaccurately returned the architecture when executed within a Docker container on a 64-bit kernel with a 32-bit userspace (`issue #4777 `_) +* Resolved an issue with incorrect handling of the ``check_src_filters`` option when used in multiple environments (`issue #4788 `_) + 6.1.11 (2023-08-31) ~~~~~~~~~~~~~~~~~~~ diff --git a/platformio/check/cli.py b/platformio/check/cli.py index d99da313..1deced87 100644 --- a/platformio/check/cli.py +++ b/platformio/check/cli.py @@ -108,7 +108,7 @@ def cli( "+<%s>" % os.path.basename(config.get("platformio", "include_dir")), ] - src_filters = ( + env_src_filters = ( src_filters or pattern or env_options.get( @@ -120,7 +120,7 @@ def cli( tool_options = dict( verbose=verbose, silent=silent, - src_filters=src_filters, + src_filters=env_src_filters, flags=flags or env_options.get("check_flags"), severity=[DefectItem.SEVERITY_LABELS[DefectItem.SEVERITY_HIGH]] if silent diff --git a/tests/commands/test_check.py b/tests/commands/test_check.py index d50a79a4..a9a99d65 100644 --- a/tests/commands/test_check.py +++ b/tests/commands/test_check.py @@ -767,3 +767,39 @@ check_patterns = assert errors + warnings + style == EXPECTED_DEFECTS * 2 assert "main.cpp" not in result.output + + +def test_check_src_filter_multiple_envs(clirunner, validate_cliresult, tmpdir_factory): + tmpdir = tmpdir_factory.mktemp("project") + + config = """ +[env] +check_tool = cppcheck +check_src_filters = + + + +[env:check_sources] +platform = native + +[env:check_tests] +platform = native +check_src_filters = + + + """ + tmpdir.join("platformio.ini").write(config) + + src_dir = tmpdir.mkdir("src") + src_dir.join("main.cpp").write(TEST_CODE) + src_dir.mkdir("spi").join("spi.cpp").write(TEST_CODE) + tmpdir.mkdir("test").join("test.cpp").write(TEST_CODE) + + result = clirunner.invoke( + cmd_check, ["--project-dir", str(tmpdir), "-e", "check_tests"] + ) + validate_cliresult(result) + + errors, warnings, style = count_defects(result.output) + + assert errors + warnings + style == EXPECTED_DEFECTS + assert "test.cpp" in result.output + assert "main.cpp" not in result.output From b238c55e53a910c158f4c4766b24f417e69de535 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Tue, 28 Nov 2023 18:15:16 +0200 Subject: [PATCH 25/69] Introduced a warning during the verification of MCU maximum RAM usage // Resolve #4791 --- HISTORY.rst | 2 +- platformio/builder/tools/pioupload.py | 11 +++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 579c1e70..b35a8744 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -20,12 +20,12 @@ test-driven methodologies, and modern toolchains for unrivaled success. 6.1.12 (2023-??-??) ~~~~~~~~~~~~~~~~~~~ +* Introduced a warning during the verification of MCU maximum RAM usage, signaling when the allocated RAM surpasses 100% (`issue #4791 `_) * Drastically enhanced the speed of project building when operating in verbose mode (`issue #4783 `_) * Resolved an issue where the ``COMPILATIONDB_INCLUDE_TOOLCHAIN`` setting was not correctly applying to private libraries (`issue #4762 `_) * Resolved an issue where ``get_systype()`` inaccurately returned the architecture when executed within a Docker container on a 64-bit kernel with a 32-bit userspace (`issue #4777 `_) * Resolved an issue with incorrect handling of the ``check_src_filters`` option when used in multiple environments (`issue #4788 `_) - 6.1.11 (2023-08-31) ~~~~~~~~~~~~~~~~~~~ diff --git a/platformio/builder/tools/pioupload.py b/platformio/builder/tools/pioupload.py index 77bf28d2..224d0b90 100644 --- a/platformio/builder/tools/pioupload.py +++ b/platformio/builder/tools/pioupload.py @@ -218,12 +218,11 @@ def CheckUploadSize(_, target, source, env): if int(ARGUMENTS.get("PIOVERBOSE", 0)): print(output) - # raise error - # if data_max_size and data_size > data_max_size: - # sys.stderr.write( - # "Error: The data size (%d bytes) is greater " - # "than maximum allowed (%s bytes)\n" % (data_size, data_max_size)) - # env.Exit(1) + if data_max_size and data_size > data_max_size: + sys.stderr.write( + "Warning! The data size (%d bytes) is greater " + "than maximum allowed (%s bytes)\n" % (data_size, data_max_size) + ) if program_size > program_max_size: sys.stderr.write( "Error: The program size (%d bytes) is greater " From ac6d94860b1d742a721969625e0bd1b2ce483e92 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 1 Dec 2023 15:55:36 +0200 Subject: [PATCH 26/69] Update deps --- platformio/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio/__init__.py b/platformio/__init__.py index 9a8932bc..05168327 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -67,7 +67,7 @@ __install_requires__ = [ ] + [ # PIO Home requirements "ajsonrpc == 1.2.*", - "starlette >=0.19, <0.32", + "starlette >=0.19, <0.33", "uvicorn >=0.16, <0.24", "wsproto == 1.*", ] From 11df0217501a7aaf9f78a32cf52b69dc14c1fcb1 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 1 Dec 2023 19:38:25 +0200 Subject: [PATCH 27/69] Resolve an issue where running `pio project metadata` resulted in duplicated include entries // Resolve #4723 --- HISTORY.rst | 1 + platformio/builder/tools/piointegration.py | 7 +- platformio/builder/tools/piolib.py | 4 +- tests/project/test_metadata.py | 82 ++++++++++++++++++++++ 4 files changed, 87 insertions(+), 7 deletions(-) create mode 100644 tests/project/test_metadata.py diff --git a/HISTORY.rst b/HISTORY.rst index b35a8744..778042b0 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -25,6 +25,7 @@ test-driven methodologies, and modern toolchains for unrivaled success. * Resolved an issue where the ``COMPILATIONDB_INCLUDE_TOOLCHAIN`` setting was not correctly applying to private libraries (`issue #4762 `_) * Resolved an issue where ``get_systype()`` inaccurately returned the architecture when executed within a Docker container on a 64-bit kernel with a 32-bit userspace (`issue #4777 `_) * Resolved an issue with incorrect handling of the ``check_src_filters`` option when used in multiple environments (`issue #4788 `_) +* Resolved an issue where running `pio project metadata `__ resulted in duplicated include entries (`issue #4723 `_) 6.1.11 (2023-08-31) ~~~~~~~~~~~~~~~~~~~ diff --git a/platformio/builder/tools/piointegration.py b/platformio/builder/tools/piointegration.py index 6f0a972e..00ecb88a 100644 --- a/platformio/builder/tools/piointegration.py +++ b/platformio/builder/tools/piointegration.py @@ -29,12 +29,7 @@ def IsIntegrationDump(_): def DumpIntegrationIncludes(env): result = dict(build=[], compatlib=[], toolchain=[]) - result["build"].extend( - [ - env.subst("$PROJECT_INCLUDE_DIR"), - env.subst("$PROJECT_SRC_DIR"), - ] - ) + # `env`(project) CPPPATH result["build"].extend( [os.path.abspath(env.subst(item)) for item in env.get("CPPPATH", [])] ) diff --git a/platformio/builder/tools/piolib.py b/platformio/builder/tools/piolib.py index 70b0811c..aa18cd1a 100644 --- a/platformio/builder/tools/piolib.py +++ b/platformio/builder/tools/piolib.py @@ -792,7 +792,9 @@ class PlatformIOLibBuilder(LibBuilderBase): include_dirs.append(os.path.join(self.path, "utility")) for path in self.env.get("CPPPATH", []): - if path not in self.envorigin.get("CPPPATH", []): + if path not in include_dirs and path not in self.envorigin.get( + "CPPPATH", [] + ): include_dirs.append(self.env.subst(path)) return include_dirs diff --git a/tests/project/test_metadata.py b/tests/project/test_metadata.py new file mode 100644 index 00000000..a536dd72 --- /dev/null +++ b/tests/project/test_metadata.py @@ -0,0 +1,82 @@ +# Copyright (c) 2014-present PlatformIO +# +# 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 json + +from platformio.project.commands.metadata import project_metadata_cmd + + +def test_metadata_dump(clirunner, validate_cliresult, tmpdir): + tmpdir.join("platformio.ini").write( + """ +[env:native] +platform = native +""" + ) + + component_dir = tmpdir.mkdir("lib").mkdir("component") + component_dir.join("library.json").write( + """ +{ + "name": "component", + "version": "1.0.0" +} + """ + ) + component_dir.mkdir("include").join("component.h").write( + """ +#define I_AM_COMPONENT + +void dummy(void); + """ + ) + component_dir.mkdir("src").join("component.cpp").write( + """ +#include + +void dummy(void ) {}; + """ + ) + + tmpdir.mkdir("src").join("main.c").write( + """ +#include + +#ifndef I_AM_COMPONENT +#error "I_AM_COMPONENT" +#endif + +int main() { +} +""" + ) + + metadata_path = tmpdir.join("metadata.json") + result = clirunner.invoke( + project_metadata_cmd, + [ + "--project-dir", + str(tmpdir), + "-e", + "native", + "--json-output", + "--json-output-path", + str(metadata_path), + ], + ) + validate_cliresult(result) + with open(str(metadata_path), encoding="utf8") as fp: + metadata = json.load(fp)["native"] + assert len(metadata["includes"]["build"]) == 3 + assert len(metadata["includes"]["compatlib"]) == 2 From 984d63983df8c7033a5040fd617d385f22e8aee6 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 1 Dec 2023 20:28:25 +0200 Subject: [PATCH 28/69] Upgrade the build engine to the latest version of SCons (4.6.0) // Resolve #4789 --- HISTORY.rst | 3 ++- platformio/__init__.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 778042b0..b88d8b32 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -22,10 +22,11 @@ test-driven methodologies, and modern toolchains for unrivaled success. * Introduced a warning during the verification of MCU maximum RAM usage, signaling when the allocated RAM surpasses 100% (`issue #4791 `_) * Drastically enhanced the speed of project building when operating in verbose mode (`issue #4783 `_) +* Upgraded the build engine to the latest version of SCons (4.6.0) to improve build performance, reliability, and compatibility with other tools and systems (`release notes `__) * Resolved an issue where the ``COMPILATIONDB_INCLUDE_TOOLCHAIN`` setting was not correctly applying to private libraries (`issue #4762 `_) * Resolved an issue where ``get_systype()`` inaccurately returned the architecture when executed within a Docker container on a 64-bit kernel with a 32-bit userspace (`issue #4777 `_) * Resolved an issue with incorrect handling of the ``check_src_filters`` option when used in multiple environments (`issue #4788 `_) -* Resolved an issue where running `pio project metadata `__ resulted in duplicated include entries (`issue #4723 `_) +* Resolved an issue where running `pio project metadata `__ resulted in duplicated "include" entries (`issue #4723 `_) 6.1.11 (2023-08-31) ~~~~~~~~~~~~~~~~~~~ diff --git a/platformio/__init__.py b/platformio/__init__.py index 05168327..156f45fb 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -41,7 +41,7 @@ __pioremote_endpoint__ = "ssl:host=remote.platformio.org:port=4413" __core_packages__ = { "contrib-piohome": "~3.4.2", "contrib-pioremote": "~1.0.0", - "tool-scons": "~4.40502.0", + "tool-scons": "~4.40600.0", "tool-cppcheck": "~1.21100.0", "tool-clangtidy": "~1.150005.0", "tool-pvs-studio": "~7.18.0", From 827bd09c618e2257fd7972186235b894cc0b5add Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 1 Dec 2023 20:28:50 +0200 Subject: [PATCH 29/69] Bump version to 6.1.12a3 --- platformio/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio/__init__.py b/platformio/__init__.py index 156f45fb..5c82336a 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -VERSION = (6, 1, "12a2") +VERSION = (6, 1, "12a3") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" From fb93c1937c6621acd2abf34f1fbae938ea1387cf Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Thu, 7 Dec 2023 14:09:11 +0200 Subject: [PATCH 30/69] Provide a map for `nrf52` and `rp2040` declared in library.properties // Resolve #4803 --- platformio/package/manifest/parser.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/platformio/package/manifest/parser.py b/platformio/package/manifest/parser.py index a70af7ea..d3fe6bfa 100644 --- a/platformio/package/manifest/parser.py +++ b/platformio/package/manifest/parser.py @@ -540,6 +540,8 @@ class LibraryPropertiesManifestParser(BaseManifestParser): "esp32": "espressif32", "arc32": "intel_arc32", "stm32": "ststm32", + "nrf52": "nordicnrf52", + "rp2040": "raspberrypi", } for arch in properties.get("architectures", "").split(","): if "particle-" in arch: From 8c61f0f6b6e0f741410324136629b8b82e8122ec Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 8 Dec 2023 19:12:00 +0200 Subject: [PATCH 31/69] Enhanced the handling of built-in variables during interpolation // Resolve #4695 --- HISTORY.rst | 1 + docs | 2 +- platformio/__init__.py | 2 +- platformio/project/config.py | 80 ++++++++++++++++++++++----------- platformio/project/exception.py | 2 +- platformio/project/options.py | 47 +++++-------------- tests/project/test_config.py | 18 ++++---- tox.ini | 2 +- 8 files changed, 79 insertions(+), 75 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index b88d8b32..2adfdf86 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -23,6 +23,7 @@ test-driven methodologies, and modern toolchains for unrivaled success. * Introduced a warning during the verification of MCU maximum RAM usage, signaling when the allocated RAM surpasses 100% (`issue #4791 `_) * Drastically enhanced the speed of project building when operating in verbose mode (`issue #4783 `_) * Upgraded the build engine to the latest version of SCons (4.6.0) to improve build performance, reliability, and compatibility with other tools and systems (`release notes `__) +* Enhanced the handling of built-in variables in |PIOCONF| during |INTERPOLATION| (`issue #4695 `_) * Resolved an issue where the ``COMPILATIONDB_INCLUDE_TOOLCHAIN`` setting was not correctly applying to private libraries (`issue #4762 `_) * Resolved an issue where ``get_systype()`` inaccurately returned the architecture when executed within a Docker container on a 64-bit kernel with a 32-bit userspace (`issue #4777 `_) * Resolved an issue with incorrect handling of the ``check_src_filters`` option when used in multiple environments (`issue #4788 `_) diff --git a/docs b/docs index 07f966a6..5f5efa22 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit 07f966a65c2392cae4bcfc1b0e4f9f8a85b831d0 +Subproject commit 5f5efa22b88562fe755d206eea0faa2f097ea70c diff --git a/platformio/__init__.py b/platformio/__init__.py index 5c82336a..a61cd4f4 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -67,7 +67,7 @@ __install_requires__ = [ ] + [ # PIO Home requirements "ajsonrpc == 1.2.*", - "starlette >=0.19, <0.33", + "starlette >=0.19, <=0.33", "uvicorn >=0.16, <0.24", "wsproto == 1.*", ] diff --git a/platformio/project/config.py b/platformio/project/config.py index 8020fdd3..f19473f8 100644 --- a/platformio/project/config.py +++ b/platformio/project/config.py @@ -14,14 +14,16 @@ import configparser import glob +import hashlib import json import os import re +import time import click from platformio import fs -from platformio.compat import MISSING, string_types +from platformio.compat import MISSING, hashlib_encode_data, string_types from platformio.project import exception from platformio.project.options import ProjectOptions @@ -41,7 +43,17 @@ CONFIG_HEADER = """ class ProjectConfigBase: ENVNAME_RE = re.compile(r"^[a-z\d\_\-]+$", flags=re.I) INLINE_COMMENT_RE = re.compile(r"\s+;.*$") - VARTPL_RE = re.compile(r"\$\{([^\.\}\()]+)\.([^\}]+)\}") + VARTPL_RE = re.compile(r"\$\{(?:([^\.\}\()]+)\.)?([^\}]+)\}") + + BUILTIN_VARS = { + "PROJECT_DIR": lambda: os.getcwd(), # pylint: disable=unnecessary-lambda + "PROJECT_HASH": lambda: "%s-%s" + % ( + os.path.basename(os.getcwd()), + hashlib.sha1(hashlib_encode_data(os.getcwd())).hexdigest()[:10], + ), + "UNIX_TIME": lambda: str(int(time.time())), + } CUSTOM_OPTION_PREFIXES = ("custom_", "board_") @@ -274,7 +286,7 @@ class ProjectConfigBase: value = ( default if default != MISSING else self._parser.get(section, option) ) - return self._expand_interpolations(section, value) + return self._expand_interpolations(section, option, value) if option_meta.sysenvvar: envvar_value = os.getenv(option_meta.sysenvvar) @@ -297,24 +309,46 @@ class ProjectConfigBase: if value == MISSING: return None - return self._expand_interpolations(section, value) + return self._expand_interpolations(section, option, value) - def _expand_interpolations(self, parent_section, value): - if ( - not value - or not isinstance(value, string_types) - or not all(["${" in value, "}" in value]) - ): + def _expand_interpolations(self, section, option, value): + if not value or not isinstance(value, string_types) or not "$" in value: + return value + + # legacy support for variables delclared without "${}" + stop = False + while not stop: + stop = True + for name in self.BUILTIN_VARS: + x = value.find(f"${name}") + if x < 0 or value[x - 1] == "$": + continue + value = "%s${%s}%s" % (value[:x], name, value[x + len(name) + 1 :]) + stop = False + warn_msg = ( + "Invalid variable declaration. Please use " + f"`${{{name}}}` instead of `${name}`" + ) + if warn_msg not in self.warnings: + self.warnings.append(warn_msg) + + if not all(["${" in value, "}" in value]): return value return self.VARTPL_RE.sub( - lambda match: self._re_interpolation_handler(parent_section, match), value + lambda match: self._re_interpolation_handler(section, option, match), value ) - def _re_interpolation_handler(self, parent_section, match): + def _re_interpolation_handler(self, parent_section, parent_option, match): section, option = match.group(1), match.group(2) + + # handle built-in variables + if section is None and option in self.BUILTIN_VARS: + return self.BUILTIN_VARS[option]() + # handle system environment variables if section == "sysenv": return os.getenv(option) + # handle ${this.*} if section == "this": section = parent_section @@ -322,21 +356,18 @@ class ProjectConfigBase: if not parent_section.startswith("env:"): raise exception.ProjectOptionValueError( f"`${{this.__env__}}` is called from the `{parent_section}` " - "section that is not valid PlatformIO environment, see", - option, - " ", - section, + "section that is not valid PlatformIO environment. Please " + f"check `{parent_option}` option in the `{section}` section" ) return parent_section[4:] + # handle nested calls try: value = self.get(section, option) except RecursionError as exc: raise exception.ProjectOptionValueError( - "Infinite recursion has been detected", - option, - " ", - section, + f"Infinite recursion has been detected for `{option}` " + f"option in the `{section}` section" ) from exc if isinstance(value, list): return "\n".join(value) @@ -363,10 +394,8 @@ class ProjectConfigBase: if not self.expand_interpolations: return value raise exception.ProjectOptionValueError( - exc.format_message(), - option, - " (%s) " % option_meta.description, - section, + "%s for `%s` option in the `%s` section (%s)" + % (exc.format_message(), option, section, option_meta.description) ) @staticmethod @@ -439,8 +468,9 @@ class ProjectConfigLintMixin: try: config = cls.get_instance(path) config.validate(silent=True) - warnings = config.warnings + warnings = config.warnings # in case "as_tuple" fails config.as_tuple() + warnings = config.warnings except Exception as exc: # pylint: disable=broad-exception-caught if exc.__cause__ is not None: exc = exc.__cause__ diff --git a/platformio/project/exception.py b/platformio/project/exception.py index 3821c865..cf97c69e 100644 --- a/platformio/project/exception.py +++ b/platformio/project/exception.py @@ -51,4 +51,4 @@ class InvalidEnvNameError(ProjectError, UserSideException): class ProjectOptionValueError(ProjectError, UserSideException): - MESSAGE = "{0} for option `{1}`{2}in section [{3}]" + pass diff --git a/platformio/project/options.py b/platformio/project/options.py index 2e13815a..70f3219e 100644 --- a/platformio/project/options.py +++ b/platformio/project/options.py @@ -14,14 +14,13 @@ # pylint: disable=redefined-builtin, too-many-arguments -import hashlib import os from collections import OrderedDict import click from platformio import fs -from platformio.compat import IS_WINDOWS, hashlib_encode_data +from platformio.compat import IS_WINDOWS class ConfigOption: # pylint: disable=too-many-instance-attributes @@ -80,30 +79,6 @@ def ConfigEnvOption(*args, **kwargs): return ConfigOption("env", *args, **kwargs) -def calculate_path_hash(path): - return "%s-%s" % ( - os.path.basename(path), - hashlib.sha1(hashlib_encode_data(path)).hexdigest()[:10], - ) - - -def expand_dir_templates(path): - project_dir = os.getcwd() - tpls = { - "$PROJECT_DIR": lambda: project_dir, - "$PROJECT_HASH": lambda: calculate_path_hash(project_dir), - } - done = False - while not done: - done = True - for tpl, cb in tpls.items(): - if tpl not in path: - continue - path = path.replace(tpl, cb()) - done = False - return path - - def validate_dir(path): if not path: return path @@ -112,8 +87,6 @@ def validate_dir(path): return path if path.startswith("~"): path = fs.expanduser(path) - if "$" in path: - path = expand_dir_templates(path) return os.path.abspath(path) @@ -240,7 +213,7 @@ ProjectOptions = OrderedDict( "external library dependencies" ), sysenvvar="PLATFORMIO_WORKSPACE_DIR", - default=os.path.join("$PROJECT_DIR", ".pio"), + default=os.path.join("${PROJECT_DIR}", ".pio"), validate=validate_dir, ), ConfigPlatformioOption( @@ -274,7 +247,7 @@ ProjectOptions = OrderedDict( "System automatically adds this path to CPPPATH scope" ), sysenvvar="PLATFORMIO_INCLUDE_DIR", - default=os.path.join("$PROJECT_DIR", "include"), + default=os.path.join("${PROJECT_DIR}", "include"), validate=validate_dir, ), ConfigPlatformioOption( @@ -285,7 +258,7 @@ ProjectOptions = OrderedDict( "project C/C++ source files" ), sysenvvar="PLATFORMIO_SRC_DIR", - default=os.path.join("$PROJECT_DIR", "src"), + default=os.path.join("${PROJECT_DIR}", "src"), validate=validate_dir, ), ConfigPlatformioOption( @@ -293,7 +266,7 @@ ProjectOptions = OrderedDict( name="lib_dir", description="A storage for the custom/private project libraries", sysenvvar="PLATFORMIO_LIB_DIR", - default=os.path.join("$PROJECT_DIR", "lib"), + default=os.path.join("${PROJECT_DIR}", "lib"), validate=validate_dir, ), ConfigPlatformioOption( @@ -304,7 +277,7 @@ ProjectOptions = OrderedDict( "file system (SPIFFS, etc.)" ), sysenvvar="PLATFORMIO_DATA_DIR", - default=os.path.join("$PROJECT_DIR", "data"), + default=os.path.join("${PROJECT_DIR}", "data"), validate=validate_dir, ), ConfigPlatformioOption( @@ -315,7 +288,7 @@ ProjectOptions = OrderedDict( "test source files" ), sysenvvar="PLATFORMIO_TEST_DIR", - default=os.path.join("$PROJECT_DIR", "test"), + default=os.path.join("${PROJECT_DIR}", "test"), validate=validate_dir, ), ConfigPlatformioOption( @@ -323,7 +296,7 @@ ProjectOptions = OrderedDict( name="boards_dir", description="A storage for custom board manifests", sysenvvar="PLATFORMIO_BOARDS_DIR", - default=os.path.join("$PROJECT_DIR", "boards"), + default=os.path.join("${PROJECT_DIR}", "boards"), validate=validate_dir, ), ConfigPlatformioOption( @@ -331,7 +304,7 @@ ProjectOptions = OrderedDict( name="monitor_dir", description="A storage for custom monitor filters", sysenvvar="PLATFORMIO_MONITOR_DIR", - default=os.path.join("$PROJECT_DIR", "monitor"), + default=os.path.join("${PROJECT_DIR}", "monitor"), validate=validate_dir, ), ConfigPlatformioOption( @@ -342,7 +315,7 @@ ProjectOptions = OrderedDict( "synchronize extra files between remote machines" ), sysenvvar="PLATFORMIO_SHARED_DIR", - default=os.path.join("$PROJECT_DIR", "shared"), + default=os.path.join("${PROJECT_DIR}", "shared"), validate=validate_dir, ), # diff --git a/tests/project/test_config.py b/tests/project/test_config.py index 6b742855..47c8f283 100644 --- a/tests/project/test_config.py +++ b/tests/project/test_config.py @@ -33,7 +33,6 @@ BASE_CONFIG = """ [platformio] env_default = base, extra_2 src_dir = ${custom.src_dir} -build_dir = ${custom.build_dir} extra_configs = extra_envs.ini extra_debug.ini @@ -61,7 +60,6 @@ build_flags = -D RELEASE [custom] src_dir = source -build_dir = ~/tmp/pio-$PROJECT_HASH debug_flags = -D RELEASE lib_flags = -lc -lm extra_flags = ${sysenv.__PIO_TEST_CNF_EXTRA_FLAGS} @@ -319,7 +317,6 @@ def test_getraw_value(config): config.getraw("custom", "debug_server") == f"\n{packages_dir}/tool-openocd/openocd\n--help" ) - assert config.getraw("platformio", "build_dir") == "~/tmp/pio-$PROJECT_HASH" # renamed option assert config.getraw("env:extra_1", "lib_install") == "574" @@ -360,7 +357,6 @@ def test_get_value(config): assert config.get("platformio", "src_dir") == os.path.abspath( os.path.join(os.getcwd(), "source") ) - assert "$PROJECT_HASH" not in config.get("platformio", "build_dir") # renamed option assert config.get("env:extra_1", "lib_install") == ["574"] @@ -371,7 +367,6 @@ def test_get_value(config): def test_items(config): assert config.items("custom") == [ ("src_dir", "source"), - ("build_dir", "~/tmp/pio-$PROJECT_HASH"), ("debug_flags", "-D DEBUG=1"), ("lib_flags", "-lc -lm"), ("extra_flags", ""), @@ -525,7 +520,6 @@ def test_dump(tmpdir_factory): [ ("env_default", ["base", "extra_2"]), ("src_dir", "${custom.src_dir}"), - ("build_dir", "${custom.build_dir}"), ("extra_configs", ["extra_envs.ini", "extra_debug.ini"]), ], ), @@ -549,7 +543,6 @@ def test_dump(tmpdir_factory): "custom", [ ("src_dir", "source"), - ("build_dir", "~/tmp/pio-$PROJECT_HASH"), ("debug_flags", "-D RELEASE"), ("lib_flags", "-lc -lm"), ("extra_flags", "${sysenv.__PIO_TEST_CNF_EXTRA_FLAGS}"), @@ -636,9 +629,10 @@ def test_nested_interpolation(tmp_path: Path): project_conf.write_text( """ [platformio] -build_dir = ~/tmp/pio-$PROJECT_HASH +build_dir = /tmp/pio-$PROJECT_HASH [env:myenv] +build_flags = -D UTIME=${UNIX_TIME} test_testing_command = ${platformio.packages_dir}/tool-simavr/bin/simavr -m @@ -651,6 +645,7 @@ test_testing_command = config = ProjectConfig(str(project_conf)) testing_command = config.get("env:myenv", "test_testing_command") assert "$" not in " ".join(testing_command) + assert config.get("env:myenv", "build_flags")[0][-10:].isdigit() def test_extends_order(tmp_path: Path): @@ -707,11 +702,16 @@ def test_linting_warnings(tmp_path: Path): project_conf = tmp_path / "platformio.ini" project_conf.write_text( """ +[platformio] +build_dir = /tmp/pio-$PROJECT_HASH + [env:app1] lib_use = 1 +test_testing_command = /usr/bin/flash-tool -p $UPLOAD_PORT -b $UPLOAD_SPEED """ ) result = ProjectConfig.lint(str(project_conf)) assert not result["errors"] - assert result["warnings"] and len(result["warnings"]) == 1 + assert result["warnings"] and len(result["warnings"]) == 2 assert "deprecated" in result["warnings"][0] + assert "Invalid variable declaration" in result["warnings"][1] diff --git a/tox.ini b/tox.ini index 2eda9b90..02b96152 100644 --- a/tox.ini +++ b/tox.ini @@ -55,7 +55,7 @@ commands = [testenv:docs] deps = sphinx - sphinx-rtd-theme==1.2.2 + sphinx-rtd-theme==2.0.0 sphinx-notfound-page sphinx-copybutton restructuredtext-lint From 127b422d25cbe937c55828737536ca5393dff04c Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 8 Dec 2023 19:38:50 +0200 Subject: [PATCH 32/69] Rectified an issue where `${platformio.name}` erroneously represented `None` as the default project name // Resolve #4717 --- HISTORY.rst | 1 + platformio/project/options.py | 1 + tests/project/test_config.py | 24 ++++++++++++++++++++++++ 3 files changed, 26 insertions(+) diff --git a/HISTORY.rst b/HISTORY.rst index 2adfdf86..76c53d72 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -24,6 +24,7 @@ test-driven methodologies, and modern toolchains for unrivaled success. * Drastically enhanced the speed of project building when operating in verbose mode (`issue #4783 `_) * Upgraded the build engine to the latest version of SCons (4.6.0) to improve build performance, reliability, and compatibility with other tools and systems (`release notes `__) * Enhanced the handling of built-in variables in |PIOCONF| during |INTERPOLATION| (`issue #4695 `_) +* Rectified an issue where ``${platformio.name}`` erroneously represented ``None`` as the default `project name `__ (`issue #4717 `_) * Resolved an issue where the ``COMPILATIONDB_INCLUDE_TOOLCHAIN`` setting was not correctly applying to private libraries (`issue #4762 `_) * Resolved an issue where ``get_systype()`` inaccurately returned the architecture when executed within a Docker container on a 64-bit kernel with a 32-bit userspace (`issue #4777 `_) * Resolved an issue with incorrect handling of the ``check_src_filters`` option when used in multiple environments (`issue #4788 `_) diff --git a/platformio/project/options.py b/platformio/project/options.py index 70f3219e..51611d24 100644 --- a/platformio/project/options.py +++ b/platformio/project/options.py @@ -110,6 +110,7 @@ ProjectOptions = OrderedDict( group="generic", name="name", description="A project name", + default=lambda: os.path.basename(os.getcwd()), ), ConfigPlatformioOption( group="generic", diff --git a/tests/project/test_config.py b/tests/project/test_config.py index 47c8f283..6880dd7c 100644 --- a/tests/project/test_config.py +++ b/tests/project/test_config.py @@ -624,6 +624,30 @@ custom_option = ${this.board} assert config.get("env:myenv", "build_flags") == ["-Dmyenv"] +def test_project_name(tmp_path: Path): + project_dir = tmp_path / "my-project-name" + project_dir.mkdir() + project_conf = project_dir / "platformio.ini" + project_conf.write_text( + """ +[env:myenv] + """ + ) + with fs.cd(str(project_dir)): + config = ProjectConfig(str(project_conf)) + assert config.get("platformio", "name") == "my-project-name" + + # custom name + project_conf.write_text( + """ +[platformio] +name = custom-project-name + """ + ) + config = ProjectConfig(str(project_conf)) + assert config.get("platformio", "name") == "custom-project-name" + + def test_nested_interpolation(tmp_path: Path): project_conf = tmp_path / "platformio.ini" project_conf.write_text( From 34545d3f12b072c396fd432c07a26ac93efcd5e8 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 8 Dec 2023 19:45:31 +0200 Subject: [PATCH 33/69] Switch to Python 3.11 for CI tasks --- .github/workflows/core.yml | 6 +++--- .github/workflows/deployment.yml | 4 ++-- .github/workflows/docs.yml | 6 +++--- .github/workflows/examples.yml | 4 ++-- .github/workflows/projects.yml | 6 +++--- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/.github/workflows/core.yml b/.github/workflows/core.yml index c7c020a3..c82438d2 100644 --- a/.github/workflows/core.yml +++ b/.github/workflows/core.yml @@ -8,12 +8,12 @@ jobs: fail-fast: false matrix: os: [ubuntu-20.04, windows-latest, macos-latest] - python-version: ["3.6", "3.7", "3.8", "3.9", "3.10", "3.11"] + python-version: ["3.6", "3.7", "3.11", "3.12"] runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: submodules: "recursive" @@ -37,7 +37,7 @@ jobs: tox -e lint - name: Integration Tests - if: ${{ matrix.python-version == '3.9' }} + if: ${{ matrix.python-version == '3.11' }} run: | tox -e testcore diff --git a/.github/workflows/deployment.yml b/.github/workflows/deployment.yml index 370333a5..0941b759 100644 --- a/.github/workflows/deployment.yml +++ b/.github/workflows/deployment.yml @@ -12,14 +12,14 @@ jobs: environment: production steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: submodules: "recursive" - name: Set up Python uses: actions/setup-python@v4 with: - python-version: "3.9" + python-version: "3.11" - name: Install dependencies run: | diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 9a64d882..4404ad54 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -7,13 +7,13 @@ jobs: name: Build Docs runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: submodules: "recursive" - name: Set up Python uses: actions/setup-python@v4 with: - python-version: 3.9 + python-version: "3.11" - name: Install dependencies run: | python -m pip install --upgrade pip @@ -78,7 +78,7 @@ jobs: fi - name: Checkout latest Docs continue-on-error: true - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: repository: ${{ env.DOCS_REPO }} path: ${{ env.DOCS_DIR }} diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml index 6bb258e0..2e734563 100644 --- a/.github/workflows/examples.yml +++ b/.github/workflows/examples.yml @@ -15,14 +15,14 @@ jobs: PIO_INSTALL_DEVPLATFORM_NAMES: "aceinna_imu,atmelavr,atmelmegaavr,atmelsam,espressif32,espressif8266,nordicnrf52,raspberrypi,ststm32,teensy" steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: submodules: "recursive" - name: Set up Python uses: actions/setup-python@v4 with: - python-version: "3.9" + python-version: "3.11" - name: Install dependencies run: | diff --git a/.github/workflows/projects.yml b/.github/workflows/projects.yml index 1d37c5a3..676efaec 100644 --- a/.github/workflows/projects.yml +++ b/.github/workflows/projects.yml @@ -40,20 +40,20 @@ jobs: runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: submodules: "recursive" - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v4 with: - python-version: 3.9 + python-version: 3.11 - name: Install PlatformIO run: pip install -U . - name: Check out ${{ matrix.project.repository }} - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: submodules: "recursive" repository: ${{ matrix.project.repository }} From 4cad98601d9d6eee023c38621bbd9dd3453dcebd Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 8 Dec 2023 19:48:36 +0200 Subject: [PATCH 34/69] Bump version to 6.1.12a4 --- platformio/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio/__init__.py b/platformio/__init__.py index a61cd4f4..7fe43bed 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -VERSION = (6, 1, "12a3") +VERSION = (6, 1, "12a4") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" From 998da59f7c7998ea32dac2b8b2fbf4e5996d9979 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 8 Dec 2023 20:18:29 +0200 Subject: [PATCH 35/69] Add support for Python 3.12 --- HISTORY.rst | 1 + platformio/fs.py | 5 +++-- platformio/util.py | 5 ++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 76c53d72..fc0e1b4d 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -20,6 +20,7 @@ test-driven methodologies, and modern toolchains for unrivaled success. 6.1.12 (2023-??-??) ~~~~~~~~~~~~~~~~~~~ +* Added support for Python 3.12 * Introduced a warning during the verification of MCU maximum RAM usage, signaling when the allocated RAM surpasses 100% (`issue #4791 `_) * Drastically enhanced the speed of project building when operating in verbose mode (`issue #4783 `_) * Upgraded the build engine to the latest version of SCons (4.6.0) to improve build performance, reliability, and compatibility with other tools and systems (`release notes `__) diff --git a/platformio/fs.py b/platformio/fs.py index 1f43a7a3..27d25a59 100644 --- a/platformio/fs.py +++ b/platformio/fs.py @@ -210,7 +210,7 @@ def change_filemtime(path, mtime): def rmtree(path): - def _onerror(func, path, __): + def _onexc(func, path, _): try: st_mode = os.stat(path).st_mode if st_mode & stat.S_IREAD: @@ -223,4 +223,5 @@ def rmtree(path): err=True, ) - return shutil.rmtree(path, onerror=_onerror) + kwargs = {"onexc" if sys.version_info >= (3, 12) else "onerror": _onexc} + return shutil.rmtree(path, **kwargs) diff --git a/platformio/util.py b/platformio/util.py index bb3679fe..54db102f 100644 --- a/platformio/util.py +++ b/platformio/util.py @@ -170,9 +170,8 @@ def items_in_list(needle, haystack): def parse_datetime(datestr): - if "T" in datestr and "Z" in datestr: - return datetime.datetime.strptime(datestr, "%Y-%m-%dT%H:%M:%SZ") - return datetime.datetime.strptime(datestr) + assert "T" in datestr and "Z" in datestr + return datetime.datetime.strptime(datestr, "%Y-%m-%dT%H:%M:%SZ") def merge_dicts(d1, d2, path=None): From f382aae66b42b9c44b012d16755ea30a241283a9 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sat, 9 Dec 2023 13:05:30 +0200 Subject: [PATCH 36/69] Do not normalize platformio.***_dir path when validating --- platformio/project/options.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/platformio/project/options.py b/platformio/project/options.py index 51611d24..6a6d4967 100644 --- a/platformio/project/options.py +++ b/platformio/project/options.py @@ -87,7 +87,8 @@ def validate_dir(path): return path if path.startswith("~"): path = fs.expanduser(path) - return os.path.abspath(path) + return path + # return os.path.abspath(path) def get_default_core_dir(): From 0f554d2f31bf122cf6d661451317d9972f0c8e23 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sat, 9 Dec 2023 13:05:51 +0200 Subject: [PATCH 37/69] PyLint fixes --- platformio/fs.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/platformio/fs.py b/platformio/fs.py index 27d25a59..d6e1e676 100644 --- a/platformio/fs.py +++ b/platformio/fs.py @@ -223,5 +223,6 @@ def rmtree(path): err=True, ) - kwargs = {"onexc" if sys.version_info >= (3, 12) else "onerror": _onexc} - return shutil.rmtree(path, **kwargs) + if sys.version_info < (3, 12): + return shutil.rmtree(path, onerror=_onexc) + return shutil.rmtree(path, onexc=_onexc) # pylint: disable=unexpected-keyword-arg From 204a60dd522d2fa81462c57bc1d7851c232fca29 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sat, 9 Dec 2023 13:06:20 +0200 Subject: [PATCH 38/69] Parse only $PROJECT_HASH legacy built-in variable --- platformio/project/config.py | 3 ++- tests/project/test_config.py | 9 ++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/platformio/project/config.py b/platformio/project/config.py index f19473f8..3d92a5ae 100644 --- a/platformio/project/config.py +++ b/platformio/project/config.py @@ -316,10 +316,11 @@ class ProjectConfigBase: return value # legacy support for variables delclared without "${}" + legacy_vars = ["PROJECT_HASH"] stop = False while not stop: stop = True - for name in self.BUILTIN_VARS: + for name in legacy_vars: x = value.find(f"${name}") if x < 0 or value[x - 1] == "$": continue diff --git a/tests/project/test_config.py b/tests/project/test_config.py index 6880dd7c..474033f3 100644 --- a/tests/project/test_config.py +++ b/tests/project/test_config.py @@ -354,10 +354,7 @@ def test_get_value(config): "--help", ] # test relative dir - assert config.get("platformio", "src_dir") == os.path.abspath( - os.path.join(os.getcwd(), "source") - ) - + assert config.get("platformio", "src_dir") == "source" # renamed option assert config.get("env:extra_1", "lib_install") == ["574"] assert config.get("env:extra_1", "lib_deps") == ["574"] @@ -654,6 +651,7 @@ def test_nested_interpolation(tmp_path: Path): """ [platformio] build_dir = /tmp/pio-$PROJECT_HASH +data_dir = $PROJECT_DIR/assets [env:myenv] build_flags = -D UTIME=${UNIX_TIME} @@ -667,9 +665,10 @@ test_testing_command = """ ) config = ProjectConfig(str(project_conf)) + assert config.get("platformio", "data_dir") == "$PROJECT_DIR/assets" + assert config.get("env:myenv", "build_flags")[0][-10:].isdigit() testing_command = config.get("env:myenv", "test_testing_command") assert "$" not in " ".join(testing_command) - assert config.get("env:myenv", "build_flags")[0][-10:].isdigit() def test_extends_order(tmp_path: Path): From 1e2c37c190a2a15a3795009310ed5f09eb74f1e8 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sat, 9 Dec 2023 13:06:42 +0200 Subject: [PATCH 39/69] Bump version to 6.1.12a5 --- platformio/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio/__init__.py b/platformio/__init__.py index 7fe43bed..4a2b9f98 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -VERSION = (6, 1, "12a4") +VERSION = (6, 1, "12a5") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" From 51bf17515eaf60b6d7aff907953309783a72fa79 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sat, 9 Dec 2023 13:18:03 +0200 Subject: [PATCH 40/69] Revert back normalizing platformio.*_dir option --- platformio/project/options.py | 3 +-- tests/project/test_config.py | 9 ++++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/platformio/project/options.py b/platformio/project/options.py index 6a6d4967..51611d24 100644 --- a/platformio/project/options.py +++ b/platformio/project/options.py @@ -87,8 +87,7 @@ def validate_dir(path): return path if path.startswith("~"): path = fs.expanduser(path) - return path - # return os.path.abspath(path) + return os.path.abspath(path) def get_default_core_dir(): diff --git a/tests/project/test_config.py b/tests/project/test_config.py index 474033f3..06e92a32 100644 --- a/tests/project/test_config.py +++ b/tests/project/test_config.py @@ -354,7 +354,10 @@ def test_get_value(config): "--help", ] # test relative dir - assert config.get("platformio", "src_dir") == "source" + assert config.get("platformio", "src_dir") == os.path.abspath( + os.path.join(os.getcwd(), "source") + ) + # renamed option assert config.get("env:extra_1", "lib_install") == ["574"] assert config.get("env:extra_1", "lib_deps") == ["574"] @@ -651,7 +654,7 @@ def test_nested_interpolation(tmp_path: Path): """ [platformio] build_dir = /tmp/pio-$PROJECT_HASH -data_dir = $PROJECT_DIR/assets +data_dir = /$PROJECT_DIR/assets [env:myenv] build_flags = -D UTIME=${UNIX_TIME} @@ -665,7 +668,7 @@ test_testing_command = """ ) config = ProjectConfig(str(project_conf)) - assert config.get("platformio", "data_dir") == "$PROJECT_DIR/assets" + assert config.get("platformio", "data_dir") == "/$PROJECT_DIR/assets" assert config.get("env:myenv", "build_flags")[0][-10:].isdigit() testing_command = config.get("env:myenv", "test_testing_command") assert "$" not in " ".join(testing_command) From cf4da42b254a94a569f145199aa1657e1bfc262f Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sat, 9 Dec 2023 13:18:21 +0200 Subject: [PATCH 41/69] Bump version to 6.1.12a6 --- platformio/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio/__init__.py b/platformio/__init__.py index 4a2b9f98..9d6cf669 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -VERSION = (6, 1, "12a5") +VERSION = (6, 1, "12a6") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" From 77e6d1b09956cf38fa8d2722bd9c88919f5c43c2 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sat, 9 Dec 2023 13:51:51 +0200 Subject: [PATCH 42/69] PyLint fix for Python 3.12 --- platformio/fs.py | 3 ++- tests/project/test_config.py | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/platformio/fs.py b/platformio/fs.py index d6e1e676..c70a554e 100644 --- a/platformio/fs.py +++ b/platformio/fs.py @@ -223,6 +223,7 @@ def rmtree(path): err=True, ) + # pylint: disable=unexpected-keyword-arg, deprecated-argument if sys.version_info < (3, 12): return shutil.rmtree(path, onerror=_onexc) - return shutil.rmtree(path, onexc=_onexc) # pylint: disable=unexpected-keyword-arg + return shutil.rmtree(path, onexc=_onexc) diff --git a/tests/project/test_config.py b/tests/project/test_config.py index 06e92a32..3f368fe1 100644 --- a/tests/project/test_config.py +++ b/tests/project/test_config.py @@ -654,7 +654,7 @@ def test_nested_interpolation(tmp_path: Path): """ [platformio] build_dir = /tmp/pio-$PROJECT_HASH -data_dir = /$PROJECT_DIR/assets +data_dir = $PROJECT_DIR/assets [env:myenv] build_flags = -D UTIME=${UNIX_TIME} @@ -668,7 +668,9 @@ test_testing_command = """ ) config = ProjectConfig(str(project_conf)) - assert config.get("platformio", "data_dir") == "/$PROJECT_DIR/assets" + assert config.get("platformio", "data_dir").endswith( + os.path.join("$PROJECT_DIR", "assets") + ) assert config.get("env:myenv", "build_flags")[0][-10:].isdigit() testing_command = config.get("env:myenv", "test_testing_command") assert "$" not in " ".join(testing_command) From e4c4f2ac5004d93b7aa3f35276a91346ba299be8 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sat, 9 Dec 2023 15:12:16 +0200 Subject: [PATCH 43/69] Resolved an issue where native debugging failed on the host machine // Resolve #4745 --- HISTORY.rst | 1 + platformio/debug/config/factory.py | 16 ++++++---------- platformio/platform/base.py | 1 + 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index fc0e1b4d..cd03107d 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -30,6 +30,7 @@ test-driven methodologies, and modern toolchains for unrivaled success. * Resolved an issue where ``get_systype()`` inaccurately returned the architecture when executed within a Docker container on a 64-bit kernel with a 32-bit userspace (`issue #4777 `_) * Resolved an issue with incorrect handling of the ``check_src_filters`` option when used in multiple environments (`issue #4788 `_) * Resolved an issue where running `pio project metadata `__ resulted in duplicated "include" entries (`issue #4723 `_) +* Resolved an issue where native debugging failed on the host machine (`issue #4745 `_) 6.1.11 (2023-08-31) ~~~~~~~~~~~~~~~~~~~ diff --git a/platformio/debug/config/factory.py b/platformio/debug/config/factory.py index d7358b92..ea36b6a0 100644 --- a/platformio/debug/config/factory.py +++ b/platformio/debug/config/factory.py @@ -27,17 +27,13 @@ class DebugConfigFactory: @classmethod def new(cls, platform, project_config, env_name): - board_config = platform.board_config( - project_config.get("env:" + env_name, "board") - ) - tool_name = ( - board_config.get_debug_tool_name( - project_config.get("env:" + env_name, "debug_tool") - ) - if board_config - else None - ) + board_id = project_config.get("env:" + env_name, "board") config_cls = None + tool_name = None + if board_id: + tool_name = platform.board_config( + project_config.get("env:" + env_name, "board") + ).get_debug_tool_name(project_config.get("env:" + env_name, "debug_tool")) try: mod = importlib.import_module("platformio.debug.config.%s" % tool_name) config_cls = getattr(mod, cls.get_clsname(tool_name)) diff --git a/platformio/platform/base.py b/platformio/platform/base.py index 51b02216..0d2d57a9 100644 --- a/platformio/platform/base.py +++ b/platformio/platform/base.py @@ -169,6 +169,7 @@ class PlatformBase( # pylint: disable=too-many-instance-attributes,too-many-pub return self._BOARDS_CACHE[id_] if id_ else self._BOARDS_CACHE def board_config(self, id_): + assert id_ return self.get_boards(id_) def get_package_type(self, name): From 195304bbeaf55a8448c0dbb8cb1cc50e11bcb461 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sat, 9 Dec 2023 15:27:06 +0200 Subject: [PATCH 44/69] Implemented a fail-safe mechanism to terminate a debugging session if an unknown CLI option is passed // Resolve #4699 --- HISTORY.rst | 1 + platformio/debug/cli.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/HISTORY.rst b/HISTORY.rst index cd03107d..5d000e27 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -25,6 +25,7 @@ test-driven methodologies, and modern toolchains for unrivaled success. * Drastically enhanced the speed of project building when operating in verbose mode (`issue #4783 `_) * Upgraded the build engine to the latest version of SCons (4.6.0) to improve build performance, reliability, and compatibility with other tools and systems (`release notes `__) * Enhanced the handling of built-in variables in |PIOCONF| during |INTERPOLATION| (`issue #4695 `_) +* Implemented a fail-safe mechanism to terminate a debugging session if an unknown CLI option is passed (`issue #4699 `_) * Rectified an issue where ``${platformio.name}`` erroneously represented ``None`` as the default `project name `__ (`issue #4717 `_) * Resolved an issue where the ``COMPILATIONDB_INCLUDE_TOOLCHAIN`` setting was not correctly applying to private libraries (`issue #4762 `_) * Resolved an issue where ``get_systype()`` inaccurately returned the architecture when executed within a Docker container on a 64-bit kernel with a 32-bit userspace (`issue #4777 `_) diff --git a/platformio/debug/cli.py b/platformio/debug/cli.py index 5c9375ae..4dc01686 100644 --- a/platformio/debug/cli.py +++ b/platformio/debug/cli.py @@ -54,7 +54,7 @@ from platformio.project.options import ProjectOptions @click.option("--environment", "-e", metavar="") @click.option("--load-mode", type=ProjectOptions["env.debug_load_mode"].type) @click.option("--verbose", "-v", is_flag=True) -@click.option("--interface", type=click.Choice(["gdb"])) +@click.option("--interface", type=click.Choice(["gdb"]), default="gdb") @click.argument("__unprocessed", nargs=-1, type=click.UNPROCESSED) @click.pass_context def cli( From b0a1f3ae16411a48988f0966666bb1417bdd994e Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 22 Dec 2023 19:55:15 +0200 Subject: [PATCH 45/69] Update deps --- platformio/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/platformio/__init__.py b/platformio/__init__.py index 9d6cf669..12122e22 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -67,7 +67,7 @@ __install_requires__ = [ ] + [ # PIO Home requirements "ajsonrpc == 1.2.*", - "starlette >=0.19, <=0.33", - "uvicorn >=0.16, <0.24", + "starlette >=0.19, <=0.34", + "uvicorn >=0.16, <=0.25", "wsproto == 1.*", ] From 14907579cd35b0bb106209effad87388e867575f Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 27 Dec 2023 15:23:01 +0200 Subject: [PATCH 46/69] Docs: Sync dev-platforms --- docs | 2 +- examples | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs b/docs index 5f5efa22..266d076c 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit 5f5efa22b88562fe755d206eea0faa2f097ea70c +Subproject commit 266d076c2e69d1d33887d99ce8d471f86fbfb334 diff --git a/examples b/examples index 2aa3bb92..f06e9656 160000 --- a/examples +++ b/examples @@ -1 +1 @@ -Subproject commit 2aa3bb92c79ceb3b09e0b2c23eab724073ff7d8d +Subproject commit f06e9656a490c17b9193ce78dca8df4c7a6cb82e From 125be4bfd47f3523bad9502d21010a39694e99da Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sat, 30 Dec 2023 14:44:35 +0200 Subject: [PATCH 47/69] urllib3 v2.0 only supports OpenSSL 1.1.1+ // Issue #4614 --- setup.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/setup.py b/setup.py index 46716cc5..bdb10a31 100644 --- a/setup.py +++ b/setup.py @@ -30,6 +30,19 @@ from platformio import ( if platform.system() == "Darwin" and "arm" in platform.machine().lower(): __install_requires__.append("chardet>=3.0.2,<4") +# issue 4614: urllib3 v2.0 only supports OpenSSL 1.1.1+ +try: + import ssl + + if ssl.OPENSSL_VERSION.startswith("OpenSSL ") and ssl.OPENSSL_VERSION_INFO < ( + 1, + 1, + 1, + ): + __install_requires__.append("urllib3<2") +except ImportError: + pass + setup( name=__title__, From dc16f80ffce7485c9d873eaff81505d997e432a1 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sat, 30 Dec 2023 18:27:40 +0200 Subject: [PATCH 48/69] Minor improvements // Issue #4699 --- platformio/debug/cli.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/platformio/debug/cli.py b/platformio/debug/cli.py index 4dc01686..25fb68e1 100644 --- a/platformio/debug/cli.py +++ b/platformio/debug/cli.py @@ -54,8 +54,8 @@ from platformio.project.options import ProjectOptions @click.option("--environment", "-e", metavar="") @click.option("--load-mode", type=ProjectOptions["env.debug_load_mode"].type) @click.option("--verbose", "-v", is_flag=True) -@click.option("--interface", type=click.Choice(["gdb"]), default="gdb") -@click.argument("__unprocessed", nargs=-1, type=click.UNPROCESSED) +@click.option("--interface", type=click.Choice(["gdb"])) +@click.argument("client_extra_args", nargs=-1, type=click.UNPROCESSED) @click.pass_context def cli( ctx, @@ -65,10 +65,13 @@ def cli( load_mode, verbose, interface, - __unprocessed, + client_extra_args, ): app.set_session_var("custom_project_conf", project_conf) + if not interface and client_extra_args: + raise click.UsageError("Please specify debugging interface") + # use env variables from Eclipse or CLion for name in ("CWD", "PWD", "PLATFORMIO_PROJECT_DIR"): if is_platformio_project(project_dir): @@ -92,7 +95,7 @@ def cli( env_name, load_mode, verbose, - __unprocessed, + client_extra_args, ) if helpers.is_gdbmi_mode(): os.environ["PLATFORMIO_DISABLE_PROGRESSBAR"] = "true" @@ -103,19 +106,19 @@ def cli( else: debug_config = _configure(*configure_args) - _run(project_dir, debug_config, __unprocessed) + _run(project_dir, debug_config, client_extra_args) return None -def _configure(ctx, project_config, env_name, load_mode, verbose, __unprocessed): +def _configure(ctx, project_config, env_name, load_mode, verbose, client_extra_args): platform = PlatformFactory.from_env(env_name, autoinstall=True) debug_config = DebugConfigFactory.new( platform, project_config, env_name, ) - if "--version" in __unprocessed: + if "--version" in client_extra_args: raise ReturnErrorCode( subprocess.run( [debug_config.client_executable_path, "--version"], check=True @@ -161,12 +164,12 @@ def _configure(ctx, project_config, env_name, load_mode, verbose, __unprocessed) return debug_config -def _run(project_dir, debug_config, __unprocessed): +def _run(project_dir, debug_config, client_extra_args): loop = asyncio.ProactorEventLoop() if IS_WINDOWS else asyncio.get_event_loop() asyncio.set_event_loop(loop) client = GDBClientProcess(project_dir, debug_config) - coro = client.run(__unprocessed) + coro = client.run(client_extra_args) try: signal.signal(signal.SIGINT, signal.SIG_IGN) loop.run_until_complete(coro) From b181406a1f8151ec33a32e9879887daacee4c3ac Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sun, 31 Dec 2023 14:54:57 +0200 Subject: [PATCH 49/69] Resolve an issue where custom debug configurations were being inadvertently overwritten in VSCode's ``launch.json`` // Resolve #4810 --- HISTORY.rst | 2 +- .../tpls/vscode/.vscode/launch.json.tpl | 28 ++++++++++++------- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 5d000e27..d64e5e2b 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -17,7 +17,7 @@ Unlock the true potential of embedded software development with PlatformIO's collaborative ecosystem, embracing declarative principles, test-driven methodologies, and modern toolchains for unrivaled success. -6.1.12 (2023-??-??) +6.1.12 (2024-??-??) ~~~~~~~~~~~~~~~~~~~ * Added support for Python 3.12 diff --git a/platformio/project/integration/tpls/vscode/.vscode/launch.json.tpl b/platformio/project/integration/tpls/vscode/.vscode/launch.json.tpl index 4bd188d2..03906ccd 100644 --- a/platformio/project/integration/tpls/vscode/.vscode/launch.json.tpl +++ b/platformio/project/integration/tpls/vscode/.vscode/launch.json.tpl @@ -1,4 +1,3 @@ -% import codecs % import json % import os % @@ -47,9 +46,14 @@ % return data % end % -% def _contains_external_configurations(launch_config): +% def _contains_custom_configurations(launch_config): +% pio_config_names = [ +% c["name"] +% for c in get_pio_configurations() +% ] % return any( % c.get("type", "") != "platformio-debug" +% or c.get("name", "") in pio_config_names % for c in launch_config.get("configurations", []) % ) % end @@ -59,10 +63,14 @@ % return launch_config % end % +% pio_config_names = [ +% c["name"] +% for c in get_pio_configurations() +% ] % external_configurations = [ -% config -% for config in launch_config["configurations"] -% if config.get("type", "") != "platformio-debug" +% c +% for c in launch_config["configurations"] +% if c.get("type", "") != "platformio-debug" or c.get("name", "") not in pio_config_names % ] % % launch_config["configurations"] = external_configurations @@ -73,11 +81,11 @@ % launch_config = {"version": "0.2.0", "configurations": []} % launch_file = os.path.join(project_dir, ".vscode", "launch.json") % if os.path.isfile(launch_file): -% with codecs.open(launch_file, "r", encoding="utf8") as fp: +% with open(launch_file, "r", encoding="utf8") as fp: % launch_data = _remove_comments(fp.readlines()) % try: % prev_config = json.loads(launch_data) -% if _contains_external_configurations(prev_config): +% if _contains_custom_configurations(prev_config): % launch_config = _remove_pio_configurations(prev_config) % end % except: @@ -91,9 +99,9 @@ % // AUTOMATICALLY GENERATED FILE. PLEASE DO NOT MODIFY IT MANUALLY // -// PIO Unified Debugger +// PlatformIO Debugging Solution // -// Documentation: https://docs.platformio.org/page/plus/debugging.html -// Configuration: https://docs.platformio.org/page/projectconf/section_env_debug.html +// Documentation: https://docs.platformio.org/en/latest/plus/debugging.html +// Configuration: https://docs.platformio.org/en/latest/projectconf/sections/env/options/debug/index.html {{ json.dumps(get_launch_configuration(), indent=4, ensure_ascii=False) }} From f2d16e7631cf205783baceb3f391b8cfb623f3c6 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sun, 31 Dec 2023 14:56:39 +0200 Subject: [PATCH 50/69] Bump version to 6.1.12b1 --- HISTORY.rst | 1 + platformio/__init__.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/HISTORY.rst b/HISTORY.rst index d64e5e2b..2df7ccd7 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -32,6 +32,7 @@ test-driven methodologies, and modern toolchains for unrivaled success. * Resolved an issue with incorrect handling of the ``check_src_filters`` option when used in multiple environments (`issue #4788 `_) * Resolved an issue where running `pio project metadata `__ resulted in duplicated "include" entries (`issue #4723 `_) * Resolved an issue where native debugging failed on the host machine (`issue #4745 `_) +* Resolved an issue where custom debug configurations were being inadvertently overwritten in VSCode's ``launch.json`` (`issue #4810 `_) 6.1.11 (2023-08-31) ~~~~~~~~~~~~~~~~~~~ diff --git a/platformio/__init__.py b/platformio/__init__.py index 12122e22..3d5d9b87 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -VERSION = (6, 1, "12a6") +VERSION = (6, 1, "12b1") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" From c74c9778a18cafab0f57e03f70d082aab200567a Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sat, 6 Jan 2024 16:24:01 +0200 Subject: [PATCH 51/69] Enhance PIP dependency declarations // Resolve #4819 --- .github/workflows/deployment.yml | 3 +- HISTORY.rst | 1 + platformio/__init__.py | 19 ---------- platformio/commands/upgrade.py | 9 ++--- platformio/pipdeps.py | 61 ++++++++++++++++++++++++++++++++ setup.py | 23 ++---------- 6 files changed, 71 insertions(+), 45 deletions(-) create mode 100644 platformio/pipdeps.py diff --git a/.github/workflows/deployment.yml b/.github/workflows/deployment.yml index 0941b759..8517d7bd 100644 --- a/.github/workflows/deployment.yml +++ b/.github/workflows/deployment.yml @@ -35,7 +35,8 @@ jobs: tox -e testcore - name: Build Python source tarball - run: python setup.py sdist bdist_wheel + # run: python setup.py sdist bdist_wheel + run: python setup.py sdist - name: Publish package to PyPI if: ${{ github.ref == 'refs/heads/master' }} diff --git a/HISTORY.rst b/HISTORY.rst index 2df7ccd7..dd40176f 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -25,6 +25,7 @@ test-driven methodologies, and modern toolchains for unrivaled success. * Drastically enhanced the speed of project building when operating in verbose mode (`issue #4783 `_) * Upgraded the build engine to the latest version of SCons (4.6.0) to improve build performance, reliability, and compatibility with other tools and systems (`release notes `__) * Enhanced the handling of built-in variables in |PIOCONF| during |INTERPOLATION| (`issue #4695 `_) +* Enhanced PIP dependency declarations for improved reliability and extended support to include Python 3.6 (`issue #4819 `_) * Implemented a fail-safe mechanism to terminate a debugging session if an unknown CLI option is passed (`issue #4699 `_) * Rectified an issue where ``${platformio.name}`` erroneously represented ``None`` as the default `project name `__ (`issue #4717 `_) * Resolved an issue where the ``COMPILATIONDB_INCLUDE_TOOLCHAIN`` setting was not correctly applying to private libraries (`issue #4762 `_) diff --git a/platformio/__init__.py b/platformio/__init__.py index 3d5d9b87..677958c8 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -52,22 +52,3 @@ __check_internet_hosts__ = [ "88.198.170.159", # platformio.org "github.com", ] + __registry_mirror_hosts__ - -__install_requires__ = [ - # Core requirements - "bottle == 0.12.*", - "click >=8.0.4, <=8.2", - "colorama", - "marshmallow == 3.*", - "pyelftools == 0.30", - "pyserial == 3.5.*", # keep in sync "device/monitor/terminal.py" - "requests == 2.*", - "semantic_version == 2.10.*", - "tabulate == 0.*", -] + [ - # PIO Home requirements - "ajsonrpc == 1.2.*", - "starlette >=0.19, <=0.34", - "uvicorn >=0.16, <=0.25", - "wsproto == 1.*", -] diff --git a/platformio/commands/upgrade.py b/platformio/commands/upgrade.py index 3fb611ea..129e3fa1 100644 --- a/platformio/commands/upgrade.py +++ b/platformio/commands/upgrade.py @@ -18,9 +18,10 @@ import subprocess import click -from platformio import VERSION, __install_requires__, __version__, app, exception +from platformio import VERSION, __version__, app, exception from platformio.http import fetch_remote_content from platformio.package.manager.core import update_core_packages +from platformio.pipdeps import get_pip_dependencies from platformio.proc import get_pythonexe_path PYPI_JSON_URL = "https://pypi.org/pypi/platformio/json" @@ -37,7 +38,7 @@ DEVELOP_INIT_SCRIPT_URL = ( @click.option("--verbose", "-v", is_flag=True) def cli(dev, only_dependencies, verbose): if only_dependencies: - return upgrade_pypi_dependencies(verbose) + return upgrade_pip_dependencies(verbose) update_core_packages() @@ -102,7 +103,7 @@ def cli(dev, only_dependencies, verbose): return True -def upgrade_pypi_dependencies(verbose): +def upgrade_pip_dependencies(verbose): subprocess.run( [ get_pythonexe_path(), @@ -111,7 +112,7 @@ def upgrade_pypi_dependencies(verbose): "install", "--upgrade", "pip", - *__install_requires__, + *get_pip_dependencies(), ], check=True, stdout=subprocess.PIPE if not verbose else None, diff --git a/platformio/pipdeps.py b/platformio/pipdeps.py new file mode 100644 index 00000000..f5512cde --- /dev/null +++ b/platformio/pipdeps.py @@ -0,0 +1,61 @@ +# Copyright (c) 2014-present PlatformIO +# +# 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 platform +import sys + +PY36 = sys.version_info[0:2] == (3, 6) + + +def get_pip_dependencies(): + core = [ + "bottle == 0.12.*", + "click >=8.0.4, <9", + "colorama", + "marshmallow == 3.*", + "pyelftools == 0.30", + "pyserial == 3.5.*", # keep in sync "device/monitor/terminal.py" + "requests == 2.*", + "semantic_version == 2.10.*", + "tabulate == 0.*", + ] + + home = [ + # PIO Home requirements + "ajsonrpc == 1.2.*", + "starlette >=0.19, <0.35", + "uvicorn %s" % ("== 0.16.0" if PY36 else ">=0.16, <0.26"), + "wsproto == 1.*", + ] + + extra = [] + + # issue #4702; Broken "requests/charset_normalizer" on macOS ARM + if platform.system() == "Darwin" and "arm" in platform.machine().lower(): + extra.append("chardet>=3.0.2,<6") + + # issue 4614: urllib3 v2.0 only supports OpenSSL 1.1.1+ + try: + import ssl # pylint: disable=import-outside-toplevel + + if ssl.OPENSSL_VERSION.startswith("OpenSSL ") and ssl.OPENSSL_VERSION_INFO < ( + 1, + 1, + 1, + ): + extra.append("urllib3<2") + except ImportError: + pass + + return core + home + extra diff --git a/setup.py b/setup.py index bdb10a31..7a7c5076 100644 --- a/setup.py +++ b/setup.py @@ -12,7 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -import platform from setuptools import find_packages, setup from platformio import ( @@ -23,26 +22,8 @@ from platformio import ( __title__, __url__, __version__, - __install_requires__, ) - -# issue #4702; Broken "requests/charset_normalizer" on macOS ARM -if platform.system() == "Darwin" and "arm" in platform.machine().lower(): - __install_requires__.append("chardet>=3.0.2,<4") - -# issue 4614: urllib3 v2.0 only supports OpenSSL 1.1.1+ -try: - import ssl - - if ssl.OPENSSL_VERSION.startswith("OpenSSL ") and ssl.OPENSSL_VERSION_INFO < ( - 1, - 1, - 1, - ): - __install_requires__.append("urllib3<2") -except ImportError: - pass - +from platformio.pipdeps import get_pip_dependencies setup( name=__title__, @@ -53,7 +34,7 @@ setup( author_email=__email__, url=__url__, license=__license__, - install_requires=__install_requires__, + install_requires=get_pip_dependencies(), python_requires=">=3.6", packages=find_packages(include=["platformio", "platformio.*"]), package_data={ From 41bd751ec2581331982c9d78b175467289fa2dec Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sat, 6 Jan 2024 17:48:18 +0200 Subject: [PATCH 52/69] Implemente automatic installation of missing dependencies when utilizing a SOCKS proxy // Resolve #4822 --- HISTORY.rst | 1 + platformio/http.py | 6 ++---- platformio/pipdeps.py | 12 +++++++++++- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index dd40176f..bb5770ce 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -26,6 +26,7 @@ test-driven methodologies, and modern toolchains for unrivaled success. * Upgraded the build engine to the latest version of SCons (4.6.0) to improve build performance, reliability, and compatibility with other tools and systems (`release notes `__) * Enhanced the handling of built-in variables in |PIOCONF| during |INTERPOLATION| (`issue #4695 `_) * Enhanced PIP dependency declarations for improved reliability and extended support to include Python 3.6 (`issue #4819 `_) +* Implemented automatic installation of missing dependencies when utilizing a SOCKS proxy (`issue #4822 `_) * Implemented a fail-safe mechanism to terminate a debugging session if an unknown CLI option is passed (`issue #4699 `_) * Rectified an issue where ``${platformio.name}`` erroneously represented ``None`` as the default `project name `__ (`issue #4717 `_) * Resolved an issue where the ``COMPILATIONDB_INCLUDE_TOOLCHAIN`` setting was not correctly applying to private libraries (`issue #4762 `_) diff --git a/platformio/http.py b/platformio/http.py index ee67b631..563f982f 100644 --- a/platformio/http.py +++ b/platformio/http.py @@ -13,7 +13,6 @@ # limitations under the License. import json -import os import socket from urllib.parse import urljoin @@ -23,6 +22,7 @@ from urllib3.util.retry import Retry from platformio import __check_internet_hosts__, app, util from platformio.cache import ContentCache, cleanup_content_cache from platformio.exception import PlatformioException, UserSideException +from platformio.pipdeps import is_proxy_set __default_requests_timeout__ = (10, None) # (connect, read) @@ -191,9 +191,7 @@ def _internet_on(): socket.setdefaulttimeout(timeout) for host in __check_internet_hosts__: try: - for var in ("HTTP_PROXY", "HTTPS_PROXY"): - if not os.getenv(var) and not os.getenv(var.lower()): - continue + if is_proxy_set(): requests.get("http://%s" % host, allow_redirects=False, timeout=timeout) return True # try to resolve `host` for both AF_INET and AF_INET6, and then try to connect diff --git a/platformio/pipdeps.py b/platformio/pipdeps.py index f5512cde..e9674dda 100644 --- a/platformio/pipdeps.py +++ b/platformio/pipdeps.py @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +import os import platform import sys @@ -26,7 +27,7 @@ def get_pip_dependencies(): "marshmallow == 3.*", "pyelftools == 0.30", "pyserial == 3.5.*", # keep in sync "device/monitor/terminal.py" - "requests == 2.*", + "requests%s == 2.*" % ("[socks]" if is_proxy_set(socks=True) else ""), "semantic_version == 2.10.*", "tabulate == 0.*", ] @@ -59,3 +60,12 @@ def get_pip_dependencies(): pass return core + home + extra + + +def is_proxy_set(socks=False): + for var in ("HTTP_PROXY", "HTTPS_PROXY", "ALL_PROXY"): + value = os.getenv(var, os.getenv(var.lower())) + if not value or (socks and not value.startswith("socks5://")): + continue + return True + return False From 4729d9f55dde821eff13b381c31c3ee7e00e4e4f Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sat, 6 Jan 2024 17:48:47 +0200 Subject: [PATCH 53/69] Bump version to 6.1.12b2 --- platformio/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio/__init__.py b/platformio/__init__.py index 677958c8..dad53f65 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -VERSION = (6, 1, "12b1") +VERSION = (6, 1, "12b2") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" From ba58db30794051a01844f65b540272ce10ebd0dc Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Tue, 9 Jan 2024 21:00:42 +0200 Subject: [PATCH 54/69] Introduced the capability to launch the debug server in a separate process // Resolve #4722 --- HISTORY.rst | 1 + platformio/debug/config/base.py | 11 +++++++---- platformio/debug/config/generic.py | 6 +----- platformio/debug/config/jlink.py | 6 +----- platformio/debug/config/mspdebug.py | 6 +----- platformio/debug/config/qemu.py | 6 +----- platformio/debug/config/renode.py | 6 +----- platformio/debug/process/server.py | 4 +++- 8 files changed, 16 insertions(+), 30 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index bb5770ce..10b09bdb 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -21,6 +21,7 @@ test-driven methodologies, and modern toolchains for unrivaled success. ~~~~~~~~~~~~~~~~~~~ * Added support for Python 3.12 +* Introduced the capability to launch the debug server in a separate process (`issue #4722 `_) * Introduced a warning during the verification of MCU maximum RAM usage, signaling when the allocated RAM surpasses 100% (`issue #4791 `_) * Drastically enhanced the speed of project building when operating in verbose mode (`issue #4783 `_) * Upgraded the build engine to the latest version of SCons (4.6.0) to improve build performance, reliability, and compatibility with other tools and systems (`release notes `__) diff --git a/platformio/debug/config/base.py b/platformio/debug/config/base.py index cb496581..212d00fa 100644 --- a/platformio/debug/config/base.py +++ b/platformio/debug/config/base.py @@ -24,7 +24,9 @@ from platformio.project.options import ProjectOptions class DebugConfigBase: # pylint: disable=too-many-instance-attributes - def __init__(self, platform, project_config, env_name, port=None): + DEFAULT_PORT = None + + def __init__(self, platform, project_config, env_name): self.platform = platform self.project_config = project_config self.env_name = env_name @@ -48,7 +50,6 @@ class DebugConfigBase: # pylint: disable=too-many-instance-attributes self._load_cmds = None self._port = None - self.port = port self.server = self._configure_server() try: @@ -120,8 +121,10 @@ class DebugConfigBase: # pylint: disable=too-many-instance-attributes @property def port(self): return ( - self.env_options.get("debug_port", self.tool_settings.get("port")) - or self._port + self._port + or self.env_options.get("debug_port") + or self.tool_settings.get("port") + or self.DEFAULT_PORT ) @port.setter diff --git a/platformio/debug/config/generic.py b/platformio/debug/config/generic.py index faa5a341..8f066802 100644 --- a/platformio/debug/config/generic.py +++ b/platformio/debug/config/generic.py @@ -16,6 +16,7 @@ from platformio.debug.config.base import DebugConfigBase class GenericDebugConfig(DebugConfigBase): + DEFAULT_PORT = ":3333" GDB_INIT_SCRIPT = """ define pio_reset_halt_target monitor reset halt @@ -31,8 +32,3 @@ $LOAD_CMDS pio_reset_halt_target $INIT_BREAK """ - - def __init__(self, *args, **kwargs): - if "port" not in kwargs: - kwargs["port"] = ":3333" - super().__init__(*args, **kwargs) diff --git a/platformio/debug/config/jlink.py b/platformio/debug/config/jlink.py index a820e0aa..5e4cc9ce 100644 --- a/platformio/debug/config/jlink.py +++ b/platformio/debug/config/jlink.py @@ -16,6 +16,7 @@ from platformio.debug.config.base import DebugConfigBase class JlinkDebugConfig(DebugConfigBase): + DEFAULT_PORT = ":2331" GDB_INIT_SCRIPT = """ define pio_reset_halt_target monitor reset @@ -36,11 +37,6 @@ $LOAD_CMDS $INIT_BREAK """ - def __init__(self, *args, **kwargs): - if "port" not in kwargs: - kwargs["port"] = ":2331" - super().__init__(*args, **kwargs) - @property def server_ready_pattern(self): return super().server_ready_pattern or ("Waiting for GDB connection") diff --git a/platformio/debug/config/mspdebug.py b/platformio/debug/config/mspdebug.py index 7f4d8e1a..aac67416 100644 --- a/platformio/debug/config/mspdebug.py +++ b/platformio/debug/config/mspdebug.py @@ -16,6 +16,7 @@ from platformio.debug.config.base import DebugConfigBase class MspdebugDebugConfig(DebugConfigBase): + DEFAULT_PORT = ":2000" GDB_INIT_SCRIPT = """ define pio_reset_halt_target end @@ -29,8 +30,3 @@ $LOAD_CMDS pio_reset_halt_target $INIT_BREAK """ - - def __init__(self, *args, **kwargs): - if "port" not in kwargs: - kwargs["port"] = ":2000" - super().__init__(*args, **kwargs) diff --git a/platformio/debug/config/qemu.py b/platformio/debug/config/qemu.py index b998c782..b28a5f34 100644 --- a/platformio/debug/config/qemu.py +++ b/platformio/debug/config/qemu.py @@ -16,6 +16,7 @@ from platformio.debug.config.base import DebugConfigBase class QemuDebugConfig(DebugConfigBase): + DEFAULT_PORT = ":1234" GDB_INIT_SCRIPT = """ define pio_reset_halt_target monitor system_reset @@ -30,8 +31,3 @@ $LOAD_CMDS pio_reset_halt_target $INIT_BREAK """ - - def __init__(self, *args, **kwargs): - if "port" not in kwargs: - kwargs["port"] = ":1234" - super().__init__(*args, **kwargs) diff --git a/platformio/debug/config/renode.py b/platformio/debug/config/renode.py index f2f62d66..de7bba48 100644 --- a/platformio/debug/config/renode.py +++ b/platformio/debug/config/renode.py @@ -16,6 +16,7 @@ from platformio.debug.config.base import DebugConfigBase class RenodeDebugConfig(DebugConfigBase): + DEFAULT_PORT = ":3333" GDB_INIT_SCRIPT = """ define pio_reset_halt_target monitor machine Reset @@ -33,11 +34,6 @@ $INIT_BREAK monitor start """ - def __init__(self, *args, **kwargs): - if "port" not in kwargs: - kwargs["port"] = ":3333" - super().__init__(*args, **kwargs) - @property def server_ready_pattern(self): return super().server_ready_pattern or ( diff --git a/platformio/debug/process/server.py b/platformio/debug/process/server.py index 693dfa44..7724ddf7 100644 --- a/platformio/debug/process/server.py +++ b/platformio/debug/process/server.py @@ -62,7 +62,9 @@ class DebugServerProcess(DebugBaseProcess): openocd_pipe_allowed = all( [ - not self.debug_config.env_options.get("debug_port"), + not self.debug_config.env_options.get( + "debug_port", self.debug_config.tool_settings.get("port") + ), "gdb" in self.debug_config.client_executable_path, "openocd" in server_executable, ] From f422b5e05c431610554324af75a495780c560414 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Tue, 9 Jan 2024 21:01:09 +0200 Subject: [PATCH 55/69] Bump version to 6.1.12rc1 --- platformio/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio/__init__.py b/platformio/__init__.py index dad53f65..9a0e1490 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -VERSION = (6, 1, "12b2") +VERSION = (6, 1, "12rc1") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" From a2f3e857608cc4e63343257731a05086b86f3069 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 10 Jan 2024 16:17:02 +0200 Subject: [PATCH 56/69] Bump version to 6.1.12 --- HISTORY.rst | 2 +- docs | 2 +- platformio/__init__.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 10b09bdb..9624b244 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -17,7 +17,7 @@ Unlock the true potential of embedded software development with PlatformIO's collaborative ecosystem, embracing declarative principles, test-driven methodologies, and modern toolchains for unrivaled success. -6.1.12 (2024-??-??) +6.1.12 (2024-01-10) ~~~~~~~~~~~~~~~~~~~ * Added support for Python 3.12 diff --git a/docs b/docs index 266d076c..c3657d69 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit 266d076c2e69d1d33887d99ce8d471f86fbfb334 +Subproject commit c3657d698d29cb8ba02bc709958ec22e7f5def04 diff --git a/platformio/__init__.py b/platformio/__init__.py index 9a0e1490..0e79928a 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -VERSION = (6, 1, "12rc1") +VERSION = (6, 1, 12) __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" From aabbbef94432b2c4a788858b01856a6cea718c9b Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 10 Jan 2024 16:39:38 +0200 Subject: [PATCH 57/69] Start 6.1.13 --- HISTORY.rst | 3 +++ platformio/__init__.py | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/HISTORY.rst b/HISTORY.rst index 9624b244..17be25e1 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -17,6 +17,9 @@ Unlock the true potential of embedded software development with PlatformIO's collaborative ecosystem, embracing declarative principles, test-driven methodologies, and modern toolchains for unrivaled success. +6.1.13 (2024-??-??) +~~~~~~~~~~~~~~~~~~~ + 6.1.12 (2024-01-10) ~~~~~~~~~~~~~~~~~~~ diff --git a/platformio/__init__.py b/platformio/__init__.py index 0e79928a..c90ba11e 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -VERSION = (6, 1, 12) +VERSION = (6, 1, "13a1") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" From adab425c6d9b7078d673504c091743b11c03c4be Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Thu, 11 Jan 2024 19:23:26 +0200 Subject: [PATCH 58/69] Expanded support for SCons variables declared in the legacy format ``${SCONS_VARNAME}`` // Resolve #4828 --- HISTORY.rst | 2 ++ platformio/project/config.py | 8 ++++++-- tests/project/test_config.py | 5 ++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 17be25e1..7a6a93cd 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -20,6 +20,8 @@ test-driven methodologies, and modern toolchains for unrivaled success. 6.1.13 (2024-??-??) ~~~~~~~~~~~~~~~~~~~ +* Expanded support for SCons variables declared in the legacy format ``${SCONS_VARNAME}`` (`issue #4828 `_) + 6.1.12 (2024-01-10) ~~~~~~~~~~~~~~~~~~~ diff --git a/platformio/project/config.py b/platformio/project/config.py index 3d92a5ae..f138f26c 100644 --- a/platformio/project/config.py +++ b/platformio/project/config.py @@ -164,6 +164,7 @@ class ProjectConfigBase: @staticmethod def get_section_scope(section): + assert section return section.split(":", 1)[0] if ":" in section else section def walk_options(self, root_section): @@ -343,8 +344,11 @@ class ProjectConfigBase: section, option = match.group(1), match.group(2) # handle built-in variables - if section is None and option in self.BUILTIN_VARS: - return self.BUILTIN_VARS[option]() + if section is None: + if option in self.BUILTIN_VARS: + return self.BUILTIN_VARS[option]() + # SCons varaibles + return f"${option}" # handle system environment variables if section == "sysenv": diff --git a/tests/project/test_config.py b/tests/project/test_config.py index 3f368fe1..c15aa7bc 100644 --- a/tests/project/test_config.py +++ b/tests/project/test_config.py @@ -657,7 +657,9 @@ build_dir = /tmp/pio-$PROJECT_HASH data_dir = $PROJECT_DIR/assets [env:myenv] -build_flags = -D UTIME=${UNIX_TIME} +build_flags = + -D UTIME=${UNIX_TIME} + -I ${PROJECTSRC_DIR}/hal test_testing_command = ${platformio.packages_dir}/tool-simavr/bin/simavr -m @@ -672,6 +674,7 @@ test_testing_command = os.path.join("$PROJECT_DIR", "assets") ) assert config.get("env:myenv", "build_flags")[0][-10:].isdigit() + assert config.get("env:myenv", "build_flags")[1] == "-I $PROJECTSRC_DIR/hal" testing_command = config.get("env:myenv", "test_testing_command") assert "$" not in " ".join(testing_command) From 485f801c74032237d3b1a92e8bfaedbb5e59c608 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Thu, 11 Jan 2024 19:23:59 +0200 Subject: [PATCH 59/69] Bump version to 6.1.13a2 --- platformio/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio/__init__.py b/platformio/__init__.py index c90ba11e..3d4f4017 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -VERSION = (6, 1, "13a1") +VERSION = (6, 1, "13a2") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" From f31f9fa616dd5e2a08f3a393eb92fbf0abe649ca Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Thu, 11 Jan 2024 21:33:01 +0200 Subject: [PATCH 60/69] Expanded support for SCons variables declared in the legacy format ``${SCONS_VARNAME}`` // Resolve #4828 --- platformio/project/config.py | 2 +- tests/project/test_config.py | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/platformio/project/config.py b/platformio/project/config.py index f138f26c..c583c0d2 100644 --- a/platformio/project/config.py +++ b/platformio/project/config.py @@ -348,7 +348,7 @@ class ProjectConfigBase: if option in self.BUILTIN_VARS: return self.BUILTIN_VARS[option]() # SCons varaibles - return f"${option}" + return f"${{{option}}}" # handle system environment variables if section == "sysenv": diff --git a/tests/project/test_config.py b/tests/project/test_config.py index c15aa7bc..02741b95 100644 --- a/tests/project/test_config.py +++ b/tests/project/test_config.py @@ -660,12 +660,14 @@ data_dir = $PROJECT_DIR/assets build_flags = -D UTIME=${UNIX_TIME} -I ${PROJECTSRC_DIR}/hal + -Wl,-Map,${BUILD_DIR}/${PROGNAME}.map test_testing_command = ${platformio.packages_dir}/tool-simavr/bin/simavr -m atmega328p -f 16000000L + ${UPLOAD_PORT and "-p "+UPLOAD_PORT} ${platformio.build_dir}/${this.__env__}/firmware.elf """ ) @@ -674,9 +676,14 @@ test_testing_command = os.path.join("$PROJECT_DIR", "assets") ) assert config.get("env:myenv", "build_flags")[0][-10:].isdigit() - assert config.get("env:myenv", "build_flags")[1] == "-I $PROJECTSRC_DIR/hal" + assert config.get("env:myenv", "build_flags")[1] == "-I ${PROJECTSRC_DIR}/hal" + assert ( + config.get("env:myenv", "build_flags")[2] + == "-Wl,-Map,${BUILD_DIR}/${PROGNAME}.map" + ) testing_command = config.get("env:myenv", "test_testing_command") - assert "$" not in " ".join(testing_command) + assert "$" not in testing_command[0] + assert testing_command[5] == '${UPLOAD_PORT and "-p "+UPLOAD_PORT}' def test_extends_order(tmp_path: Path): From 17ba91977db3d5991b37b4811081e328c277d225 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 12 Jan 2024 12:51:28 +0200 Subject: [PATCH 61/69] Update deps --- platformio/pipdeps.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio/pipdeps.py b/platformio/pipdeps.py index e9674dda..677d8c9d 100644 --- a/platformio/pipdeps.py +++ b/platformio/pipdeps.py @@ -35,7 +35,7 @@ def get_pip_dependencies(): home = [ # PIO Home requirements "ajsonrpc == 1.2.*", - "starlette >=0.19, <0.35", + "starlette >=0.19, <0.36", "uvicorn %s" % ("== 0.16.0" if PY36 else ">=0.16, <0.26"), "wsproto == 1.*", ] From 700c7053170713813c403931333e05aa1d318305 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 12 Jan 2024 12:51:49 +0200 Subject: [PATCH 62/69] Bump version to 6.1.13 --- HISTORY.rst | 2 +- docs | 2 +- platformio/__init__.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 7a6a93cd..f26bad63 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -17,7 +17,7 @@ Unlock the true potential of embedded software development with PlatformIO's collaborative ecosystem, embracing declarative principles, test-driven methodologies, and modern toolchains for unrivaled success. -6.1.13 (2024-??-??) +6.1.13 (2024-01-12) ~~~~~~~~~~~~~~~~~~~ * Expanded support for SCons variables declared in the legacy format ``${SCONS_VARNAME}`` (`issue #4828 `_) diff --git a/docs b/docs index c3657d69..3f021525 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit c3657d698d29cb8ba02bc709958ec22e7f5def04 +Subproject commit 3f02152561334a92bd8cae5c49e35cc194f86721 diff --git a/platformio/__init__.py b/platformio/__init__.py index 3d4f4017..7024104f 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -VERSION = (6, 1, "13a2") +VERSION = (6, 1, 13) __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" From 1fe806269db21bd44cd247097749423ec0110cef Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 12 Jan 2024 12:53:51 +0200 Subject: [PATCH 63/69] Start 6.1.14a1 --- HISTORY.rst | 3 +++ platformio/__init__.py | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/HISTORY.rst b/HISTORY.rst index f26bad63..63772de0 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -17,6 +17,9 @@ Unlock the true potential of embedded software development with PlatformIO's collaborative ecosystem, embracing declarative principles, test-driven methodologies, and modern toolchains for unrivaled success. +6.1.14 (2024-??-??) +~~~~~~~~~~~~~~~~~~~ + 6.1.13 (2024-01-12) ~~~~~~~~~~~~~~~~~~~ diff --git a/platformio/__init__.py b/platformio/__init__.py index 7024104f..81161c06 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -VERSION = (6, 1, 13) +VERSION = (6, 1, "14a1") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" From adf4012b96417c3e6c3f881ca86ba734d3b1fdce Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 17 Jan 2024 12:43:57 +0200 Subject: [PATCH 64/69] Update deps --- platformio/pipdeps.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio/pipdeps.py b/platformio/pipdeps.py index 677d8c9d..31715be2 100644 --- a/platformio/pipdeps.py +++ b/platformio/pipdeps.py @@ -36,7 +36,7 @@ def get_pip_dependencies(): # PIO Home requirements "ajsonrpc == 1.2.*", "starlette >=0.19, <0.36", - "uvicorn %s" % ("== 0.16.0" if PY36 else ">=0.16, <0.26"), + "uvicorn %s" % ("== 0.16.0" if PY36 else ">=0.16, <0.27"), "wsproto == 1.*", ] From a75da327d03ebfb50f4ecffa0f7d895c2d38cc1e Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 17 Jan 2024 12:45:33 +0200 Subject: [PATCH 65/69] Broadened version support for the `pyelftools` dependency // Resolve #4834 --- HISTORY.rst | 2 ++ platformio/pipdeps.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/HISTORY.rst b/HISTORY.rst index 63772de0..727cbe46 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -20,6 +20,8 @@ test-driven methodologies, and modern toolchains for unrivaled success. 6.1.14 (2024-??-??) ~~~~~~~~~~~~~~~~~~~ +* Broadened version support for the pyelftools dependency, enabling compatibility with lower versions and facilitating integration with a wider range of third-party tools (`issue #4834 `_) + 6.1.13 (2024-01-12) ~~~~~~~~~~~~~~~~~~~ diff --git a/platformio/pipdeps.py b/platformio/pipdeps.py index 31715be2..0ece2b65 100644 --- a/platformio/pipdeps.py +++ b/platformio/pipdeps.py @@ -25,7 +25,7 @@ def get_pip_dependencies(): "click >=8.0.4, <9", "colorama", "marshmallow == 3.*", - "pyelftools == 0.30", + "pyelftools >=0.27, <1", "pyserial == 3.5.*", # keep in sync "device/monitor/terminal.py" "requests%s == 2.*" % ("[socks]" if is_proxy_set(socks=True) else ""), "semantic_version == 2.10.*", From 28c90652bc527c7f76be7d40803b1c5814946972 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Mon, 22 Jan 2024 22:51:23 +0200 Subject: [PATCH 66/69] Update deps --- platformio/pipdeps.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/platformio/pipdeps.py b/platformio/pipdeps.py index 0ece2b65..771290c1 100644 --- a/platformio/pipdeps.py +++ b/platformio/pipdeps.py @@ -35,8 +35,8 @@ def get_pip_dependencies(): home = [ # PIO Home requirements "ajsonrpc == 1.2.*", - "starlette >=0.19, <0.36", - "uvicorn %s" % ("== 0.16.0" if PY36 else ">=0.16, <0.27"), + "starlette >=0.19, <0.37", + "uvicorn %s" % ("== 0.16.0" if PY36 else ">=0.16, <0.28"), "wsproto == 1.*", ] From 84c7ede0e102857c0edb852c0572514aa637883b Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Mon, 22 Jan 2024 22:54:58 +0200 Subject: [PATCH 67/69] Sync docs --- docs | 2 +- platformio/pipdeps.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs b/docs index 3f021525..64a2a3b6 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit 3f02152561334a92bd8cae5c49e35cc194f86721 +Subproject commit 64a2a3b6dabd084b64a832fb35f6d3669adaf506 diff --git a/platformio/pipdeps.py b/platformio/pipdeps.py index 771290c1..f41218ea 100644 --- a/platformio/pipdeps.py +++ b/platformio/pipdeps.py @@ -35,7 +35,7 @@ def get_pip_dependencies(): home = [ # PIO Home requirements "ajsonrpc == 1.2.*", - "starlette >=0.19, <0.37", + "starlette >=0.19, <0.36", "uvicorn %s" % ("== 0.16.0" if PY36 else ">=0.16, <0.28"), "wsproto == 1.*", ] From e3e08d96916cdbac22d5a465bbd752408ae25a6a Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Mon, 22 Jan 2024 22:57:07 +0200 Subject: [PATCH 68/69] Resolved an issue related to the relative package path in the `pio pkg publish` --- HISTORY.rst | 3 ++- platformio/package/commands/publish.py | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/HISTORY.rst b/HISTORY.rst index 727cbe46..bfe1dcba 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -20,7 +20,8 @@ test-driven methodologies, and modern toolchains for unrivaled success. 6.1.14 (2024-??-??) ~~~~~~~~~~~~~~~~~~~ -* Broadened version support for the pyelftools dependency, enabling compatibility with lower versions and facilitating integration with a wider range of third-party tools (`issue #4834 `_) +* Broadened version support for the ``pyelftools`` dependency, enabling compatibility with lower versions and facilitating integration with a wider range of third-party tools (`issue #4834 `_) +* Resolved an issue related to the relative package path in the `pio pkg publish `__ command 6.1.13 (2024-01-12) ~~~~~~~~~~~~~~~~~~~ diff --git a/platformio/package/commands/publish.py b/platformio/package/commands/publish.py index c8b4ea77..ff0f6507 100644 --- a/platformio/package/commands/publish.py +++ b/platformio/package/commands/publish.py @@ -86,6 +86,7 @@ def package_publish_cmd( # pylint: disable=too-many-arguments, too-many-locals package, owner, typex, released_at, private, notify, no_interactive, non_interactive ): click.secho("Preparing a package...", fg="cyan") + package = os.path.abspath(package) no_interactive = no_interactive or non_interactive owner = owner or AccountClient().get_logged_username() do_not_pack = ( From adf94843eaf48ae3722f5740f5b2990c182de1b8 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sat, 27 Jan 2024 14:01:42 +0200 Subject: [PATCH 69/69] Apply formatting --- platformio/account/team/commands/list.py | 12 +++++++----- platformio/builder/tools/pioplatform.py | 8 +++++--- platformio/check/cli.py | 16 ++++++++++------ platformio/debug/config/base.py | 8 +++++--- platformio/device/list/util.py | 6 +++--- platformio/device/monitor/command.py | 8 +++++--- platformio/home/rpc/handlers/project.py | 16 ++++++++++------ platformio/http.py | 8 +++++--- platformio/package/commands/install.py | 8 +++++--- platformio/package/commands/search.py | 10 ++++++---- platformio/package/manager/_install.py | 6 +++--- platformio/package/manifest/parser.py | 8 +++++--- platformio/package/meta.py | 8 +++++--- platformio/platform/_run.py | 6 +++--- platformio/project/commands/config.py | 8 +++++--- platformio/project/integration/generator.py | 8 +++++--- platformio/registry/access/commands/list.py | 8 +++++--- platformio/registry/mirror.py | 8 +++++--- platformio/remote/client/device_monitor.py | 8 +++++--- platformio/test/reports/json.py | 12 +++++++----- 20 files changed, 109 insertions(+), 71 deletions(-) diff --git a/platformio/account/team/commands/list.py b/platformio/account/team/commands/list.py index d0395d7c..5bdc8c14 100644 --- a/platformio/account/team/commands/list.py +++ b/platformio/account/team/commands/list.py @@ -48,11 +48,13 @@ def team_list_cmd(orgname, json_output): table_data.append( ( "Members:", - ", ".join( - (member.get("username") for member in team.get("members")) - ) - if team.get("members") - else "-", + ( + ", ".join( + (member.get("username") for member in team.get("members")) + ) + if team.get("members") + else "-" + ), ) ) click.echo(tabulate(table_data, tablefmt="plain")) diff --git a/platformio/builder/tools/pioplatform.py b/platformio/builder/tools/pioplatform.py index 4ce4b91d..f99a6ec5 100644 --- a/platformio/builder/tools/pioplatform.py +++ b/platformio/builder/tools/pioplatform.py @@ -75,9 +75,11 @@ def LoadPioPlatform(env): continue env.PrependENVPath( "PATH", - os.path.join(pkg.path, "bin") - if os.path.isdir(os.path.join(pkg.path, "bin")) - else pkg.path, + ( + os.path.join(pkg.path, "bin") + if os.path.isdir(os.path.join(pkg.path, "bin")) + else pkg.path + ), ) if ( not IS_WINDOWS diff --git a/platformio/check/cli.py b/platformio/check/cli.py index 1deced87..3e0c1759 100644 --- a/platformio/check/cli.py +++ b/platformio/check/cli.py @@ -122,9 +122,11 @@ def cli( silent=silent, src_filters=env_src_filters, flags=flags or env_options.get("check_flags"), - severity=[DefectItem.SEVERITY_LABELS[DefectItem.SEVERITY_HIGH]] - if silent - else severity or config.get("env:" + envname, "check_severity"), + severity=( + [DefectItem.SEVERITY_LABELS[DefectItem.SEVERITY_HIGH]] + if silent + else severity or config.get("env:" + envname, "check_severity") + ), skip_packages=skip_packages or env_options.get("check_skip_packages"), platform_packages=env_options.get("platform_packages"), ) @@ -142,9 +144,11 @@ def cli( result = {"env": envname, "tool": tool, "duration": time()} rc = ct.check( - on_defect_callback=None - if (json_output or verbose) - else lambda defect: click.echo(repr(defect)) + on_defect_callback=( + None + if (json_output or verbose) + else lambda defect: click.echo(repr(defect)) + ) ) result["defects"] = ct.get_defects() diff --git a/platformio/debug/config/base.py b/platformio/debug/config/base.py index 212d00fa..2a9f2235 100644 --- a/platformio/debug/config/base.py +++ b/platformio/debug/config/base.py @@ -194,9 +194,11 @@ class DebugConfigBase: # pylint: disable=too-many-instance-attributes cwd=server_package_dir if server_package else None, executable=result.get("executable"), arguments=[ - a.replace("$PACKAGE_DIR", server_package_dir) - if server_package_dir - else a + ( + a.replace("$PACKAGE_DIR", server_package_dir) + if server_package_dir + else a + ) for a in result.get("arguments", []) ], ) diff --git a/platformio/device/list/util.py b/platformio/device/list/util.py index 3589ee26..3847969c 100644 --- a/platformio/device/list/util.py +++ b/platformio/device/list/util.py @@ -144,9 +144,9 @@ def list_mdns_services(): if service.properties: try: properties = { - k.decode("utf8"): v.decode("utf8") - if isinstance(v, bytes) - else v + k.decode("utf8"): ( + v.decode("utf8") if isinstance(v, bytes) else v + ) for k, v in service.properties.items() } json.dumps(properties) diff --git a/platformio/device/monitor/command.py b/platformio/device/monitor/command.py index 3d3190fe..87f64449 100644 --- a/platformio/device/monitor/command.py +++ b/platformio/device/monitor/command.py @@ -125,9 +125,11 @@ def device_monitor_cmd(**options): options = apply_project_monitor_options(options, project_options) register_filters(platform=platform, options=options) options["port"] = SerialPortFinder( - board_config=platform.board_config(project_options.get("board")) - if platform and project_options.get("board") - else None, + board_config=( + platform.board_config(project_options.get("board")) + if platform and project_options.get("board") + else None + ), upload_protocol=project_options.get("upload_protocol"), ensure_ready=True, ).find(initial_port=options["port"]) diff --git a/platformio/home/rpc/handlers/project.py b/platformio/home/rpc/handlers/project.py index 2c03a7c9..817bb210 100644 --- a/platformio/home/rpc/handlers/project.py +++ b/platformio/home/rpc/handlers/project.py @@ -372,15 +372,19 @@ class ProjectRPC(BaseRPCHandler): return dict( platform=dict( - ownername=platform_pkg.metadata.spec.owner - if platform_pkg.metadata.spec - else None, + ownername=( + platform_pkg.metadata.spec.owner + if platform_pkg.metadata.spec + else None + ), name=platform.name, title=platform.title, version=str(platform_pkg.metadata.version), ), - board=platform.board_config(board_id).get_brief_data() - if board_id - else None, + board=( + platform.board_config(board_id).get_brief_data() + if board_id + else None + ), frameworks=frameworks or None, ) diff --git a/platformio/http.py b/platformio/http.py index 563f982f..18bb50c6 100644 --- a/platformio/http.py +++ b/platformio/http.py @@ -63,9 +63,11 @@ class HTTPSession(requests.Session): kwargs["timeout"] = __default_requests_timeout__ return super().request( method, - url - if url.startswith("http") or not self._x_base_url - else urljoin(self._x_base_url, url), + ( + url + if url.startswith("http") or not self._x_base_url + else urljoin(self._x_base_url, url) + ), *args, **kwargs ) diff --git a/platformio/package/commands/install.py b/platformio/package/commands/install.py index d2976644..8c987c17 100644 --- a/platformio/package/commands/install.py +++ b/platformio/package/commands/install.py @@ -222,9 +222,11 @@ def _install_project_env_libraries(project_env, options): env_lm = LibraryPackageManager( os.path.join(config.get("platformio", "libdeps_dir"), project_env), - compatibility=PackageCompatibility(**compatibility_qualifiers) - if compatibility_qualifiers - else None, + compatibility=( + PackageCompatibility(**compatibility_qualifiers) + if compatibility_qualifiers + else None + ), ) private_lm = LibraryPackageManager( os.path.join(config.get("platformio", "lib_dir")) diff --git a/platformio/package/commands/search.py b/platformio/package/commands/search.py index ac71ef4c..c3f7d5cd 100644 --- a/platformio/package/commands/search.py +++ b/platformio/package/commands/search.py @@ -65,10 +65,12 @@ def print_search_item(item): click.echo( "%s • %s • Published on %s" % ( - item["type"].capitalize() - if item["tier"] == "community" - else click.style( - ("%s %s" % (item["tier"], item["type"])).title(), bold=True + ( + item["type"].capitalize() + if item["tier"] == "community" + else click.style( + ("%s %s" % (item["tier"], item["type"])).title(), bold=True + ) ), item["version"]["name"], util.parse_datetime(item["version"]["released_at"]).strftime("%c"), diff --git a/platformio/package/manager/_install.py b/platformio/package/manager/_install.py index fc4d5ddb..125766d3 100644 --- a/platformio/package/manager/_install.py +++ b/platformio/package/manager/_install.py @@ -98,9 +98,9 @@ class PackageManagerInstallMixin: else: pkg = self.install_from_registry( spec, - search_qualifiers=compatibility.to_search_qualifiers() - if compatibility - else None, + search_qualifiers=( + compatibility.to_search_qualifiers() if compatibility else None + ), ) if not pkg or not pkg.metadata: diff --git a/platformio/package/manifest/parser.py b/platformio/package/manifest/parser.py index d3fe6bfa..7694c8a8 100644 --- a/platformio/package/manifest/parser.py +++ b/platformio/package/manifest/parser.py @@ -294,9 +294,11 @@ class BaseManifestParser: if not matched_files: continue result[root] = dict( - name="Examples" - if root == examples_dir - else os.path.relpath(root, examples_dir), + name=( + "Examples" + if root == examples_dir + else os.path.relpath(root, examples_dir) + ), base=os.path.relpath(root, package_dir), files=matched_files, ) diff --git a/platformio/package/meta.py b/platformio/package/meta.py index b1c491d7..b9e3750d 100644 --- a/platformio/package/meta.py +++ b/platformio/package/meta.py @@ -485,9 +485,11 @@ class PackageItem: def __eq__(self, other): conds = [ - os.path.realpath(self.path) == os.path.realpath(other.path) - if self.path and other.path - else self.path == other.path, + ( + os.path.realpath(self.path) == os.path.realpath(other.path) + if self.path and other.path + else self.path == other.path + ), self.metadata == other.metadata, ] return all(conds) diff --git a/platformio/platform/_run.py b/platformio/platform/_run.py index 949a452d..2912371d 100644 --- a/platformio/platform/_run.py +++ b/platformio/platform/_run.py @@ -116,9 +116,9 @@ class PlatformRunMixin: args, stdout=proc.BuildAsyncPipe( line_callback=self._on_stdout_line, - data_callback=lambda data: None - if self.silent - else _write_and_flush(sys.stdout, data), + data_callback=lambda data: ( + None if self.silent else _write_and_flush(sys.stdout, data) + ), ), stderr=proc.BuildAsyncPipe( line_callback=self._on_stderr_line, diff --git a/platformio/project/commands/config.py b/platformio/project/commands/config.py index 5e4ed21f..214b0db1 100644 --- a/platformio/project/commands/config.py +++ b/platformio/project/commands/config.py @@ -82,9 +82,11 @@ def lint_configuration(json_output=False): ( click.style(error["type"], fg="red"), error["message"], - error.get("source", "") + (f":{error.get('lineno')}") - if "lineno" in error - else "", + ( + error.get("source", "") + (f":{error.get('lineno')}") + if "lineno" in error + else "" + ), ) for error in errors ], diff --git a/platformio/project/integration/generator.py b/platformio/project/integration/generator.py index d55f9aa7..3cb677f1 100644 --- a/platformio/project/integration/generator.py +++ b/platformio/project/integration/generator.py @@ -91,9 +91,11 @@ class ProjectGenerator: "default_debug_env_name": get_default_debug_env(self.config), "env_name": self.env_name, "user_home_dir": os.path.abspath(fs.expanduser("~")), - "platformio_path": sys.argv[0] - if os.path.isfile(sys.argv[0]) - else where_is_program("platformio"), + "platformio_path": ( + sys.argv[0] + if os.path.isfile(sys.argv[0]) + else where_is_program("platformio") + ), "env_path": os.getenv("PATH"), "env_pathsep": os.pathsep, } diff --git a/platformio/registry/access/commands/list.py b/platformio/registry/access/commands/list.py index ce9d8a6a..50073031 100644 --- a/platformio/registry/access/commands/list.py +++ b/platformio/registry/access/commands/list.py @@ -41,9 +41,11 @@ def access_list_cmd(owner, urn_type, json_output): # pylint: disable=unused-arg table_data.append( ( "Access:", - click.style("Private", fg="red") - if resource.get("private", False) - else "Public", + ( + click.style("Private", fg="red") + if resource.get("private", False) + else "Public" + ), ) ) table_data.append( diff --git a/platformio/registry/mirror.py b/platformio/registry/mirror.py index 4b4508f6..8805ffe5 100644 --- a/platformio/registry/mirror.py +++ b/platformio/registry/mirror.py @@ -54,9 +54,11 @@ class RegistryFileMirrorIterator: "head", self._url_parts.path, allow_redirects=False, - params=dict(bypass=",".join(self._visited_mirrors)) - if self._visited_mirrors - else None, + params=( + dict(bypass=",".join(self._visited_mirrors)) + if self._visited_mirrors + else None + ), x_with_authorization=RegistryClient.allowed_private_packages(), ) stop_conditions = [ diff --git a/platformio/remote/client/device_monitor.py b/platformio/remote/client/device_monitor.py index 1499dd58..4e1ccb2f 100644 --- a/platformio/remote/client/device_monitor.py +++ b/platformio/remote/client/device_monitor.py @@ -123,9 +123,11 @@ class DeviceMonitorClient( # pylint: disable=too-many-instance-attributes index=i + 1, host=device[0] + ":" if len(result) > 1 else "", port=device[1]["port"], - description=device[1]["description"] - if device[1]["description"] != "n/a" - else "", + description=( + device[1]["description"] + if device[1]["description"] != "n/a" + else "" + ), ) ) device_index = click.prompt( diff --git a/platformio/test/reports/json.py b/platformio/test/reports/json.py index 791224c7..3d3c6f6e 100644 --- a/platformio/test/reports/json.py +++ b/platformio/test/reports/json.py @@ -62,11 +62,13 @@ class JsonTestReport(TestReportBase): test_dir=test_suite.test_dir, status=test_suite.status.name, duration=test_suite.duration, - timestamp=datetime.datetime.fromtimestamp(test_suite.timestamp).strftime( - "%Y-%m-%dT%H:%M:%S" - ) - if test_suite.timestamp - else None, + timestamp=( + datetime.datetime.fromtimestamp(test_suite.timestamp).strftime( + "%Y-%m-%dT%H:%M:%S" + ) + if test_suite.timestamp + else None + ), testcase_nums=len(test_suite.cases), error_nums=test_suite.get_status_nums(TestStatus.ERRORED), failure_nums=test_suite.get_status_nums(TestStatus.FAILED),