Skip to content

Commit f660117

Browse files
authored
Merge pull request #8481 from dhalbert/v1.20-merge
Merge from MicroPython v1.20.0
2 parents e232b13 + f78b35d commit f660117

File tree

729 files changed

+13299
-8769
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

729 files changed

+13299
-8769
lines changed

.codespell/ignore-words.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,5 @@ numer
2424
arithmetics
2525
ftbfs
2626
straightaway
27+
ftbs
28+
ftb

.git-blame-ignore-revs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
#all: Reformat remaining C code that doesn't have a space after a comma.
1+
# top: Update Python formatting to black "2023 stable style".
2+
8b2748269244304854b3462cb8902952b4dcb892
3+
4+
# all: Reformat remaining C code that doesn't have a space after a comma.
25
5b700b0af90591d6b1a2c087bb8de6b7f1bfdd2d
36

47
# ports: Reformat more C and Python source code.

.github/actions/mpy_cross/action.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ inputs:
55
required: false
66
default: true
77
type: boolean
8+
cp-version:
9+
required: true
10+
type: string
811

912
runs:
1013
using: composite
@@ -16,22 +19,24 @@ runs:
1619
uses: actions/download-artifact@v3
1720
with:
1821
name: mpy-cross
19-
path: mpy-cross
22+
path: mpy-cross/build
2023

2124
- name: Make mpy-cross executable
2225
if: inputs.download == 'true' && steps.download-mpy-cross.outcome == 'success'
23-
run: sudo chmod +x mpy-cross/mpy-cross
26+
run: sudo chmod +x mpy-cross/build/mpy-cross
2427
shell: bash
2528

2629
- name: Build mpy-cross
2730
if: inputs.download == 'false' || steps.download-mpy-cross.outcome == 'failure'
2831
run: make -C mpy-cross -j2
2932
shell: bash
33+
env:
34+
CP_VERSION: ${{ inputs.cp-version }}
3035

3136
- name: Upload mpy-cross
3237
if: inputs.download == 'false' || steps.download-mpy-cross.outcome == 'failure'
3338
continue-on-error: true
3439
uses: actions/upload-artifact@v3
3540
with:
3641
name: mpy-cross
37-
path: mpy-cross/mpy-cross
42+
path: mpy-cross/build/mpy-cross

.github/workflows/build-boards.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ jobs:
4949
- name: Set up mpy-cross
5050
if: steps.set-up-submodules.outputs.frozen == 'True'
5151
uses: ./.github/actions/mpy_cross
52+
with:
53+
cp-version: ${{ inputs.cp-version }}
5254

5355
- name: Versions
5456
run: |

.github/workflows/build-mpy-cross.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,11 @@ jobs:
6464
uses: actions/upload-artifact@v3
6565
with:
6666
name: mpy-cross.${{ env.EX }}
67-
path: mpy-cross/mpy-cross.${{ env.EX }}
67+
path: mpy-cross/build-${{ env.EX}}/mpy-cross.${{ env.EX }}
6868
- name: Upload to S3
6969
uses: ./.github/actions/upload_aws
7070
with:
71-
source: mpy-cross/mpy-cross.${{ env.EX }}
71+
source: mpy-cross/build-${{ env.EX}}/mpy-cross.${{ env.EX }}
7272
destination: mpy-cross/${{ env.OS }}/mpy-cross-${{ env.OS }}-${{ env.CP_VERSION }}.${{ env.EX }}
7373
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
7474
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

.github/workflows/build.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ jobs:
5151
- name: Set up mpy-cross
5252
uses: ./.github/actions/mpy_cross
5353
with:
54+
cp-version: ${{ steps.set-up-submodules.outputs.version }}
5455
download: false
5556
- name: Get last commit with checks
5657
id: get-last-commit-with-checks
@@ -127,15 +128,15 @@ jobs:
127128
- uses: actions/upload-artifact@v3
128129
with:
129130
name: mpy-cross-macos-11-x64
130-
path: mpy-cross/mpy-cross
131+
path: mpy-cross/build/mpy-cross
131132
- name: Build mpy-cross (arm64)
132133
run: make -C mpy-cross -j2 -f Makefile.m1 V=2
133134
- uses: actions/upload-artifact@v3
134135
with:
135136
name: mpy-cross-macos-11-arm64
136-
path: mpy-cross/mpy-cross-arm64
137+
path: mpy-cross/build-arm64/mpy-cross-arm64
137138
- name: Make universal binary
138-
run: lipo -create -output mpy-cross-macos-universal mpy-cross/mpy-cross mpy-cross/mpy-cross-arm64
139+
run: lipo -create -output mpy-cross-macos-universal mpy-cross/build/mpy-cross mpy-cross/build-arm64/mpy-cross-arm64
139140
- name: Upload artifact
140141
uses: actions/upload-artifact@v3
141142
with:

.github/workflows/custom-board-build.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ jobs:
6565
if: steps.set-up-submodules.outputs.frozen == 'True'
6666
uses: ./.github/actions/mpy_cross
6767
with:
68+
cp-version: ${{ steps.set-up-submodules.outputs.version }}
6869
download: false
6970
- name: Versions
7071
run: |

.github/workflows/run-tests.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
env:
1818
CP_VERSION: ${{ inputs.cp-version }}
1919
MICROPY_CPYTHON3: python3.8
20-
MICROPY_MICROPYTHON: ../ports/unix/micropython-coverage
20+
MICROPY_MICROPYTHON: ../ports/unix/build-coverage/micropython
2121
TEST_all:
2222
TEST_mpy: --via-mpy -d basics float micropython
2323
TEST_native: --emit native
@@ -41,6 +41,8 @@ jobs:
4141
uses: ./.github/actions/deps/external
4242
- name: Set up mpy-cross
4343
uses: ./.github/actions/mpy_cross
44+
with:
45+
cp-version: ${{ inputs.cp-version }}
4446
- name: Build unix port
4547
run: make -C ports/unix VARIANT=coverage -j2
4648
- name: Run tests

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,9 @@
345345
path = ports/raspberrypi/lib/Pico-PIO-USB
346346
url = https://github.com/sekigon-gonnoc/Pico-PIO-USB.git
347347
branch = main
348+
[submodule "lib/micropython-lib"]
349+
path = lib/micropython-lib
350+
url = https://github.com/micropython/micropython-lib.git
348351
[submodule "lib/certificates"]
349352
path = lib/certificates
350353
url = https://github.com/adafruit/certificates

.pre-commit-config.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ repos:
1919
exclude: |
2020
(?x)^(
2121
locale/|
22-
lib/
22+
lib/|
23+
tests/unicode/data/utf-8_invalid.txt|
24+
tests/extmod/data/qr.pgm|
25+
tests/basics/bytearray_byte_operations.py
2326
)
2427
- repo: local
2528
hooks:

LICENSE

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
MIT License
1+
The MIT License (MIT)
22

3-
Copyright (c) 2013-2022 Damien P. George and others
3+
Copyright (c) 2013-2023 Damien P. George
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal
@@ -9,8 +9,8 @@ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
99
copies of the Software, and to permit persons to whom the Software is
1010
furnished to do so, subject to the following conditions:
1111

12-
The above copyright notice and this permission notice shall be included in all
13-
copies or substantial portions of the Software.
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
1414

1515
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1616
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,

conf.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,8 @@ def autoapi_prepare_jinja_env(jinja_env):
202202
"ports/cxd56/spresense-exported-sdk",
203203
"ports/espressif/certificates",
204204
"ports/espressif/esp-idf",
205-
"ports/espressif/esp32-camera",
205+
"ports/espressif/esp-camera",
206+
"ports/espressif/esp-protocols",
206207
"ports/espressif/.idf_tools",
207208
"ports/espressif/peripherals",
208209
"ports/litex/hw",

devices/ble_hci/common-hal/_bleio/att.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
#include "shared-bindings/_bleio/Service.h"
4545
#include "shared-bindings/_bleio/UUID.h"
4646
#include "supervisor/shared/tick.h"
47-
#include "supervisor/shared/translate/translate.h"
4847

4948
STATIC uint16_t max_mtu = BT_ATT_DEFAULT_LE_MTU; // 23
5049
STATIC unsigned long timeout = 5000;

docs/index.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ Full Table of Contents
3333
design_guide
3434
porting
3535
common_hal
36-
reference/mpyfiles.rst
3736
reference/glossary.rst
3837

3938
.. toctree::

docs/library/array.rst

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,55 @@ Classes
2727

2828
Append new elements as contained in `iterable` to the end of
2929
array, growing it.
30+
31+
.. method:: __getitem__(index)
32+
33+
Indexed read of the array, called as ``a[index]`` (where ``a`` is an ``array``).
34+
Returns a value if *index* is an ``int`` and an ``array`` if *index* is a slice.
35+
Negative indices count from the end and ``IndexError`` is thrown if the index is
36+
out of range.
37+
38+
**Note:** ``__getitem__`` cannot be called directly (``a.__getitem__(index)`` fails) and
39+
is not present in ``__dict__``, however ``a[index]`` does work.
40+
41+
.. method:: __setitem__(index, value)
42+
43+
Indexed write into the array, called as ``a[index] = value`` (where ``a`` is an ``array``).
44+
``value`` is a single value if *index* is an ``int`` and an ``array`` if *index* is a slice.
45+
Negative indices count from the end and ``IndexError`` is thrown if the index is out of range.
46+
47+
**Note:** ``__setitem__`` cannot be called directly (``a.__setitem__(index, value)`` fails) and
48+
is not present in ``__dict__``, however ``a[index] = value`` does work.
49+
50+
.. method:: __len__()
51+
52+
Returns the number of items in the array, called as ``len(a)`` (where ``a`` is an ``array``).
53+
54+
**Note:** ``__len__`` cannot be called directly (``a.__len__()`` fails) and the
55+
method is not present in ``__dict__``, however ``len(a)`` does work.
56+
57+
.. method:: __add__(other)
58+
59+
Return a new ``array`` that is the concatenation of the array with *other*, called as
60+
``a + other`` (where ``a`` and *other* are both ``arrays``).
61+
62+
**Note:** ``__add__`` cannot be called directly (``a.__add__(other)`` fails) and
63+
is not present in ``__dict__``, however ``a + other`` does work.
64+
65+
.. method:: __iadd__(other)
66+
67+
Concatenates the array with *other* in-place, called as ``a += other`` (where ``a`` and *other*
68+
are both ``arrays``). Equivalent to ``extend(other)``.
69+
70+
**Note:** ``__iadd__`` cannot be called directly (``a.__iadd__(other)`` fails) and
71+
is not present in ``__dict__``, however ``a += other`` does work.
72+
73+
.. method:: __repr__()
74+
75+
Returns the string representation of the array, called as ``str(a)`` or ``repr(a)```
76+
(where ``a`` is an ``array``). Returns the string ``"array(<type>, [<elements>])"``,
77+
where ``<type>`` is the type code letter for the array and ``<elements>`` is a comma
78+
separated list of the elements of the array.
79+
80+
**Note:** ``__repr__`` cannot be called directly (``a.__repr__()`` fails) and
81+
is not present in ``__dict__``, however ``str(a)`` and ``repr(a)`` both work.

docs/reference/glossary.rst

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ Glossary
5252
cross-compiler
5353
Also known as ``mpy-cross``. This tool runs on your PC and converts a
5454
:term:`.py file` containing MicroPython code into a :term:`.mpy file`
55-
containing MicroPython bytecode. This means it loads faster (the board
55+
containing MicroPython :term:`bytecode`. This means it loads faster (the board
5656
doesn't have to compile the code), and uses less space on flash (the
5757
bytecode is more space efficient).
5858

@@ -112,6 +112,24 @@ Glossary
112112
require much less power. MicroPython is designed to be small and
113113
optimized enough to run on an average modern microcontroller.
114114

115+
micropython-lib
116+
MicroPython is (usually) distributed as a single executable/binary
117+
file with just few builtin modules. There is no extensive standard
118+
library comparable with :term:`CPython`'s. Instead, there is a related,
119+
but separate project `micropython-lib
120+
<https://github.com/micropython/micropython-lib>`_ which provides
121+
implementations for many modules from CPython's standard library.
122+
123+
Some of the modules are are implemented in pure Python, and are able to
124+
be used on all ports. However, the majority of these modules use
125+
:term:`FFI` to access operating system functionality, and as such can
126+
only be used on the :term:`MicroPython Unix port` (with limited support
127+
for Windows).
128+
129+
Unlike the :term:`CPython` stdlib, micropython-lib modules are
130+
intended to be installed individually - either using manual copying or
131+
using :term:`mip`.
132+
115133
MicroPython port
116134
MicroPython supports different :term:`boards <board>`, RTOSes, and
117135
OSes, and can be relatively easily adapted to new systems. MicroPython
@@ -133,16 +151,26 @@ Glossary
133151
machine-independent features. It can also function in a similar way to
134152
:term:`CPython`'s ``python`` executable.
135153

154+
mip
155+
A package installer for MicroPython (mip - "mip installs packages"). It
156+
installs MicroPython packages either from :term:`micropython-lib`,
157+
GitHub, or arbitrary URLs. mip can be used on-device on
158+
network-capable boards, and internally by tools such
159+
as :term:`mpremote`.
160+
161+
mpremote
162+
A tool for interacting with a MicroPython device.
163+
136164
.mpy file
137165
The output of the :term:`cross-compiler`. A compiled form of a
138-
:term:`.py file` that contains MicroPython bytecode instead of Python
139-
source code.
166+
:term:`.py file` that contains MicroPython :term:`bytecode` instead of
167+
Python source code.
140168

141169
native
142170
Usually refers to "native code", i.e. machine code for the target
143171
microcontroller (such as ARM Thumb, Xtensa, x86/x64). The ``@native``
144172
decorator can be applied to a MicroPython function to generate native
145-
code instead of bytecode for that function, which will likely be
173+
code instead of :term:`bytecode` for that function, which will likely be
146174
faster but use more RAM.
147175

148176
port
@@ -173,3 +201,12 @@ Glossary
173201
peripheral that sends data over a pair of pins (TX & RX). Many boards
174202
include a way to make at least one of the UARTs available to a host PC
175203
as a serial port over USB.
204+
205+
upip
206+
A now-obsolete package manager for MicroPython, inspired
207+
by :term:`CPython`'s pip, but much smaller and with reduced
208+
functionality. See its replacement, :term:`mip`.
209+
210+
webrepl
211+
A way of connecting to the REPL (and transferring files) on a device
212+
over the internet from a browser. See https://micropython.org/webrepl

0 commit comments

Comments
 (0)