micropython-stubber 1.20.6__py3-none-any.whl → 1.23.1__py3-none-any.whl
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.
- {micropython_stubber-1.20.6.dist-info → micropython_stubber-1.23.1.dist-info}/METADATA +4 -3
- micropython_stubber-1.23.1.dist-info/RECORD +159 -0
- mpflash/README.md +14 -4
- mpflash/mpflash/add_firmware.py +1 -1
- mpflash/mpflash/ask_input.py +1 -1
- {stubber → mpflash/mpflash}/basicgit.py +3 -13
- mpflash/mpflash/bootloader/__init__.py +2 -37
- mpflash/mpflash/bootloader/activate.py +60 -0
- mpflash/mpflash/bootloader/detect.py +82 -0
- mpflash/mpflash/bootloader/manual.py +10 -11
- mpflash/mpflash/bootloader/micropython.py +2 -0
- mpflash/mpflash/bootloader/touch1200.py +13 -22
- mpflash/mpflash/cli_download.py +1 -1
- mpflash/mpflash/cli_flash.py +4 -4
- mpflash/mpflash/cli_group.py +18 -5
- mpflash/mpflash/cli_main.py +3 -5
- mpflash/mpflash/common.py +1 -0
- mpflash/mpflash/config.py +6 -9
- mpflash/mpflash/connected.py +9 -5
- mpflash/mpflash/download.py +9 -5
- mpflash/mpflash/downloaded.py +4 -3
- mpflash/mpflash/{flash.py → flash/__init__.py} +20 -17
- mpflash/mpflash/{flash_esp.py → flash/esp.py} +1 -1
- mpflash/mpflash/flash/stm32.py +19 -0
- mpflash/mpflash/{flash_stm32_dfu.py → flash/stm32_dfu.py} +4 -1
- mpflash/mpflash/{flash_uf2.py → flash/uf2/__init__.py} +44 -23
- mpflash/mpflash/{flash_uf2_linux.py → flash/uf2/linux.py} +15 -8
- mpflash/mpflash/{flash_uf2_macos.py → flash/uf2/macos.py} +13 -5
- mpflash/mpflash/{flash_uf2_windows.py → flash/uf2/windows.py} +16 -7
- mpflash/mpflash/{worklist.py → flash/worklist.py} +9 -9
- mpflash/mpflash/list.py +13 -3
- mpflash/mpflash/mpboard_id/__init__.py +1 -1
- mpflash/mpflash/mpboard_id/add_boards.py +3 -7
- mpflash/mpflash/mpboard_id/board_id.py +1 -1
- mpflash/mpflash/mpremoteboard/__init__.py +5 -4
- {stubber/utils → mpflash/mpflash}/versions.py +31 -24
- mpflash/poetry.lock +16 -5
- mpflash/pyproject.toml +8 -3
- stubber/__init__.py +1 -1
- stubber/board/createstubs.py +4 -4
- stubber/board/createstubs_db.py +5 -5
- stubber/board/createstubs_db_min.py +1 -1
- stubber/board/createstubs_db_mpy.mpy +0 -0
- stubber/board/createstubs_mem.py +5 -5
- stubber/board/createstubs_mem_min.py +1 -1
- stubber/board/createstubs_mem_mpy.mpy +0 -0
- stubber/board/createstubs_min.py +1 -1
- stubber/board/createstubs_mpy.mpy +0 -0
- stubber/codemod/utils.py +2 -3
- stubber/commands/build_cmd.py +1 -1
- stubber/commands/cli.py +8 -4
- stubber/commands/clone_cmd.py +16 -4
- stubber/commands/enrich_folder_cmd.py +2 -1
- stubber/commands/get_core_cmd.py +5 -3
- stubber/commands/get_docstubs_cmd.py +6 -4
- stubber/commands/get_frozen_cmd.py +5 -3
- stubber/commands/get_mcu_cmd.py +9 -4
- stubber/commands/merge_cmd.py +3 -3
- stubber/commands/publish_cmd.py +2 -3
- stubber/commands/stub_cmd.py +2 -1
- stubber/commands/switch_cmd.py +14 -6
- stubber/commands/variants_cmd.py +3 -3
- stubber/freeze/get_frozen.py +1 -1
- stubber/minify.py +4 -3
- stubber/publish/candidates.py +4 -10
- stubber/publish/defaults.py +4 -9
- stubber/publish/missing_class_methods.py +1 -1
- stubber/publish/package.py +1 -1
- stubber/publish/pathnames.py +1 -1
- stubber/publish/publish.py +1 -1
- stubber/publish/stubpackage.py +3 -5
- stubber/rst/reader.py +5 -13
- stubber/tools/manifestfile.py +71 -27
- stubber/tools/readme.md +3 -2
- stubber/update_fallback.py +1 -1
- stubber/utils/__init__.py +2 -1
- stubber/utils/config.py +3 -5
- stubber/utils/manifest.py +2 -4
- stubber/utils/repos.py +5 -12
- micropython_stubber-1.20.6.dist-info/RECORD +0 -159
- mpflash/mpflash/flash_stm32.py +0 -24
- mpflash/mpflash/flash_stm32_cube.py +0 -111
- mpflash/mpflash/vendor/versions.py +0 -119
- {micropython_stubber-1.20.6.dist-info → micropython_stubber-1.23.1.dist-info}/LICENSE +0 -0
- {micropython_stubber-1.20.6.dist-info → micropython_stubber-1.23.1.dist-info}/WHEEL +0 -0
- {micropython_stubber-1.20.6.dist-info → micropython_stubber-1.23.1.dist-info}/entry_points.txt +0 -0
- /mpflash/{mpflash/vendor/basicgit.py → basicgit.py} +0 -0
- /mpflash/mpflash/{flash_uf2_boardid.py → flash/uf2/boardid.py} +0 -0
- /mpflash/mpflash/{uf2disk.py → flash/uf2/uf2disk.py} +0 -0
stubber/commands/get_mcu_cmd.py
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
##########################################################################################
|
6
6
|
|
7
7
|
|
8
|
-
import click
|
8
|
+
import rich_click as click
|
9
9
|
from loguru import logger as log
|
10
10
|
|
11
11
|
from stubber.bulk.mcu_stubber import stub_connected_mcus
|
@@ -21,7 +21,7 @@ from .cli import stubber_cli
|
|
21
21
|
@stubber_cli.command(name="get-mcu-stubs")
|
22
22
|
@click.option(
|
23
23
|
"--variant",
|
24
|
-
"-v",
|
24
|
+
# "-v",
|
25
25
|
type=click.Choice(["Full", "Mem", "DB"], case_sensitive=False),
|
26
26
|
default="DB",
|
27
27
|
show_default=True,
|
@@ -37,7 +37,10 @@ from .cli import stubber_cli
|
|
37
37
|
)
|
38
38
|
@click.option("--debug/--no-debug", default=False, show_default=True, help="Debug mode.")
|
39
39
|
@click.option(
|
40
|
-
"--reset/--no-reset",
|
40
|
+
"--reset/--no-reset",
|
41
|
+
default=False,
|
42
|
+
show_default=True,
|
43
|
+
help="Reset the board before running createstubs.",
|
41
44
|
)
|
42
45
|
@click.option(
|
43
46
|
"--github/--local",
|
@@ -50,7 +53,9 @@ def cli_create_mcu_stubs(variant: str, format: str, debug: bool, reset: bool, gi
|
|
50
53
|
# check if all repos have been cloned
|
51
54
|
for repo in CONFIG.repos:
|
52
55
|
if not repo.exists():
|
53
|
-
log.error(
|
56
|
+
log.error(
|
57
|
+
f"Repo {repo} not found, use 'stubber clone --add-stubs' to clone the repos."
|
58
|
+
)
|
54
59
|
exit(1)
|
55
60
|
|
56
61
|
exit(stub_connected_mcus(variant=variant, format=format, debug=debug))
|
stubber/commands/merge_cmd.py
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
"""
|
2
2
|
enrich machinestubs with docstubs
|
3
3
|
"""
|
4
|
+
|
4
5
|
from typing import List, Union
|
5
6
|
|
6
|
-
import click
|
7
|
+
import rich_click as click
|
7
8
|
from loguru import logger as log
|
8
9
|
|
9
10
|
from stubber.publish.merge_docstubs import merge_all_docstubs
|
@@ -17,8 +18,7 @@ from .cli import stubber_cli
|
|
17
18
|
@click.option("--family", default="micropython", type=str, show_default=True)
|
18
19
|
@click.option(
|
19
20
|
"--version",
|
20
|
-
"
|
21
|
-
"-V",
|
21
|
+
"-v",
|
22
22
|
"versions",
|
23
23
|
multiple=True,
|
24
24
|
default=["all"],
|
stubber/commands/publish_cmd.py
CHANGED
@@ -4,7 +4,7 @@ Commandline interface to publish stubs.
|
|
4
4
|
|
5
5
|
from typing import List, Union
|
6
6
|
|
7
|
-
import click
|
7
|
+
import rich_click as click
|
8
8
|
from loguru import logger as log
|
9
9
|
from tabulate import tabulate
|
10
10
|
|
@@ -18,8 +18,7 @@ from stubber.utils.config import CONFIG
|
|
18
18
|
@click.option("--family", default="micropython", type=str, show_default=True)
|
19
19
|
@click.option(
|
20
20
|
"--version",
|
21
|
-
"
|
22
|
-
"-V",
|
21
|
+
"-v",
|
23
22
|
"versions",
|
24
23
|
multiple=True,
|
25
24
|
default=[CONFIG.stable_version],
|
stubber/commands/stub_cmd.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
"""Create or update .pyi type hint files."""
|
2
|
+
|
2
3
|
##########################################################################################
|
3
4
|
# stub
|
4
5
|
##########################################################################################
|
@@ -7,7 +8,7 @@ from loguru import logger as log
|
|
7
8
|
from pathlib import Path
|
8
9
|
from typing import Union
|
9
10
|
|
10
|
-
import click
|
11
|
+
import rich_click as click
|
11
12
|
from stubber.utils import generate_pyi_files
|
12
13
|
from stubber.utils.post import do_post_processing
|
13
14
|
|
stubber/commands/switch_cmd.py
CHANGED
@@ -2,16 +2,15 @@
|
|
2
2
|
switch to a specific version of the micropython repos
|
3
3
|
"""
|
4
4
|
|
5
|
-
|
6
5
|
from pathlib import Path
|
7
6
|
from typing import Optional, Union
|
8
7
|
|
9
|
-
import click
|
8
|
+
import rich_click as click
|
10
9
|
|
11
|
-
import
|
10
|
+
import mpflash.basicgit as git
|
12
11
|
from stubber.utils.config import CONFIG
|
13
12
|
from stubber.utils.repos import fetch_repos, repo_paths
|
14
|
-
from
|
13
|
+
from mpflash.versions import SET_PREVIEW, V_PREVIEW
|
15
14
|
|
16
15
|
from .cli import stubber_cli
|
17
16
|
|
@@ -23,7 +22,11 @@ from .cli import stubber_cli
|
|
23
22
|
# get version list from Git tags in the repo that is provided on the command line
|
24
23
|
|
25
24
|
try:
|
26
|
-
VERSION_LIST = git.get_tags("micropython/micropython", minver="v1.9.3") + [
|
25
|
+
VERSION_LIST = git.get_tags("micropython/micropython", minver="v1.9.3") + [
|
26
|
+
V_PREVIEW,
|
27
|
+
"latest",
|
28
|
+
"stable",
|
29
|
+
]
|
27
30
|
except Exception:
|
28
31
|
# offline fallback
|
29
32
|
VERSION_LIST = ["v1.91.1", "v1.20.1", "v1.21.0", "v1.22.1", "preview", "stable"]
|
@@ -31,7 +34,12 @@ except Exception:
|
|
31
34
|
|
32
35
|
@stubber_cli.command(name="switch")
|
33
36
|
@click.argument("tag", required=False, type=click.Choice(VERSION_LIST, case_sensitive=False))
|
34
|
-
@click.option(
|
37
|
+
@click.option(
|
38
|
+
"--path",
|
39
|
+
"-p",
|
40
|
+
default=CONFIG.repo_path.as_posix(),
|
41
|
+
type=click.Path(file_okay=False, dir_okay=True),
|
42
|
+
)
|
35
43
|
def cli_switch(path: Union[str, Path], tag: Optional[str] = None):
|
36
44
|
"""
|
37
45
|
Switch to a specific version of the micropython repos.
|
stubber/commands/variants_cmd.py
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
"""Create all variant of createstubs*.py."""
|
2
|
+
|
2
3
|
from pathlib import Path
|
3
4
|
|
4
|
-
import click
|
5
|
+
import rich_click as click
|
5
6
|
from loguru import logger as log
|
6
7
|
from stubber.utils.config import CONFIG
|
7
8
|
from stubber.variants import create_variants
|
@@ -12,8 +13,7 @@ from .cli import stubber_cli
|
|
12
13
|
|
13
14
|
@click.option(
|
14
15
|
"--version",
|
15
|
-
"
|
16
|
-
"-V",
|
16
|
+
"-v",
|
17
17
|
"version",
|
18
18
|
default=CONFIG.stable_version,
|
19
19
|
show_default=True,
|
stubber/freeze/get_frozen.py
CHANGED
@@ -25,11 +25,11 @@ from typing import List, Optional
|
|
25
25
|
from loguru import logger as log
|
26
26
|
from packaging.version import Version
|
27
27
|
|
28
|
+
from mpflash.versions import SET_PREVIEW, V_PREVIEW
|
28
29
|
from stubber import utils
|
29
30
|
from stubber.freeze.freeze_folder import freeze_folders # Micropython < v1.12
|
30
31
|
from stubber.freeze.freeze_manifest_2 import freeze_one_manifest_2
|
31
32
|
from stubber.utils.config import CONFIG
|
32
|
-
from stubber.utils.versions import SET_PREVIEW, V_PREVIEW
|
33
33
|
|
34
34
|
FAMILY = "micropython"
|
35
35
|
|
stubber/minify.py
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
Processing for createstubs.py
|
3
3
|
Minimizes and cross-compiles a MicroPyton file.
|
4
4
|
"""
|
5
|
+
|
5
6
|
import itertools
|
6
7
|
import subprocess
|
7
8
|
import tempfile
|
@@ -10,14 +11,14 @@ from io import BytesIO, IOBase, StringIO, TextIOWrapper
|
|
10
11
|
from pathlib import Path
|
11
12
|
from typing import List, Tuple, Union
|
12
13
|
|
13
|
-
try:
|
14
|
+
try:
|
14
15
|
import python_minifier
|
15
16
|
except ImportError:
|
16
17
|
python_minifier = None
|
17
18
|
|
18
19
|
from loguru import logger as log
|
19
20
|
|
20
|
-
from
|
21
|
+
from mpflash.versions import SET_PREVIEW, V_PREVIEW
|
21
22
|
|
22
23
|
# Type Aliases for minify
|
23
24
|
StubSource = Union[Path, str, StringIO, TextIOWrapper]
|
@@ -243,7 +244,7 @@ def minify_script(source_script: StubSource, keep_report: bool = True, diff: boo
|
|
243
244
|
],
|
244
245
|
# remove_pass=True, # no dead code
|
245
246
|
# convert_posargs_to_args=True, # Does not save any space
|
246
|
-
|
247
|
+
)
|
247
248
|
len_3 = len(min_source)
|
248
249
|
if 1:
|
249
250
|
# write to temp file for debugging
|
stubber/publish/candidates.py
CHANGED
@@ -17,13 +17,13 @@ from typing import Any, Dict, Generator, List, Optional, Union
|
|
17
17
|
from loguru import logger as log
|
18
18
|
from packaging.version import parse
|
19
19
|
|
20
|
-
import
|
20
|
+
import mpflash.basicgit as git
|
21
|
+
from mpflash.versions import OLDEST_VERSION, SET_PREVIEW, V_PREVIEW, clean_version, micropython_versions
|
21
22
|
from stubber import utils
|
22
23
|
from stubber.publish.defaults import GENERIC, GENERIC_L, GENERIC_U
|
23
24
|
|
24
25
|
# from stubber.publish.enums import COMBO_STUBS
|
25
26
|
from stubber.utils.config import CONFIG
|
26
|
-
from stubber.utils.versions import OLDEST_VERSION, SET_PREVIEW, V_PREVIEW, clean_version, micropython_versions
|
27
27
|
|
28
28
|
|
29
29
|
def subfolder_names(path: Path):
|
@@ -215,9 +215,7 @@ def board_candidates(
|
|
215
215
|
else:
|
216
216
|
r = git.checkout_tag(repo=mpy_path, tag=version)
|
217
217
|
if not r:
|
218
|
-
log.warning(
|
219
|
-
f"Incorrect version: {version} or did you forget to run `stubber clone` to get the micropython repo?"
|
220
|
-
)
|
218
|
+
log.warning(f"Incorrect version: {version} or did you forget to run `stubber clone` to get the micropython repo?")
|
221
219
|
return []
|
222
220
|
ports = list_micropython_ports(family=family, mpy_path=mpy_path)
|
223
221
|
for port in ports:
|
@@ -254,9 +252,5 @@ def filter_list(
|
|
254
252
|
worklist = [i for i in worklist if i["port"].lower() in ports_]
|
255
253
|
if boards and not is_auto(boards):
|
256
254
|
boards_ = [i.lower() for i in boards]
|
257
|
-
worklist = [
|
258
|
-
i
|
259
|
-
for i in worklist
|
260
|
-
if i["board"].lower() in boards_ or i["board"].lower().replace("generic_", "") in boards_
|
261
|
-
]
|
255
|
+
worklist = [i for i in worklist if i["board"].lower() in boards_ or i["board"].lower().replace("generic_", "") in boards_]
|
262
256
|
return worklist
|
stubber/publish/defaults.py
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
"""Build and packaging defaults for stubber"""
|
2
|
+
|
2
3
|
from typing import Dict, List
|
3
4
|
|
5
|
+
from mpflash.versions import V_PREVIEW, clean_version
|
4
6
|
from stubber.utils.config import CONFIG
|
5
|
-
from stubber.utils.versions import V_PREVIEW, clean_version
|
6
7
|
|
7
8
|
# The default board for the ports modules documented with base name only
|
8
9
|
# as the MicroPython BOARD naming convention has changed over time there are different options to try
|
@@ -29,15 +30,9 @@ def default_board(port: str, version=V_PREVIEW) -> str: # sourcery skip: assign
|
|
29
30
|
ver_flat = clean_version(version, flat=True)
|
30
31
|
if port in DEFAULT_BOARDS:
|
31
32
|
for board in DEFAULT_BOARDS[port]:
|
32
|
-
base =
|
33
|
-
f"micropython-{ver_flat}-{port}-{board}"
|
34
|
-
if board
|
35
|
-
else f"micropython-{ver_flat}-{port}"
|
36
|
-
)
|
33
|
+
base = f"micropython-{ver_flat}-{port}-{board}" if board else f"micropython-{ver_flat}-{port}"
|
37
34
|
# check if we have a (merged)stub for this version and port
|
38
|
-
if (CONFIG.stub_path / f"{base}-merged").exists() or (
|
39
|
-
CONFIG.stub_path / base
|
40
|
-
).exists():
|
35
|
+
if (CONFIG.stub_path / f"{base}-merged").exists() or (CONFIG.stub_path / base).exists():
|
41
36
|
return board
|
42
37
|
# fallback to first listed board
|
43
38
|
return DEFAULT_BOARDS[port][0]
|
@@ -8,10 +8,10 @@ from pathlib import Path
|
|
8
8
|
import libcst as cst
|
9
9
|
from loguru import logger as log
|
10
10
|
|
11
|
+
from mpflash.versions import clean_version
|
11
12
|
from stubber.codemod.add_method import CallAdder, CallFinder
|
12
13
|
from stubber.utils.config import CONFIG
|
13
14
|
from stubber.utils.post import run_black
|
14
|
-
from stubber.utils.versions import clean_version
|
15
15
|
|
16
16
|
|
17
17
|
def add_machine_pin_call(merged_path: Path, version: str):
|
stubber/publish/package.py
CHANGED
@@ -11,11 +11,11 @@ from loguru import logger as log
|
|
11
11
|
from packaging.version import parse
|
12
12
|
from pysondb import PysonDB
|
13
13
|
|
14
|
+
from mpflash.versions import clean_version
|
14
15
|
from stubber.publish.defaults import GENERIC, GENERIC_L, default_board
|
15
16
|
from stubber.publish.enums import StubSource
|
16
17
|
from stubber.publish.stubpackage import StubPackage, StubSources
|
17
18
|
from stubber.utils.config import CONFIG
|
18
|
-
from stubber.utils.versions import clean_version
|
19
19
|
|
20
20
|
# replace std log handler with a custom one capped on INFO level
|
21
21
|
log.remove()
|
stubber/publish/pathnames.py
CHANGED
@@ -8,10 +8,10 @@ from typing import Dict, Optional
|
|
8
8
|
|
9
9
|
from loguru import logger as log
|
10
10
|
|
11
|
+
from mpflash.versions import V_PREVIEW, clean_version
|
11
12
|
from stubber.publish.defaults import default_board
|
12
13
|
from stubber.publish.package import GENERIC
|
13
14
|
from stubber.utils.config import CONFIG
|
14
|
-
from stubber.utils.versions import V_PREVIEW, clean_version
|
15
15
|
|
16
16
|
|
17
17
|
## Helper functions
|
stubber/publish/publish.py
CHANGED
@@ -8,12 +8,12 @@ from typing import Any, Dict, List, Optional, Union
|
|
8
8
|
|
9
9
|
from loguru import logger as log
|
10
10
|
|
11
|
+
from mpflash.versions import V_PREVIEW
|
11
12
|
from stubber.publish.candidates import board_candidates, filter_list
|
12
13
|
from stubber.publish.database import get_database
|
13
14
|
from stubber.publish.defaults import GENERIC_U
|
14
15
|
from stubber.publish.package import get_package
|
15
16
|
from stubber.utils.config import CONFIG
|
16
|
-
from stubber.utils.versions import V_PREVIEW
|
17
17
|
|
18
18
|
|
19
19
|
def build_multiple(
|
stubber/publish/stubpackage.py
CHANGED
@@ -9,7 +9,7 @@ from typing import Any, Dict, List, Optional, Tuple, Union
|
|
9
9
|
|
10
10
|
import tenacity
|
11
11
|
|
12
|
-
from
|
12
|
+
from mpflash.basicgit import get_git_describe
|
13
13
|
from stubber.publish.helpers import get_module_docstring
|
14
14
|
|
15
15
|
try:
|
@@ -24,12 +24,12 @@ from loguru import logger as log
|
|
24
24
|
from packaging.version import Version, parse
|
25
25
|
from pysondb import PysonDB
|
26
26
|
|
27
|
+
from mpflash.versions import SET_PREVIEW, V_PREVIEW, clean_version
|
27
28
|
from stubber.publish.bump import bump_version
|
28
29
|
from stubber.publish.defaults import GENERIC_U, default_board
|
29
30
|
from stubber.publish.enums import StubSource
|
30
31
|
from stubber.publish.pypi import Version, get_pypi_versions
|
31
32
|
from stubber.utils.config import CONFIG
|
32
|
-
from stubber.utils.versions import SET_PREVIEW, V_PREVIEW, clean_version
|
33
33
|
|
34
34
|
Status = NewType("Status", Dict[str, Union[str, None]])
|
35
35
|
StubSources = List[Tuple[StubSource, Path]]
|
@@ -906,9 +906,7 @@ class StubPackage(PoetryBuilder):
|
|
906
906
|
self.pkg_version = self.next_package_version(production)
|
907
907
|
self.status["version"] = self.pkg_version
|
908
908
|
# to get the next version
|
909
|
-
log.debug(
|
910
|
-
f"{self.package_name}: bump version for {old_ver} to {self.pkg_version } {'production' if production else 'test'}"
|
911
|
-
)
|
909
|
+
log.debug(f"{self.package_name}: bump version for {old_ver} to {self.pkg_version } {'production' if production else 'test'}")
|
912
910
|
self.write_package_json()
|
913
911
|
log.trace(f"New hash: {self.package_name} {self.pkg_version} {self.hash}")
|
914
912
|
if self.poetry_build():
|
stubber/rst/reader.py
CHANGED
@@ -69,6 +69,7 @@ from typing import List, Optional, Tuple
|
|
69
69
|
|
70
70
|
from loguru import logger as log
|
71
71
|
|
72
|
+
from mpflash.versions import V_PREVIEW
|
72
73
|
from stubber.rst import (
|
73
74
|
CHILD_PARENT_CLASS,
|
74
75
|
MODULE_GLUE,
|
@@ -82,7 +83,6 @@ from stubber.rst import (
|
|
82
83
|
)
|
83
84
|
from stubber.rst.lookup import Fix
|
84
85
|
from stubber.utils.config import CONFIG
|
85
|
-
from stubber.utils.versions import V_PREVIEW
|
86
86
|
|
87
87
|
SEPERATOR = "::"
|
88
88
|
|
@@ -369,9 +369,7 @@ class RSTParser(RSTReader):
|
|
369
369
|
PARAM_RE_FIXES = [
|
370
370
|
Fix(r"\[angle, time=0\]", "[angle], time=0", is_re=True), # fix: method:: Servo.angle([angle, time=0])
|
371
371
|
Fix(r"\[speed, time=0\]", "[speed], time=0", is_re=True), # fix: .. method:: Servo.speed([speed, time=0])
|
372
|
-
Fix(
|
373
|
-
r"\[service_id, key=None, \*, \.\.\.\]", "[service_id], [key], *, ...", is_re=True
|
374
|
-
), # fix: network - AbstractNIC.connect
|
372
|
+
Fix(r"\[service_id, key=None, \*, \.\.\.\]", "[service_id], [key], *, ...", is_re=True), # fix: network - AbstractNIC.connect
|
375
373
|
]
|
376
374
|
|
377
375
|
def __init__(self, v_tag: str) -> None:
|
@@ -497,9 +495,7 @@ class RSTParser(RSTReader):
|
|
497
495
|
version = V_PREVIEW
|
498
496
|
else:
|
499
497
|
version = self.source_tag.replace("_", ".") # TODO Use clean_version(self.source_tag)
|
500
|
-
docstr[0] =
|
501
|
-
f"{docstr[0]}.\n\nMicroPython module: https://docs.micropython.org/en/{version}/library/{module_name}.html"
|
502
|
-
)
|
498
|
+
docstr[0] = f"{docstr[0]}.\n\nMicroPython module: https://docs.micropython.org/en/{version}/library/{module_name}.html"
|
503
499
|
|
504
500
|
self.output_dict.name = module_name
|
505
501
|
self.output_dict.add_comment(f"# source version: {self.source_tag}")
|
@@ -637,9 +633,7 @@ class RSTParser(RSTReader):
|
|
637
633
|
params = self.fix_parameters(params, f"{class_name}.{name}")
|
638
634
|
|
639
635
|
# parse return type from docstring
|
640
|
-
ret_type = return_type_from_context(
|
641
|
-
docstring=docstr, signature=f"{class_name}.{name}", module=self.current_module
|
642
|
-
)
|
636
|
+
ret_type = return_type_from_context(docstring=docstr, signature=f"{class_name}.{name}", module=self.current_module)
|
643
637
|
# methods have 4 flavours
|
644
638
|
# - __init__ (self, <params>) -> None:
|
645
639
|
# - classmethod (cls, <params>) -> <ret_type>:
|
@@ -759,9 +753,7 @@ class RSTParser(RSTReader):
|
|
759
753
|
|
760
754
|
# deal with documentation wildcards
|
761
755
|
for name in names:
|
762
|
-
r_type = return_type_from_context(
|
763
|
-
docstring=docstr, signature=name, module=self.current_module, literal=True
|
764
|
-
)
|
756
|
+
r_type = return_type_from_context(docstring=docstr, signature=name, module=self.current_module, literal=True)
|
765
757
|
if r_type in ["None"]: # None does not make sense
|
766
758
|
r_type = "Incomplete" # Default to Incomplete/ Unknown / int
|
767
759
|
name = self.strip_prefixes(name)
|
stubber/tools/manifestfile.py
CHANGED
@@ -26,7 +26,6 @@
|
|
26
26
|
# THE SOFTWARE.
|
27
27
|
|
28
28
|
from __future__ import print_function
|
29
|
-
|
30
29
|
import contextlib
|
31
30
|
import os
|
32
31
|
import sys
|
@@ -62,6 +61,9 @@ FILE_TYPE_LOCAL = 1
|
|
62
61
|
# URL to file. (TODO)
|
63
62
|
FILE_TYPE_HTTP = 2
|
64
63
|
|
64
|
+
# Default list of libraries in micropython-lib to search for library packages.
|
65
|
+
BASE_LIBRARY_NAMES = ("micropython", "python-stdlib", "python-ecosys")
|
66
|
+
|
65
67
|
|
66
68
|
class ManifestFileError(Exception):
|
67
69
|
pass
|
@@ -106,7 +108,7 @@ class ManifestPackageMetadata:
|
|
106
108
|
self.stdlib = False
|
107
109
|
|
108
110
|
# Allows a python-ecosys package to be annotated with the
|
109
|
-
# corresponding name in PyPI. e.g. micropython-lib/
|
111
|
+
# corresponding name in PyPI. e.g. micropython-lib/requests is based
|
110
112
|
# on pypi/requests.
|
111
113
|
self.pypi = None
|
112
114
|
# For a micropython package, this is the name that we will publish it
|
@@ -143,7 +145,7 @@ class ManifestPackageMetadata:
|
|
143
145
|
|
144
146
|
self.description = description
|
145
147
|
self.version = version
|
146
|
-
self.license =
|
148
|
+
self.license = license
|
147
149
|
self.author = author
|
148
150
|
self.pypi = pypi
|
149
151
|
self.pypi_publish = pypi_publish
|
@@ -194,6 +196,14 @@ class ManifestFile:
|
|
194
196
|
self._visited = set()
|
195
197
|
# Stack of metadata for each level.
|
196
198
|
self._metadata = [ManifestPackageMetadata()]
|
199
|
+
# Registered external libraries.
|
200
|
+
self._libraries = {}
|
201
|
+
# List of directories to search for packages.
|
202
|
+
self._library_dirs = []
|
203
|
+
# Add default micropython-lib libraries if $(MPY_LIB_DIR) has been specified.
|
204
|
+
if self._path_vars["MPY_LIB_DIR"]:
|
205
|
+
for lib in BASE_LIBRARY_NAMES:
|
206
|
+
self.add_library(lib, os.path.join("$(MPY_LIB_DIR)", lib))
|
197
207
|
|
198
208
|
def _resolve_path(self, path):
|
199
209
|
# Convert path to an absolute path, applying variable substitutions.
|
@@ -208,6 +218,7 @@ class ManifestFile:
|
|
208
218
|
"metadata": self.metadata,
|
209
219
|
"include": self.include,
|
210
220
|
"require": self.require,
|
221
|
+
"add_library": self.add_library,
|
211
222
|
"package": self.package,
|
212
223
|
"module": self.module,
|
213
224
|
"options": IncludeOptions(**kwargs),
|
@@ -271,13 +282,15 @@ class ManifestFile:
|
|
271
282
|
kind = KIND_COMPILE_AS_MPY
|
272
283
|
|
273
284
|
self._manifest_files.append(
|
274
|
-
ManifestOutput(
|
285
|
+
ManifestOutput(
|
286
|
+
FILE_TYPE_LOCAL, full_path, target_path, timestamp, kind, self._metadata[-1], opt
|
287
|
+
)
|
275
288
|
)
|
276
289
|
|
277
290
|
def _search(self, base_path, package_path, files, exts, kind, opt=None, strict=False):
|
278
291
|
base_path = self._resolve_path(base_path)
|
279
292
|
|
280
|
-
if files:
|
293
|
+
if files is not None:
|
281
294
|
# Use explicit list of files (relative to package_path).
|
282
295
|
for file in files:
|
283
296
|
if package_path:
|
@@ -386,14 +399,23 @@ class ManifestFile:
|
|
386
399
|
if is_require:
|
387
400
|
self._metadata.pop()
|
388
401
|
|
389
|
-
def
|
390
|
-
|
391
|
-
|
402
|
+
def _require_from_path(self, library_path, name, version, extra_kwargs):
|
403
|
+
for root, dirnames, filenames in os.walk(library_path):
|
404
|
+
if os.path.basename(root) == name and "manifest.py" in filenames:
|
405
|
+
self.include(root, is_require=True, **extra_kwargs)
|
406
|
+
return True
|
407
|
+
return False
|
392
408
|
|
393
|
-
|
409
|
+
def require(self, name, version=None, pypi=None, library=None, **kwargs):
|
410
|
+
"""
|
411
|
+
Require a package by name from micropython-lib.
|
394
412
|
|
395
413
|
Optionally specify pipy="package-name" to indicate that this should
|
396
414
|
use the named package from PyPI when building for CPython.
|
415
|
+
|
416
|
+
Optionally specify library="name" to reference a package from a
|
417
|
+
library that has been previously registered with add_library(). Otherwise
|
418
|
+
the list of library paths will be used.
|
397
419
|
"""
|
398
420
|
self._metadata[-1].check_initialised(self._mode)
|
399
421
|
|
@@ -404,24 +426,41 @@ class ManifestFile:
|
|
404
426
|
self._pypi_dependencies.append(pypi)
|
405
427
|
return
|
406
428
|
|
407
|
-
if
|
408
|
-
|
409
|
-
if
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
429
|
+
if library is not None:
|
430
|
+
# Find package in external library.
|
431
|
+
if library not in self._libraries:
|
432
|
+
raise ValueError("Unknown library '{}' for require('{}').".format(library, name))
|
433
|
+
library_path = self._libraries[library]
|
434
|
+
# Search for {library_path}/**/{name}/manifest.py.
|
435
|
+
if self._require_from_path(library_path, name, version, kwargs):
|
436
|
+
return
|
437
|
+
raise ValueError(
|
438
|
+
"Package '{}' not found in external library '{}' ({}).".format(
|
439
|
+
name, library, library_path
|
440
|
+
)
|
441
|
+
)
|
442
|
+
|
443
|
+
for lib_dir in self._library_dirs:
|
444
|
+
# Search for {lib_dir}/**/{name}/manifest.py.
|
445
|
+
if self._require_from_path(lib_dir, name, version, kwargs):
|
446
|
+
return
|
447
|
+
|
448
|
+
raise ValueError("Package '{}' not found in any known library.".format(name))
|
449
|
+
|
450
|
+
def add_library(self, library, library_path, prepend=False):
|
451
|
+
"""
|
452
|
+
Register the path to an external named library.
|
453
|
+
|
454
|
+
The path will be automatically searched when using require(). By default the
|
455
|
+
added library is added to the end of the list of libraries to search. Pass
|
456
|
+
`prepend=True` to add it to the start of the list.
|
457
|
+
|
458
|
+
Additionally, the added library can be explicitly requested by using
|
459
|
+
`require("name", library="library")`.
|
460
|
+
"""
|
461
|
+
library_path = self._resolve_path(library_path)
|
462
|
+
self._libraries[library] = library_path
|
463
|
+
self._library_dirs.insert(0 if prepend else len(self._library_dirs), library_path)
|
425
464
|
|
426
465
|
def package(self, package_path, files=None, base_path=".", opt=None):
|
427
466
|
"""
|
@@ -563,6 +602,9 @@ def main():
|
|
563
602
|
default=os.path.join(os.path.dirname(__file__), "../lib/micropython-lib"),
|
564
603
|
help="path to micropython-lib repo",
|
565
604
|
)
|
605
|
+
cmd_parser.add_argument(
|
606
|
+
"--unix-ffi", action="store_true", help="prepend unix-ffi to the library path"
|
607
|
+
)
|
566
608
|
cmd_parser.add_argument("--port", default=None, help="path to port dir")
|
567
609
|
cmd_parser.add_argument("--board", default=None, help="path to board dir")
|
568
610
|
cmd_parser.add_argument(
|
@@ -592,6 +634,8 @@ def main():
|
|
592
634
|
exit(1)
|
593
635
|
|
594
636
|
m = ManifestFile(mode, path_vars)
|
637
|
+
if args.unix_ffi:
|
638
|
+
m.add_library("unix-ffi", os.path.join("$(MPY_LIB_DIR)", "unix-ffi"), prepend=True)
|
595
639
|
for manifest_file in args.files:
|
596
640
|
try:
|
597
641
|
m.execute(manifest_file)
|
stubber/tools/readme.md
CHANGED
@@ -2,5 +2,6 @@ tools vendored from micropython
|
|
2
2
|
|
3
3
|
- manifestfile.py
|
4
4
|
- Micropython manifest file parser
|
5
|
-
-
|
6
|
-
-
|
5
|
+
- https://github.com/micropython/micropython/blob/master/tools/manifestfile.py
|
6
|
+
- v1.23.0
|
7
|
+
- https://raw.githubusercontent.com/micropython/micropython/v1.23.0/tools/manifestfile.py
|
stubber/update_fallback.py
CHANGED
stubber/utils/__init__.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# type: ignore
|
2
|
+
from mpflash.versions import checkedout_version, clean_version
|
3
|
+
|
2
4
|
from .manifest import make_manifest, manifest
|
3
5
|
from .post import do_post_processing
|
4
6
|
from .stubmaker import generate_pyi_files, generate_pyi_from_file
|
5
|
-
from .versions import checkedout_version, clean_version
|
stubber/utils/config.py
CHANGED
@@ -7,8 +7,8 @@ from loguru import logger as log
|
|
7
7
|
from typedconfig.config import Config, key, section
|
8
8
|
from typedconfig.source import EnvironmentConfigSource
|
9
9
|
|
10
|
-
import
|
11
|
-
from
|
10
|
+
import mpflash.basicgit as git
|
11
|
+
from mpflash.versions import V_PREVIEW
|
12
12
|
|
13
13
|
from .typed_config_toml import TomlConfigSource
|
14
14
|
|
@@ -113,9 +113,7 @@ def readconfig(filename: str = "pyproject.toml", prefix: str = "tool.", must_exi
|
|
113
113
|
# add provider sources to the config
|
114
114
|
config.add_source(EnvironmentConfigSource())
|
115
115
|
if use_toml:
|
116
|
-
config.add_source(
|
117
|
-
TomlConfigSource(filename, prefix=prefix, must_exist=must_exist)
|
118
|
-
) # ,"tools.micropython-stubber"))
|
116
|
+
config.add_source(TomlConfigSource(filename, prefix=prefix, must_exist=must_exist)) # ,"tools.micropython-stubber"))
|
119
117
|
config.read()
|
120
118
|
return config
|
121
119
|
|