mpbuild 0.5__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mpbuild-0.5/.gitignore +10 -0
- mpbuild-0.5/.pre-commit-config.yaml +20 -0
- mpbuild-0.5/.python-version +1 -0
- mpbuild-0.5/LICENSE +21 -0
- mpbuild-0.5/PKG-INFO +141 -0
- mpbuild-0.5/README.md +131 -0
- mpbuild-0.5/pyproject.toml +36 -0
- mpbuild-0.5/requirements-dev.lock +27 -0
- mpbuild-0.5/requirements.lock +27 -0
- mpbuild-0.5/src/mpbuild/__init__.py +21 -0
- mpbuild-0.5/src/mpbuild/__main__.py +9 -0
- mpbuild-0.5/src/mpbuild/board_database.py +187 -0
- mpbuild-0.5/src/mpbuild/build.py +155 -0
- mpbuild-0.5/src/mpbuild/check_images.py +87 -0
- mpbuild-0.5/src/mpbuild/cli.py +119 -0
- mpbuild-0.5/src/mpbuild/completions.py +17 -0
- mpbuild-0.5/src/mpbuild/find_boards.py +26 -0
- mpbuild-0.5/src/mpbuild/list_boards.py +41 -0
- mpbuild-0.5/uv.lock +260 -0
mpbuild-0.5/.gitignore
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# See https://pre-commit.com for more information
|
|
2
|
+
# See https://pre-commit.com/hooks.html for more hooks
|
|
3
|
+
repos:
|
|
4
|
+
- repo: https://github.com/pre-commit/pre-commit-hooks
|
|
5
|
+
rev: v3.2.0
|
|
6
|
+
hooks:
|
|
7
|
+
- id: trailing-whitespace
|
|
8
|
+
- id: end-of-file-fixer
|
|
9
|
+
- id: check-yaml
|
|
10
|
+
- id: check-added-large-files
|
|
11
|
+
|
|
12
|
+
- repo: https://github.com/astral-sh/ruff-pre-commit
|
|
13
|
+
# Ruff version.
|
|
14
|
+
rev: v0.6.1
|
|
15
|
+
hooks:
|
|
16
|
+
# Run the linter.
|
|
17
|
+
- id: ruff
|
|
18
|
+
args: [ --fix ]
|
|
19
|
+
# Run the formatter.
|
|
20
|
+
- id: ruff-format
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.12.2
|
mpbuild-0.5/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Matt Trentini
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
mpbuild-0.5/PKG-INFO
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
|
+
Name: mpbuild
|
|
3
|
+
Version: 0.5
|
|
4
|
+
Summary: Build MicroPython firmware with ease!
|
|
5
|
+
Author-email: Matt Trentini <matt.trentini@gmail.com>
|
|
6
|
+
Requires-Python: >=3.9
|
|
7
|
+
Requires-Dist: rich>=13.7.1
|
|
8
|
+
Requires-Dist: typer>=0.12.3
|
|
9
|
+
Description-Content-Type: text/markdown
|
|
10
|
+
|
|
11
|
+
<div align="center">
|
|
12
|
+
|
|
13
|
+
# mpbuild
|
|
14
|
+
|
|
15
|
+

|
|
16
|
+
|
|
17
|
+
Build MicroPython firmware with ease!
|
|
18
|
+
|
|
19
|
+
**mpbuild** builds MicroPython firmware in containers so you don't need to install any compiler toolchains or development tools. It knows which containers to use for each board so the appropriate build tools are used.
|
|
20
|
+
|
|
21
|
+
</div>
|
|
22
|
+
|
|
23
|
+
## Table of Contents
|
|
24
|
+
|
|
25
|
+
- [Usage](#usage)
|
|
26
|
+
- [Advanced Usage](#advanced-usage)
|
|
27
|
+
- [Use as a Module](#use-as-a-module)
|
|
28
|
+
- [Installation](#installation)
|
|
29
|
+
- [Prerequisites](#prerequisites)
|
|
30
|
+
- [Examples](#examples)
|
|
31
|
+
- [Related links](#related-links)
|
|
32
|
+
|
|
33
|
+
## Usage
|
|
34
|
+
|
|
35
|
+
**mpbuild** is intended to be executed in the root of a MicroPython repository. Help text (accessed with adding `--help`) is extensive and documents advanced options.
|
|
36
|
+
|
|
37
|
+
> [!NOTE]
|
|
38
|
+
> Note that there are some _special_ builds. `unix`, `webassembly` and `windows` can all be specified as `BOARD`s but their target isn't a microcontroller. See the [MicroPython documentation](https://github.com/micropython/micropython/) for details.
|
|
39
|
+
|
|
40
|
+
> [!WARNING]
|
|
41
|
+
> Currently **mpbuild** is tested on Linux (specifically Ubuntu 24.04 on WSL on Windows 11) but it's intended to work on any platform that supports Docker.
|
|
42
|
+
|
|
43
|
+
Build a board, with optional variant:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
mpbuild build BOARD [VARIANT]
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Remove build artifacts:
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
mpbuild clean BOARD [VARIANT]
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
List the available boards, optionally filter by the port name.
|
|
56
|
+
|
|
57
|
+
Displays the board names (as a clickable link), variants and number of boards per port:
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
mpbuild list [PORT]
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Advanced Usage
|
|
64
|
+
|
|
65
|
+
Validate the state of all images referenced in board definitions:
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
mpbuild check_images
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Use as a Module
|
|
72
|
+
|
|
73
|
+
> [!CAUTION]
|
|
74
|
+
> This is _very much_ a work-in-progress and the API is subject to change.
|
|
75
|
+
|
|
76
|
+
**mpbuild** can also be used from Python as a module. This allows it to easily be integrated into other tools.
|
|
77
|
+
|
|
78
|
+
Example:
|
|
79
|
+
|
|
80
|
+
```python
|
|
81
|
+
import mpbuild
|
|
82
|
+
|
|
83
|
+
mpbuild.build("RPI_PICO")
|
|
84
|
+
mpbuild.list()
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Installation
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
uv tool install mpbuild
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Or use pipx, pip etc.
|
|
94
|
+
|
|
95
|
+
After installation, you may want to also install command-line tab completion for your shell (bash, zsh, fish and PowerShell are supported). Tab completion includes the various mpbuild commands as well as the board names and variants:
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
mpbuild --install-completion
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### Prerequisites
|
|
102
|
+
|
|
103
|
+
A clone of MicroPython (or a fork):
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
git clone git@github.com:micropython/micropython.git
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
[Docker](https://www.docker.com/) is currently necessary for managing containers and must be installed and available on your system path.
|
|
110
|
+
|
|
111
|
+
## Examples
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
$ mpbuild build RPI_PICO
|
|
115
|
+
# Downloads appropriate containers and builds firmware for the Raspberry Pi Pico
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
$ mpbuild list rp2
|
|
120
|
+
🐍 MicroPython Boards
|
|
121
|
+
└── rp2 19
|
|
122
|
+
├── ADAFRUIT_FEATHER_RP2040
|
|
123
|
+
├── ADAFRUIT_ITSYBITSY_RP2040
|
|
124
|
+
├── ADAFRUIT_QTPY_RP2040
|
|
125
|
+
├── ARDUINO_NANO_RP2040_CONNECT
|
|
126
|
+
├── GARATRONIC_PYBSTICK26_RP2040
|
|
127
|
+
├── NULLBITS_BIT_C_PRO
|
|
128
|
+
├── PIMORONI_PICOLIPO FLASH_16M
|
|
129
|
+
├── PIMORONI_TINY2040 FLASH_8M
|
|
130
|
+
├── POLOLU_3PI_2040_ROBOT
|
|
131
|
+
├── POLOLU_ZUMO_2040_ROBOT
|
|
132
|
+
├── RPI_PICO
|
|
133
|
+
├── RPI_PICO2 RISCV
|
|
134
|
+
├── RPI_PICO_W
|
|
135
|
+
├── SIL_RP2040_SHIM
|
|
136
|
+
├── SPARKFUN_PROMICRO
|
|
137
|
+
├── SPARKFUN_THINGPLUS
|
|
138
|
+
├── W5100S_EVB_PICO
|
|
139
|
+
├── W5500_EVB_PICO
|
|
140
|
+
└── WEACTSTUDIO FLASH_2M, FLASH_4M, FLASH_8M
|
|
141
|
+
```
|
mpbuild-0.5/README.md
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
# mpbuild
|
|
4
|
+
|
|
5
|
+

|
|
6
|
+
|
|
7
|
+
Build MicroPython firmware with ease!
|
|
8
|
+
|
|
9
|
+
**mpbuild** builds MicroPython firmware in containers so you don't need to install any compiler toolchains or development tools. It knows which containers to use for each board so the appropriate build tools are used.
|
|
10
|
+
|
|
11
|
+
</div>
|
|
12
|
+
|
|
13
|
+
## Table of Contents
|
|
14
|
+
|
|
15
|
+
- [Usage](#usage)
|
|
16
|
+
- [Advanced Usage](#advanced-usage)
|
|
17
|
+
- [Use as a Module](#use-as-a-module)
|
|
18
|
+
- [Installation](#installation)
|
|
19
|
+
- [Prerequisites](#prerequisites)
|
|
20
|
+
- [Examples](#examples)
|
|
21
|
+
- [Related links](#related-links)
|
|
22
|
+
|
|
23
|
+
## Usage
|
|
24
|
+
|
|
25
|
+
**mpbuild** is intended to be executed in the root of a MicroPython repository. Help text (accessed with adding `--help`) is extensive and documents advanced options.
|
|
26
|
+
|
|
27
|
+
> [!NOTE]
|
|
28
|
+
> Note that there are some _special_ builds. `unix`, `webassembly` and `windows` can all be specified as `BOARD`s but their target isn't a microcontroller. See the [MicroPython documentation](https://github.com/micropython/micropython/) for details.
|
|
29
|
+
|
|
30
|
+
> [!WARNING]
|
|
31
|
+
> Currently **mpbuild** is tested on Linux (specifically Ubuntu 24.04 on WSL on Windows 11) but it's intended to work on any platform that supports Docker.
|
|
32
|
+
|
|
33
|
+
Build a board, with optional variant:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
mpbuild build BOARD [VARIANT]
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Remove build artifacts:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
mpbuild clean BOARD [VARIANT]
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
List the available boards, optionally filter by the port name.
|
|
46
|
+
|
|
47
|
+
Displays the board names (as a clickable link), variants and number of boards per port:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
mpbuild list [PORT]
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Advanced Usage
|
|
54
|
+
|
|
55
|
+
Validate the state of all images referenced in board definitions:
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
mpbuild check_images
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Use as a Module
|
|
62
|
+
|
|
63
|
+
> [!CAUTION]
|
|
64
|
+
> This is _very much_ a work-in-progress and the API is subject to change.
|
|
65
|
+
|
|
66
|
+
**mpbuild** can also be used from Python as a module. This allows it to easily be integrated into other tools.
|
|
67
|
+
|
|
68
|
+
Example:
|
|
69
|
+
|
|
70
|
+
```python
|
|
71
|
+
import mpbuild
|
|
72
|
+
|
|
73
|
+
mpbuild.build("RPI_PICO")
|
|
74
|
+
mpbuild.list()
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## Installation
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
uv tool install mpbuild
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Or use pipx, pip etc.
|
|
84
|
+
|
|
85
|
+
After installation, you may want to also install command-line tab completion for your shell (bash, zsh, fish and PowerShell are supported). Tab completion includes the various mpbuild commands as well as the board names and variants:
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
mpbuild --install-completion
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Prerequisites
|
|
92
|
+
|
|
93
|
+
A clone of MicroPython (or a fork):
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
git clone git@github.com:micropython/micropython.git
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
[Docker](https://www.docker.com/) is currently necessary for managing containers and must be installed and available on your system path.
|
|
100
|
+
|
|
101
|
+
## Examples
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
$ mpbuild build RPI_PICO
|
|
105
|
+
# Downloads appropriate containers and builds firmware for the Raspberry Pi Pico
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
$ mpbuild list rp2
|
|
110
|
+
🐍 MicroPython Boards
|
|
111
|
+
└── rp2 19
|
|
112
|
+
├── ADAFRUIT_FEATHER_RP2040
|
|
113
|
+
├── ADAFRUIT_ITSYBITSY_RP2040
|
|
114
|
+
├── ADAFRUIT_QTPY_RP2040
|
|
115
|
+
├── ARDUINO_NANO_RP2040_CONNECT
|
|
116
|
+
├── GARATRONIC_PYBSTICK26_RP2040
|
|
117
|
+
├── NULLBITS_BIT_C_PRO
|
|
118
|
+
├── PIMORONI_PICOLIPO FLASH_16M
|
|
119
|
+
├── PIMORONI_TINY2040 FLASH_8M
|
|
120
|
+
├── POLOLU_3PI_2040_ROBOT
|
|
121
|
+
├── POLOLU_ZUMO_2040_ROBOT
|
|
122
|
+
├── RPI_PICO
|
|
123
|
+
├── RPI_PICO2 RISCV
|
|
124
|
+
├── RPI_PICO_W
|
|
125
|
+
├── SIL_RP2040_SHIM
|
|
126
|
+
├── SPARKFUN_PROMICRO
|
|
127
|
+
├── SPARKFUN_THINGPLUS
|
|
128
|
+
├── W5100S_EVB_PICO
|
|
129
|
+
├── W5500_EVB_PICO
|
|
130
|
+
└── WEACTSTUDIO FLASH_2M, FLASH_4M, FLASH_8M
|
|
131
|
+
```
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "mpbuild"
|
|
3
|
+
version = "0.5"
|
|
4
|
+
description = "Build MicroPython firmware with ease!"
|
|
5
|
+
authors = [
|
|
6
|
+
{ name = "Matt Trentini", email = "matt.trentini@gmail.com" }
|
|
7
|
+
]
|
|
8
|
+
dependencies = [
|
|
9
|
+
"typer>=0.12.3",
|
|
10
|
+
"rich>=13.7.1",
|
|
11
|
+
]
|
|
12
|
+
readme = "README.md"
|
|
13
|
+
requires-python = ">= 3.9"
|
|
14
|
+
|
|
15
|
+
[project.scripts]
|
|
16
|
+
mpbuild = "mpbuild.__main__:main"
|
|
17
|
+
|
|
18
|
+
[build-system]
|
|
19
|
+
requires = ["hatchling"]
|
|
20
|
+
build-backend = "hatchling.build"
|
|
21
|
+
|
|
22
|
+
[tool.rye]
|
|
23
|
+
managed = true
|
|
24
|
+
dev-dependencies = [
|
|
25
|
+
]
|
|
26
|
+
|
|
27
|
+
[tool.hatch.metadata]
|
|
28
|
+
allow-direct-references = true
|
|
29
|
+
|
|
30
|
+
[tool.hatch.build.targets.wheel]
|
|
31
|
+
packages = ["src/mpbuild"]
|
|
32
|
+
|
|
33
|
+
[dependency-groups]
|
|
34
|
+
dev = [
|
|
35
|
+
"pre-commit>=4.0.1",
|
|
36
|
+
]
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# generated by rye
|
|
2
|
+
# use `rye lock` or `rye sync` to update this lockfile
|
|
3
|
+
#
|
|
4
|
+
# last locked with the following flags:
|
|
5
|
+
# pre: false
|
|
6
|
+
# features: []
|
|
7
|
+
# all-features: false
|
|
8
|
+
# with-sources: false
|
|
9
|
+
|
|
10
|
+
-e file:.
|
|
11
|
+
click==8.1.7
|
|
12
|
+
# via typer
|
|
13
|
+
markdown-it-py==3.0.0
|
|
14
|
+
# via rich
|
|
15
|
+
mdurl==0.1.2
|
|
16
|
+
# via markdown-it-py
|
|
17
|
+
pygments==2.18.0
|
|
18
|
+
# via rich
|
|
19
|
+
rich==13.7.1
|
|
20
|
+
# via mpbuild
|
|
21
|
+
# via typer
|
|
22
|
+
shellingham==1.5.4
|
|
23
|
+
# via typer
|
|
24
|
+
typer==0.12.3
|
|
25
|
+
# via mpbuild
|
|
26
|
+
typing-extensions==4.12.2
|
|
27
|
+
# via typer
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# generated by rye
|
|
2
|
+
# use `rye lock` or `rye sync` to update this lockfile
|
|
3
|
+
#
|
|
4
|
+
# last locked with the following flags:
|
|
5
|
+
# pre: false
|
|
6
|
+
# features: []
|
|
7
|
+
# all-features: false
|
|
8
|
+
# with-sources: false
|
|
9
|
+
|
|
10
|
+
-e file:.
|
|
11
|
+
click==8.1.7
|
|
12
|
+
# via typer
|
|
13
|
+
markdown-it-py==3.0.0
|
|
14
|
+
# via rich
|
|
15
|
+
mdurl==0.1.2
|
|
16
|
+
# via markdown-it-py
|
|
17
|
+
pygments==2.18.0
|
|
18
|
+
# via rich
|
|
19
|
+
rich==13.7.1
|
|
20
|
+
# via mpbuild
|
|
21
|
+
# via typer
|
|
22
|
+
shellingham==1.5.4
|
|
23
|
+
# via typer
|
|
24
|
+
typer==0.12.3
|
|
25
|
+
# via mpbuild
|
|
26
|
+
typing-extensions==4.12.2
|
|
27
|
+
# via typer
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
__app_name__ = "mpbuild"
|
|
2
|
+
__version__ = "0.1.0"
|
|
3
|
+
|
|
4
|
+
from enum import Enum
|
|
5
|
+
from functools import cache
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
from .find_boards import find_mpy_root
|
|
8
|
+
from .board_database import Database
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
@cache
|
|
12
|
+
def board_database(mpy_dir: Path | None = None, port: str | None = None) -> Database:
|
|
13
|
+
mpy_dir, auto_port = find_mpy_root(mpy_dir)
|
|
14
|
+
port = port or auto_port
|
|
15
|
+
# assert port
|
|
16
|
+
return Database(mpy_dir, port)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class OutputFormat(str, Enum):
|
|
20
|
+
rich = "rich"
|
|
21
|
+
text = "text"
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
"""
|
|
2
|
+
The micropython git repo contains many 'board.json' files.
|
|
3
|
+
|
|
4
|
+
This is an example:
|
|
5
|
+
ports/stm32/boards/PYBV11/board.json
|
|
6
|
+
|
|
7
|
+
{
|
|
8
|
+
"deploy": [
|
|
9
|
+
"../PYBV10/deploy.md"
|
|
10
|
+
],
|
|
11
|
+
"docs": "",
|
|
12
|
+
"features": [],
|
|
13
|
+
"images": [
|
|
14
|
+
"PYBv1_1.jpg",
|
|
15
|
+
"PYBv1_1-C.jpg",
|
|
16
|
+
"PYBv1_1-E.jpg"
|
|
17
|
+
],
|
|
18
|
+
"mcu": "stm32f4",
|
|
19
|
+
"product": "Pyboard v1.1",
|
|
20
|
+
"thumbnail": "",
|
|
21
|
+
"url": "https://store.micropython.org/product/PYBv1.1",
|
|
22
|
+
"variants": {
|
|
23
|
+
"DP": "Double-precision float",
|
|
24
|
+
"DP_THREAD": "Double precision float + Threads",
|
|
25
|
+
"NETWORK": "Wiznet 5200 Driver",
|
|
26
|
+
"THREAD": "Threading"
|
|
27
|
+
},
|
|
28
|
+
"vendor": "George Robotics"
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
This module implements `class Database` which reads all 'board.json' files and
|
|
32
|
+
provides a way to browse it's data.
|
|
33
|
+
"""
|
|
34
|
+
|
|
35
|
+
from __future__ import annotations
|
|
36
|
+
|
|
37
|
+
from pathlib import Path
|
|
38
|
+
import json
|
|
39
|
+
from dataclasses import dataclass, field
|
|
40
|
+
from glob import glob
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
@dataclass(order=True)
|
|
44
|
+
class Variant:
|
|
45
|
+
name: str
|
|
46
|
+
"""
|
|
47
|
+
Example: "DP_THREAD"
|
|
48
|
+
"""
|
|
49
|
+
text: str
|
|
50
|
+
"""
|
|
51
|
+
Example: "Double precision float + Threads"
|
|
52
|
+
"""
|
|
53
|
+
board: Board = field(repr=False)
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
@dataclass(order=True)
|
|
57
|
+
class Board:
|
|
58
|
+
name: str
|
|
59
|
+
"""
|
|
60
|
+
Example: "PYBV11"
|
|
61
|
+
"""
|
|
62
|
+
variants: list[Variant]
|
|
63
|
+
"""
|
|
64
|
+
List of variants available for this board.
|
|
65
|
+
Variants are sorted. May be an empty list if no variants are available.
|
|
66
|
+
Example key: "DP_THREAD"
|
|
67
|
+
"""
|
|
68
|
+
url: str
|
|
69
|
+
"""
|
|
70
|
+
Primary URL to link to this board.
|
|
71
|
+
"""
|
|
72
|
+
mcu: str
|
|
73
|
+
"""
|
|
74
|
+
Example: "stm32f4"
|
|
75
|
+
"""
|
|
76
|
+
product: str
|
|
77
|
+
"""
|
|
78
|
+
Example: "Pyboard v1.1"
|
|
79
|
+
"""
|
|
80
|
+
vendor: str
|
|
81
|
+
"""
|
|
82
|
+
Example: "George Robotics"
|
|
83
|
+
"""
|
|
84
|
+
images: list[str]
|
|
85
|
+
"""
|
|
86
|
+
Images of this board, stored in the micropython-media repository.
|
|
87
|
+
Example: ["PYBv1_1.jpg", "PYBv1_1-C.jpg", "PYBv1_1-E.jpg"]
|
|
88
|
+
"""
|
|
89
|
+
deploy: list[str]
|
|
90
|
+
"""
|
|
91
|
+
Files that explain how to deploy for this board:
|
|
92
|
+
Example: ["../PYBV10/deploy.md"]
|
|
93
|
+
"""
|
|
94
|
+
port: Port | None= field(default=None, compare=False)
|
|
95
|
+
|
|
96
|
+
@staticmethod
|
|
97
|
+
def factory(filename_json: Path) -> Board:
|
|
98
|
+
with filename_json.open() as f:
|
|
99
|
+
board_json = json.load(f)
|
|
100
|
+
|
|
101
|
+
board = Board(
|
|
102
|
+
name=filename_json.parent.name,
|
|
103
|
+
variants=[],
|
|
104
|
+
url=board_json["url"],
|
|
105
|
+
mcu=board_json["mcu"],
|
|
106
|
+
product=board_json["product"],
|
|
107
|
+
vendor=board_json["vendor"],
|
|
108
|
+
images=board_json["images"],
|
|
109
|
+
deploy=board_json["deploy"],
|
|
110
|
+
)
|
|
111
|
+
board.variants.extend(
|
|
112
|
+
sorted([Variant(*v, board) for v in board_json.get("variants", {}).items()])
|
|
113
|
+
)
|
|
114
|
+
return board
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
@dataclass(order=True)
|
|
118
|
+
class Port:
|
|
119
|
+
name: str
|
|
120
|
+
"""
|
|
121
|
+
Example: "stm32"
|
|
122
|
+
"""
|
|
123
|
+
boards: dict[str, Board] = field(default_factory=dict, repr=False)
|
|
124
|
+
"""
|
|
125
|
+
Example key: "PYBV11"
|
|
126
|
+
"""
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
@dataclass
|
|
130
|
+
class Database:
|
|
131
|
+
"""
|
|
132
|
+
This database contains all information retrieved from all 'board.json' files.
|
|
133
|
+
"""
|
|
134
|
+
|
|
135
|
+
mpy_root_directory: Path = field(repr=False)
|
|
136
|
+
port_filter: str = field(default="", repr=False)
|
|
137
|
+
|
|
138
|
+
ports: dict[str, Port] = field(default_factory=dict)
|
|
139
|
+
boards: dict[str, Board] = field(default_factory=dict)
|
|
140
|
+
|
|
141
|
+
def __post_init__(self) -> None:
|
|
142
|
+
mpy_dir = self.mpy_root_directory
|
|
143
|
+
# Take care to avoid using Path.glob! Performance was 15x slower.
|
|
144
|
+
for p in glob(f"{mpy_dir}/ports/**/boards/**/board.json"):
|
|
145
|
+
filename_json = Path(p)
|
|
146
|
+
port_name = filename_json.parent.parent.parent.name
|
|
147
|
+
if self.port_filter and self.port_filter != port_name:
|
|
148
|
+
continue
|
|
149
|
+
|
|
150
|
+
# Create a port
|
|
151
|
+
port = self.ports.get(port_name, None)
|
|
152
|
+
if port is None:
|
|
153
|
+
port = Port(port_name)
|
|
154
|
+
self.ports[port_name] = port
|
|
155
|
+
|
|
156
|
+
# Load board.json and attach it to the board
|
|
157
|
+
board = Board.factory(filename_json)
|
|
158
|
+
board.port = port
|
|
159
|
+
|
|
160
|
+
port.boards[board.name] = board
|
|
161
|
+
self.boards[board.name] = board
|
|
162
|
+
|
|
163
|
+
# Add 'special' ports, that don't have boards
|
|
164
|
+
# TODO(mst) Tidy up later (variant descriptions etc)
|
|
165
|
+
for special_port_name in ["unix", "webassembly", "windows"]:
|
|
166
|
+
if self.port_filter and self.port_filter != special_port_name:
|
|
167
|
+
continue
|
|
168
|
+
path = Path(mpy_dir, "ports", special_port_name)
|
|
169
|
+
variant_names = [
|
|
170
|
+
var.name for var in path.glob("variants/*") if var.is_dir()
|
|
171
|
+
]
|
|
172
|
+
board = Board(
|
|
173
|
+
special_port_name,
|
|
174
|
+
[],
|
|
175
|
+
f"https://github.com/micropython/micropython/blob/master/ports/{special_port_name}/README.md",
|
|
176
|
+
"",
|
|
177
|
+
"",
|
|
178
|
+
"",
|
|
179
|
+
[],
|
|
180
|
+
[],
|
|
181
|
+
)
|
|
182
|
+
board.variants = [Variant(v, "", board) for v in variant_names]
|
|
183
|
+
port = Port(special_port_name, {special_port_name: board})
|
|
184
|
+
board.port = port
|
|
185
|
+
|
|
186
|
+
self.ports[special_port_name] = port
|
|
187
|
+
self.boards[board.name] = board
|