Skip to content

Commit 7527143

Browse files
committed
Merge branch 'release/v6.1.2'
2 parents b9920b2 + cd4f554 commit 7527143

File tree

12 files changed

+66
-25
lines changed

12 files changed

+66
-25
lines changed

HISTORY.rst

+9
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,15 @@ PlatformIO Core 6
1313

1414
**A professional collaborative platform for declarative, safety-critical, and test-driven embedded development.**
1515

16+
6.1.2 (2022-07-18)
17+
~~~~~~~~~~~~~~~~~~
18+
19+
* Export a ``PIO_UNIT_TESTING`` macro to the project source files and dependent libraries in the |UNITTESTING| mode
20+
* Improved detection of Windows architecture (`issue #4353 <https://github.com/platformio/platformio-core/issues/4353>`_)
21+
* Warn about unknown `device monitor filters <https://docs.platformio.org/en/latest/core/userguide/device/cmd_monitor.html#filters>`__ (`issue #4362 <https://github.com/platformio/platformio-core/issues/4362>`_)
22+
* Fixed a regression bug when `libArchive <https://docs.platformio.org/en/latest/manifests/library-json/fields/build/libarchive.html>`__ option declared in the `library.json <https://docs.platformio.org/en/latest/manifests/library-json/index.html>`__ manifest was ignored (`issue #4351 <https://github.com/platformio/platformio-core/issues/4351>`_)
23+
* Fixed an issue when the `pio pkg publish <https://docs.platformio.org/en/latest/core/userguide/pkg/cmd_publish.html>`__ command didn't work with Python 3.6 (`issue #4352 <https://github.com/platformio/platformio-core/issues/4352>`_)
24+
1625
6.1.1 (2022-07-11)
1726
~~~~~~~~~~~~~~~~~~
1827

platformio/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
import sys
1616

17-
VERSION = (6, 1, 1)
17+
VERSION = (6, 1, 2)
1818
__version__ = ".".join([str(s) for s in VERSION])
1919

2020
__title__ = "platformio"

platformio/builder/tools/piolib.py

+11-5
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
from platformio import exception, fs
3232
from platformio.builder.tools import platformio as piotool
33-
from platformio.compat import IS_WINDOWS, MISSING, hashlib_encode_data, string_types
33+
from platformio.compat import IS_WINDOWS, hashlib_encode_data, string_types
3434
from platformio.http import HTTPClientError, InternetIsOffline
3535
from platformio.package.exception import (
3636
MissingPackageManifestError,
@@ -145,6 +145,10 @@ def __init__(self, env, path, manifest=None, verbose=False):
145145
self._circular_deps = []
146146
self._processed_search_files = []
147147

148+
# pass a macro to the projenv + libs
149+
if "test" in env.GetBuildType():
150+
self.env.Append(CPPDEFINES=["PIO_UNIT_TESTING"])
151+
148152
# reset source filter, could be overridden with extra script
149153
self.env["SRC_FILTER"] = ""
150154

@@ -576,10 +580,11 @@ def lib_ldf_mode(self):
576580
# pylint: disable=no-member
577581
if not self._manifest.get("dependencies"):
578582
return LibBuilderBase.lib_ldf_mode.fget(self)
583+
missing = object()
579584
global_value = self.env.GetProjectConfig().getraw(
580-
"env:" + self.env["PIOENV"], "lib_ldf_mode", MISSING
585+
"env:" + self.env["PIOENV"], "lib_ldf_mode", missing
581586
)
582-
if global_value != MISSING:
587+
if global_value != missing:
583588
return LibBuilderBase.lib_ldf_mode.fget(self)
584589
# automatically enable C++ Preprocessing in runtime
585590
# (Arduino IDE has this behavior)
@@ -831,10 +836,11 @@ def extra_script(self):
831836

832837
@property
833838
def lib_archive(self):
839+
missing = object()
834840
global_value = self.env.GetProjectConfig().getraw(
835-
"env:" + self.env["PIOENV"], "lib_archive", MISSING
841+
"env:" + self.env["PIOENV"], "lib_archive", missing
836842
)
837-
if global_value != MISSING:
843+
if global_value != missing:
838844
return self.env.GetProjectConfig().get(
839845
"env:" + self.env["PIOENV"], "lib_archive"
840846
)

platformio/builder/tools/piotest.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
def ConfigureTestTarget(env):
2525
env.Append(
26-
CPPDEFINES=["UNIT_TEST", "PIO_UNIT_TESTING"],
26+
CPPDEFINES=["UNIT_TEST"], # deprecated, use PIO_UNIT_TESTING
2727
PIOTEST_SRC_FILTER=[f"+<*.{ext}>" for ext in piotool.SRC_BUILD_EXT],
2828
)
2929
env.Prepend(CPPPATH=["$PROJECT_TEST_DIR"])

platformio/compat.py

+9
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,15 @@ def is_bytes(x):
4141
return isinstance(x, (bytes, memoryview, bytearray))
4242

4343

44+
def isascii(text):
45+
if sys.version_info >= (3, 7):
46+
return text.isascii()
47+
for c in text or "":
48+
if ord(c) > 127:
49+
return False
50+
return True
51+
52+
4453
def ci_strings_are_equal(a, b):
4554
if a == b:
4655
return True

platformio/debug/config/base.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import os
1717

1818
from platformio import fs, proc, util
19-
from platformio.compat import MISSING, string_types
19+
from platformio.compat import string_types
2020
from platformio.debug.exception import DebugInvalidOptionsError
2121
from platformio.project.config import ProjectConfig
2222
from platformio.project.helpers import load_build_metadata
@@ -96,8 +96,9 @@ def load_mode(self):
9696

9797
@property
9898
def init_break(self):
99-
result = self.env_options.get("debug_init_break", MISSING)
100-
if result != MISSING:
99+
missed = object()
100+
result = self.env_options.get("debug_init_break", missed)
101+
if result != missed:
101102
return result
102103
result = None
103104
if not result:

platformio/device/monitor/command.py

+12-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from platformio import exception, fs
2121
from platformio.device.finder import find_serial_port
2222
from platformio.device.monitor.filters.base import register_filters
23-
from platformio.device.monitor.terminal import start_terminal
23+
from platformio.device.monitor.terminal import get_available_filters, start_terminal
2424
from platformio.platform.factory import PlatformFactory
2525
from platformio.project.config import ProjectConfig
2626
from platformio.project.exception import NotPlatformIOProjectError
@@ -138,6 +138,17 @@ def device_monitor_cmd(**options):
138138
"--exit-char can not be the same as --menu-char"
139139
)
140140

141+
# check for unknown filters
142+
known_filters = set(get_available_filters())
143+
unknown_filters = set(options["filters"]) - known_filters
144+
if unknown_filters:
145+
options["filters"] = list(known_filters & set(options["filters"]))
146+
click.secho(
147+
("Warning! Skipping unknown filters `%s`. Known filters are `%s`")
148+
% (", ".join(unknown_filters), ", ".join(sorted(known_filters))),
149+
fg="yellow",
150+
)
151+
141152
start_terminal(options)
142153

143154

platformio/device/monitor/terminal.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ def writer(self):
4141
self.pio_unexpected_exception = exc
4242

4343

44+
def get_available_filters():
45+
return sorted(miniterm.TRANSFORMATIONS.keys())
46+
47+
4448
def start_terminal(options):
4549
retries = 0
4650
is_port_valid = False
@@ -116,7 +120,7 @@ def print_terminal_settings(terminal):
116120
)
117121
click.echo(
118122
"--- Available filters and text transformations: %s"
119-
% ", ".join(sorted(miniterm.TRANSFORMATIONS.keys()))
123+
% ", ".join(get_available_filters())
120124
)
121125
click.echo("--- More details at https://bit.ly/pio-monitor-filters")
122126
click.echo(

platformio/http.py

+4-7
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
# limitations under the License.
1414

1515
import json
16-
import math
1716
import os
1817
import socket
1918
from urllib.parse import urljoin
@@ -63,9 +62,10 @@ def __init__(self, endpoints):
6362
endpoints = [endpoints]
6463
self.endpoints = endpoints
6564
self.endpoints_iter = iter(endpoints)
65+
# https://urllib3.readthedocs.io/en/stable/reference/urllib3.util.html
6666
self.retry = Retry(
67-
total=math.ceil(6 / len(self.endpoints)),
68-
backoff_factor=1,
67+
total=5,
68+
backoff_factor=1, # [0, 2, 4, 8, 16] secs
6969
# method_whitelist=list(Retry.DEFAULT_METHOD_WHITELIST) + ["POST"],
7070
status_forcelist=[413, 429, 500, 502, 503, 504],
7171
)
@@ -129,10 +129,7 @@ def send_request(self, method, path, **kwargs):
129129
while True:
130130
try:
131131
return getattr(self._session, method)(path, **kwargs)
132-
except (
133-
requests.exceptions.ConnectionError,
134-
requests.exceptions.Timeout,
135-
) as exc:
132+
except requests.exceptions.RequestException as exc:
136133
try:
137134
self._next_session()
138135
except Exception as exc2:

platformio/package/commands/publish.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
from platformio import fs
2424
from platformio.account.client import AccountClient
25+
from platformio.compat import isascii
2526
from platformio.exception import UserSideException
2627
from platformio.package.manifest.parser import ManifestParserFactory
2728
from platformio.package.manifest.schema import ManifestSchema
@@ -155,7 +156,7 @@ def package_publish_cmd( # pylint: disable=too-many-arguments, too-many-locals
155156
def check_archive_file_names(archive_path):
156157
with tarfile.open(archive_path, mode="r:gz") as tf:
157158
for name in tf.getnames():
158-
if not name.isascii():
159+
if not isascii(name) or not name.isprintable():
159160
click.secho(
160161
f"Warning! The `{name}` file contains non-ASCII chars and can "
161162
"lead to the unpacking issues on a user machine",

platformio/util.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,14 @@ def get_instance(*args, **kwargs):
139139

140140

141141
def get_systype():
142-
type_ = platform.system().lower()
142+
system = platform.system().lower()
143143
arch = platform.machine().lower()
144-
if type_ == "windows" and "x86" in arch:
145-
arch = "amd64" if "64" in arch else "x86"
146-
return "%s_%s" % (type_, arch) if arch else type_
144+
if system == "windows":
145+
if not arch: # issue #4353
146+
arch = "x86_" + platform.architecture()[0]
147+
if "x86" in arch:
148+
arch = "amd64" if "64" in arch else "x86"
149+
return "%s_%s" % (system, arch) if arch else system
147150

148151

149152
def pioversion_to_intstr():

0 commit comments

Comments
 (0)