micropython-stubber 1.14.1__py3-none-any.whl → 1.15.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.15.1.dist-info/METADATA +244 -0
- {micropython_stubber-1.14.1.dist-info → micropython_stubber-1.15.1.dist-info}/RECORD +49 -46
- stubber/__init__.py +1 -1
- stubber/basicgit.py +27 -14
- stubber/board/createstubs.py +34 -36
- stubber/board/createstubs_db.py +35 -35
- stubber/board/createstubs_db_min.py +195 -193
- stubber/board/createstubs_db_mpy.mpy +0 -0
- stubber/board/createstubs_info.py +73 -42
- stubber/board/createstubs_lvgl.py +35 -35
- stubber/board/createstubs_lvgl_min.py +88 -87
- stubber/board/createstubs_lvgl_mpy.mpy +0 -0
- stubber/board/createstubs_mem.py +44 -40
- stubber/board/createstubs_mem_min.py +179 -174
- stubber/board/createstubs_mem_mpy.mpy +0 -0
- stubber/board/createstubs_min.py +75 -74
- stubber/board/createstubs_mpy.mpy +0 -0
- stubber/board/info.py +183 -0
- stubber/codemod/enrich.py +28 -16
- stubber/commands/build_cmd.py +3 -3
- stubber/commands/get_core_cmd.py +17 -5
- stubber/commands/get_docstubs_cmd.py +23 -8
- stubber/commands/get_frozen_cmd.py +62 -9
- stubber/commands/get_lobo_cmd.py +13 -3
- stubber/commands/merge_cmd.py +7 -4
- stubber/commands/publish_cmd.py +5 -4
- stubber/commands/stub_cmd.py +2 -1
- stubber/commands/variants_cmd.py +0 -1
- stubber/freeze/common.py +2 -2
- stubber/freeze/freeze_folder.py +1 -1
- stubber/freeze/get_frozen.py +1 -1
- stubber/minify.py +43 -28
- stubber/publish/bump.py +1 -1
- stubber/publish/candidates.py +61 -17
- stubber/publish/defaults.py +44 -0
- stubber/publish/merge_docstubs.py +19 -56
- stubber/publish/package.py +44 -37
- stubber/publish/pathnames.py +51 -0
- stubber/publish/publish.py +5 -4
- stubber/publish/stubpacker.py +55 -33
- stubber/rst/lookup.py +7 -16
- stubber/rst/reader.py +39 -8
- stubber/stubs_from_docs.py +5 -8
- stubber/utils/post.py +34 -40
- stubber/utils/repos.py +32 -17
- stubber/utils/stubmaker.py +22 -14
- micropython_stubber-1.14.1.dist-info/METADATA +0 -217
- {micropython_stubber-1.14.1.dist-info → micropython_stubber-1.15.1.dist-info}/LICENSE +0 -0
- {micropython_stubber-1.14.1.dist-info → micropython_stubber-1.15.1.dist-info}/WHEEL +0 -0
- {micropython_stubber-1.14.1.dist-info → micropython_stubber-1.15.1.dist-info}/entry_points.txt +0 -0
stubber/commands/get_core_cmd.py
CHANGED
@@ -28,12 +28,22 @@ from .cli import stubber_cli
|
|
28
28
|
type=click.Path(exists=True, file_okay=False, dir_okay=True),
|
29
29
|
show_default=True,
|
30
30
|
)
|
31
|
-
@click.option(
|
32
|
-
|
31
|
+
@click.option(
|
32
|
+
"--stubgen/--no-stubgen",
|
33
|
+
default=True,
|
34
|
+
help="run stubgen to create .pyi files for the (new) frozen modules",
|
35
|
+
show_default=True,
|
36
|
+
)
|
37
|
+
@click.option(
|
38
|
+
"--black/--no-black",
|
39
|
+
default=True,
|
40
|
+
help="Run black on the (new) frozen modules",
|
41
|
+
show_default=True,
|
42
|
+
)
|
33
43
|
def cli_get_core(
|
34
44
|
stub_folder: str = CONFIG.stub_path.as_posix(),
|
35
45
|
# core_type: str = "pycopy", # pycopy or Micropython CPython stubs
|
36
|
-
|
46
|
+
stubgen: bool = True,
|
37
47
|
black: bool = True,
|
38
48
|
):
|
39
49
|
"""
|
@@ -48,9 +58,11 @@ def cli_get_core(
|
|
48
58
|
req_filename = f"requirements-core-{core_type}.txt"
|
49
59
|
stub_path = Path(stub_folder) / f"cpython_core-{core_type}"
|
50
60
|
|
51
|
-
get_cpython.get_core(
|
61
|
+
get_cpython.get_core(
|
62
|
+
stub_path=stub_path.as_posix(), requirements=req_filename, family=core_type
|
63
|
+
)
|
52
64
|
stub_paths.append(stub_path)
|
53
65
|
|
54
66
|
log.info("::group:: start post processing of retrieved stubs")
|
55
|
-
utils.do_post_processing(stub_paths,
|
67
|
+
utils.do_post_processing(stub_paths, stubgen=stubgen, black=black, autoflake=True)
|
56
68
|
log.info("::group:: Done")
|
@@ -6,11 +6,13 @@ get-docstubs
|
|
6
6
|
from pathlib import Path
|
7
7
|
|
8
8
|
import click
|
9
|
+
from loguru import logger as log
|
10
|
+
|
9
11
|
import stubber.basicgit as git
|
10
12
|
import stubber.utils as utils
|
11
|
-
from loguru import logger as log
|
12
13
|
from stubber.stubs_from_docs import generate_from_rst
|
13
14
|
from stubber.utils.config import CONFIG
|
15
|
+
from stubber.utils.repos import fetch_repos
|
14
16
|
|
15
17
|
from .cli import stubber_cli
|
16
18
|
|
@@ -20,7 +22,13 @@ from .cli import stubber_cli
|
|
20
22
|
|
21
23
|
|
22
24
|
@stubber_cli.command(name="get-docstubs")
|
23
|
-
@click.option(
|
25
|
+
@click.option(
|
26
|
+
"--path",
|
27
|
+
"-p",
|
28
|
+
default=CONFIG.repo_path.as_posix(),
|
29
|
+
type=click.Path(file_okay=False, dir_okay=True),
|
30
|
+
show_default=True,
|
31
|
+
)
|
24
32
|
@click.option(
|
25
33
|
"--stub-path",
|
26
34
|
"--stub-folder",
|
@@ -30,7 +38,10 @@ from .cli import stubber_cli
|
|
30
38
|
help="Destination of the files to be generated.",
|
31
39
|
show_default=True,
|
32
40
|
)
|
33
|
-
@click.option("--family", "-f", "basename", default="micropython", help="Micropython family.", show_default=True)
|
41
|
+
# @click.option("--family", "-f", "basename", default="micropython", help="Micropython family.", show_default=True)
|
42
|
+
@click.option(
|
43
|
+
"--version", "--tag", default="", type=str, help="Version number to use. [default: Git tag]"
|
44
|
+
)
|
34
45
|
@click.option("--black/--no-black", "-b/-nb", default=True, help="Run black", show_default=True)
|
35
46
|
@click.pass_context
|
36
47
|
def cli_docstubs(
|
@@ -39,6 +50,7 @@ def cli_docstubs(
|
|
39
50
|
target: str = CONFIG.stub_path.as_posix(),
|
40
51
|
black: bool = True,
|
41
52
|
basename: str = "micropython",
|
53
|
+
version: str = "",
|
42
54
|
):
|
43
55
|
"""
|
44
56
|
Build stubs from documentation.
|
@@ -54,6 +66,13 @@ def cli_docstubs(
|
|
54
66
|
rst_path = Path(path) / "docs" / "library"
|
55
67
|
else:
|
56
68
|
rst_path = Path(path) # or specify full path
|
69
|
+
|
70
|
+
if version:
|
71
|
+
version = utils.clean_version(version, drop_v=False)
|
72
|
+
result = fetch_repos(version, CONFIG.mpy_path, CONFIG.mpy_lib_path)
|
73
|
+
if not result:
|
74
|
+
return -1
|
75
|
+
|
57
76
|
v_tag = git.get_local_tag(rst_path.as_posix())
|
58
77
|
if not v_tag:
|
59
78
|
# if we can't find a tag , bail
|
@@ -64,9 +83,5 @@ def cli_docstubs(
|
|
64
83
|
dst_path = Path(target) / f"{basename}-{v_tag}-docstubs"
|
65
84
|
|
66
85
|
log.info(f"Get docstubs for MicroPython {utils.clean_version(v_tag, drop_v=False)}")
|
67
|
-
generate_from_rst(rst_path, dst_path, v_tag, release=release, suffix=".pyi")
|
68
|
-
|
69
|
-
# no need to generate .pyi in post processing
|
70
|
-
log.info("::group:: start post processing of retrieved stubs")
|
71
|
-
utils.do_post_processing([dst_path], False, black)
|
86
|
+
generate_from_rst(rst_path, dst_path, v_tag, release=release, suffix=".pyi",black=black)
|
72
87
|
log.info("::group:: Done")
|
@@ -6,10 +6,12 @@ from pathlib import Path
|
|
6
6
|
from typing import List
|
7
7
|
|
8
8
|
import click
|
9
|
+
from loguru import logger as log
|
10
|
+
|
9
11
|
import stubber.basicgit as git
|
10
|
-
from stubber.freeze.get_frozen import freeze_any
|
11
12
|
import stubber.utils as utils
|
12
|
-
from
|
13
|
+
from stubber.codemod.enrich import enrich_folder
|
14
|
+
from stubber.freeze.get_frozen import freeze_any
|
13
15
|
from stubber.utils.config import CONFIG
|
14
16
|
from stubber.utils.repos import fetch_repos
|
15
17
|
|
@@ -26,15 +28,34 @@ from .cli import stubber_cli
|
|
26
28
|
type=click.Path(exists=True, file_okay=False, dir_okay=True),
|
27
29
|
show_default=True,
|
28
30
|
)
|
29
|
-
@click.option(
|
30
|
-
|
31
|
-
|
31
|
+
@click.option(
|
32
|
+
"--version",
|
33
|
+
"--Version",
|
34
|
+
"-V",
|
35
|
+
"version",
|
36
|
+
default="",
|
37
|
+
# default=[CONFIG.stable_version],
|
38
|
+
show_default=True,
|
39
|
+
)
|
40
|
+
@click.option(
|
41
|
+
"--stubgen/--no-stubgen",
|
42
|
+
default=True,
|
43
|
+
help="Run stubgen to create .pyi files for the (new) frozen modules",
|
44
|
+
show_default=True,
|
45
|
+
)
|
46
|
+
@click.option(
|
47
|
+
"--black/--no-black",
|
48
|
+
default=True,
|
49
|
+
help="Run black on the (new) frozen modules",
|
50
|
+
show_default=True,
|
51
|
+
)
|
32
52
|
def cli_get_frozen(
|
33
53
|
stub_folder: str = CONFIG.stub_path.as_posix(),
|
34
54
|
# path: str = config.repo_path.as_posix(),
|
35
55
|
version: str = "",
|
36
|
-
|
56
|
+
stubgen: bool = True,
|
37
57
|
black: bool = True,
|
58
|
+
autoflake: bool = True,
|
38
59
|
):
|
39
60
|
"""
|
40
61
|
Get the frozen stubs for MicroPython.
|
@@ -45,20 +66,52 @@ def cli_get_frozen(
|
|
45
66
|
stub_paths: List[Path] = []
|
46
67
|
|
47
68
|
if version:
|
69
|
+
version = utils.clean_version(version, drop_v=False)
|
48
70
|
result = fetch_repos(version, CONFIG.mpy_path, CONFIG.mpy_lib_path)
|
49
71
|
if not result:
|
72
|
+
log.error(
|
73
|
+
"Failed to fetch repos for version: {} for micropython folder: {} and micropython-lib folder: {}".format(
|
74
|
+
version, CONFIG.mpy_path.as_posix(), CONFIG.mpy_lib_path.as_posix()
|
75
|
+
)
|
76
|
+
)
|
50
77
|
return -1
|
51
78
|
else:
|
52
79
|
version = utils.clean_version(git.get_local_tag(CONFIG.mpy_path.as_posix()) or "0.0")
|
53
80
|
if not version:
|
54
|
-
log.warning(
|
81
|
+
log.warning(
|
82
|
+
"Unable to find the micropython repo in folder : {}".format(CONFIG.mpy_path.as_posix())
|
83
|
+
)
|
55
84
|
|
56
85
|
log.info("MicroPython version : {}".format(version))
|
57
86
|
# folder/{family}-{version}-frozen
|
58
87
|
family = "micropython"
|
59
88
|
stub_path = Path(stub_folder) / f"{family}-{utils.clean_version(version, flat=True)}-frozen"
|
60
89
|
stub_paths.append(stub_path)
|
61
|
-
freeze_any(
|
90
|
+
freeze_any(
|
91
|
+
stub_path, version=version, mpy_path=CONFIG.mpy_path, mpy_lib_path=CONFIG.mpy_lib_path
|
92
|
+
)
|
93
|
+
# Also enrich the frozen modules from the doc stubs if available
|
94
|
+
|
95
|
+
# first create .pyi files so they can be enriched
|
96
|
+
utils.do_post_processing(stub_paths, stubgen=stubgen, black=False, autoflake=False)
|
97
|
+
family = "micropython"
|
98
|
+
docstubs_path = (
|
99
|
+
Path(CONFIG.stub_path)
|
100
|
+
/ f"{family}-{utils.clean_version(version, drop_v=False, flat=True)}-docstubs"
|
101
|
+
)
|
102
|
+
if docstubs_path.exists():
|
103
|
+
log.info(f"Enriching {str(stub_path)} with {docstubs_path}")
|
104
|
+
if merged := enrich_folder(
|
105
|
+
stub_path,
|
106
|
+
docstubs_path,
|
107
|
+
show_diff=False,
|
108
|
+
write_back=True,
|
109
|
+
require_docstub=False,
|
110
|
+
):
|
111
|
+
log.info(f"Enriched {merged} frozen modules from docstubs")
|
112
|
+
else:
|
113
|
+
log.info(f"No docstubs found at {docstubs_path}")
|
114
|
+
|
62
115
|
log.info("::group:: start post processing of retrieved stubs")
|
63
|
-
utils.do_post_processing(stub_paths,
|
116
|
+
utils.do_post_processing(stub_paths, stubgen=False, black=black, autoflake=autoflake)
|
64
117
|
log.info("::group:: Done")
|
stubber/commands/get_lobo_cmd.py
CHANGED
@@ -21,8 +21,18 @@ from stubber.utils.config import CONFIG
|
|
21
21
|
type=click.Path(exists=True, file_okay=False, dir_okay=True),
|
22
22
|
show_default=True,
|
23
23
|
)
|
24
|
-
@click.option(
|
25
|
-
|
24
|
+
@click.option(
|
25
|
+
"--pyi/--no-pyi",
|
26
|
+
default=True,
|
27
|
+
help="Create .pyi files for the (new) frozen modules",
|
28
|
+
show_default=True,
|
29
|
+
)
|
30
|
+
@click.option(
|
31
|
+
"--black/--no-black",
|
32
|
+
default=True,
|
33
|
+
help="Run black on the (new) frozen modules",
|
34
|
+
show_default=True,
|
35
|
+
)
|
26
36
|
def cli_get_lobo(
|
27
37
|
stub_folder: str = CONFIG.stub_path.as_posix(),
|
28
38
|
pyi: bool = True,
|
@@ -44,5 +54,5 @@ def cli_get_lobo(
|
|
44
54
|
stub_paths = [stub_path]
|
45
55
|
|
46
56
|
log.info("::group:: start post processing of retrieved stubs")
|
47
|
-
utils.do_post_processing(stub_paths, pyi, black)
|
57
|
+
utils.do_post_processing(stub_paths, stubgen=pyi, black=black, autoflake=True)
|
48
58
|
log.info("::group:: Done")
|
stubber/commands/merge_cmd.py
CHANGED
@@ -5,6 +5,7 @@ from typing import List, Union
|
|
5
5
|
|
6
6
|
import click
|
7
7
|
from loguru import logger as log
|
8
|
+
|
8
9
|
from stubber.publish.merge_docstubs import merge_all_docstubs
|
9
10
|
from stubber.publish.package import GENERIC_L
|
10
11
|
from stubber.utils.config import CONFIG
|
@@ -20,7 +21,7 @@ from .cli import stubber_cli
|
|
20
21
|
"-V",
|
21
22
|
"versions",
|
22
23
|
multiple=True,
|
23
|
-
default=["
|
24
|
+
default=["all"],
|
24
25
|
# type=click.Choice(ALL_VERSIONS),
|
25
26
|
show_default=True,
|
26
27
|
help="'latest', 'auto', or one or more versions",
|
@@ -30,7 +31,7 @@ from .cli import stubber_cli
|
|
30
31
|
"-p",
|
31
32
|
"ports",
|
32
33
|
multiple=True,
|
33
|
-
default=["
|
34
|
+
default=["all"],
|
34
35
|
show_default=True,
|
35
36
|
help="multiple: ",
|
36
37
|
)
|
@@ -39,7 +40,7 @@ from .cli import stubber_cli
|
|
39
40
|
"-b",
|
40
41
|
"boards",
|
41
42
|
multiple=True,
|
42
|
-
default=[GENERIC_L], # or "
|
43
|
+
default=[GENERIC_L], # or "all" ?
|
43
44
|
show_default=True,
|
44
45
|
help="multiple: ",
|
45
46
|
)
|
@@ -60,4 +61,6 @@ def cli_merge_docstubs(
|
|
60
61
|
versions = list(versions)
|
61
62
|
# single version should be a string
|
62
63
|
log.info(f"Merge docstubs for {family} {versions}")
|
63
|
-
_ = merge_all_docstubs(
|
64
|
+
_ = merge_all_docstubs(
|
65
|
+
versions=versions, family=family, boards=boards, ports=ports, mpy_path=CONFIG.mpy_path
|
66
|
+
)
|
stubber/commands/publish_cmd.py
CHANGED
@@ -6,10 +6,11 @@ from typing import List, Union
|
|
6
6
|
|
7
7
|
import click
|
8
8
|
from loguru import logger as log
|
9
|
+
from tabulate import tabulate
|
10
|
+
|
9
11
|
from stubber.commands.cli import stubber_cli
|
10
|
-
from stubber.publish.
|
12
|
+
from stubber.publish.defaults import GENERIC_U
|
11
13
|
from stubber.publish.publish import publish_multiple
|
12
|
-
from tabulate import tabulate
|
13
14
|
from stubber.utils.config import CONFIG
|
14
15
|
|
15
16
|
|
@@ -30,7 +31,7 @@ from stubber.utils.config import CONFIG
|
|
30
31
|
"-p",
|
31
32
|
"ports",
|
32
33
|
multiple=True,
|
33
|
-
default=["
|
34
|
+
default=["all"],
|
34
35
|
show_default=True,
|
35
36
|
help="multiple: ",
|
36
37
|
)
|
@@ -39,7 +40,7 @@ from stubber.utils.config import CONFIG
|
|
39
40
|
"-b",
|
40
41
|
"boards",
|
41
42
|
multiple=True,
|
42
|
-
default=[GENERIC_U], # or "
|
43
|
+
default=[GENERIC_U], # or "all" ?
|
43
44
|
show_default=True,
|
44
45
|
help="multiple: ",
|
45
46
|
)
|
stubber/commands/stub_cmd.py
CHANGED
@@ -25,5 +25,6 @@ def cli_stub(source: Union[str, Path]):
|
|
25
25
|
|
26
26
|
log.info("Generate type hint files (pyi) in folder: {}".format(source))
|
27
27
|
OK = generate_pyi_files(Path(source))
|
28
|
-
|
28
|
+
# do not generate pyi files twice
|
29
|
+
do_post_processing([Path(source)], stubgen=False, black=True, autoflake=False)
|
29
30
|
return 0 if OK else 1
|
stubber/commands/variants_cmd.py
CHANGED
stubber/freeze/common.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
"""common functions for
|
1
|
+
"""common functions for frozen stub generation"""
|
2
2
|
|
3
3
|
import re
|
4
4
|
import shutil
|
@@ -7,7 +7,7 @@ from typing import Tuple
|
|
7
7
|
|
8
8
|
from loguru import logger as log
|
9
9
|
|
10
|
-
from stubber.publish.
|
10
|
+
from stubber.publish.defaults import GENERIC_U
|
11
11
|
|
12
12
|
|
13
13
|
def get_portboard(manifest_path: Path):
|
stubber/freeze/freeze_folder.py
CHANGED
@@ -25,7 +25,7 @@ def freeze_folders(stub_folder: str, mpy_folder: str, lib_folder: str, version:
|
|
25
25
|
- 'ports/<port>/modules/*.py'
|
26
26
|
- 'ports/<port>/boards/<board>/modules/*.py'
|
27
27
|
"""
|
28
|
-
match_lib_with_mpy(version_tag=version, lib_path=Path(lib_folder))
|
28
|
+
match_lib_with_mpy(version_tag=version, mpy_path=Path(mpy_folder),lib_path=Path(lib_folder))
|
29
29
|
|
30
30
|
targets = []
|
31
31
|
scripts = glob.glob(mpy_folder + "/ports/**/modules/*.py", recursive=True)
|
stubber/freeze/get_frozen.py
CHANGED
@@ -54,7 +54,7 @@ def add_comment_to_path(path: Path, comment: str) -> None:
|
|
54
54
|
Add a comment to the top of each file in the path
|
55
55
|
using a codemod
|
56
56
|
"""
|
57
|
-
#
|
57
|
+
#TODO: #305 add comment line to each file with the micropython version it was generated from
|
58
58
|
# frozen_stub_path
|
59
59
|
# python -m libcst.tool codemod --include-stubs --no-format add_comment.AddComment .\repos\micropython-stubs\stubs\micropython-v1_19_1-frozen\ --comment "# Micropython 1.19.1 frozen stubs"
|
60
60
|
pass
|
stubber/minify.py
CHANGED
@@ -80,17 +80,17 @@ def edit_lines(content: str, edits: LineEdits, diff: bool = False):
|
|
80
80
|
"""Handles edits that require multiline comments
|
81
81
|
|
82
82
|
Example:
|
83
|
-
self.
|
83
|
+
self.log.debug("info: {} {}".format(
|
84
84
|
1,
|
85
85
|
2
|
86
86
|
))
|
87
|
-
Here, only commenting out the first self.
|
87
|
+
Here, only commenting out the first self.log line will raise
|
88
88
|
an error. So this function returns all lines that need to
|
89
89
|
be commented out instead.
|
90
90
|
|
91
91
|
It also checks for situations such as this:
|
92
92
|
if condition:
|
93
|
-
self.
|
93
|
+
self.log.debug('message')
|
94
94
|
|
95
95
|
Here, since the only functionality of the conditional is the call log,
|
96
96
|
both lines would be returned to comment out.
|
@@ -129,9 +129,9 @@ def edit_lines(content: str, edits: LineEdits, diff: bool = False):
|
|
129
129
|
try:
|
130
130
|
something()
|
131
131
|
except:
|
132
|
-
self.
|
132
|
+
self.log.debug('some message')
|
133
133
|
|
134
|
-
Simply removing the self.
|
134
|
+
Simply removing the self.log call would create a syntax error,
|
135
135
|
which is what this function checks for.
|
136
136
|
|
137
137
|
"""
|
@@ -214,33 +214,33 @@ def minify_script(source_script: StubSource, keep_report: bool = True, diff: boo
|
|
214
214
|
("comment", "import logging"),
|
215
215
|
# report keepers may be inserted here
|
216
216
|
# do report errors
|
217
|
-
("rprint", "self.
|
218
|
-
("rprint", "
|
217
|
+
("rprint", "self.log.error"),
|
218
|
+
("rprint", "log.error"),
|
219
219
|
]
|
220
220
|
if keep_report:
|
221
221
|
# insert report keepers after the comment modifiers
|
222
222
|
edits += [
|
223
223
|
# keepers
|
224
|
-
("rprint", 'self.
|
225
|
-
("rprint", 'self.
|
226
|
-
("rprint", 'self.
|
227
|
-
("rprint", 'self.
|
228
|
-
("rprint", 'self.
|
229
|
-
("rprint", 'self.
|
230
|
-
("rprint", 'self.
|
231
|
-
("rprint", 'self.
|
224
|
+
("rprint", 'self.log.info("Stub module: '),
|
225
|
+
("rprint", 'self.log.warning("{}Skip module:'),
|
226
|
+
("rprint", 'self.log.info("Clean/remove files in folder:'),
|
227
|
+
("rprint", 'self.log.info("Created stubs for'),
|
228
|
+
("rprint", 'self.log.info("Family: '),
|
229
|
+
("rprint", 'self.log.info("Version: '),
|
230
|
+
("rprint", 'self.log.info("Port: '),
|
231
|
+
("rprint", 'self.log.info("Board: '),
|
232
232
|
# all others
|
233
|
-
("comment",
|
233
|
+
("comment", "self.log."),
|
234
234
|
("comment", "_log ="),
|
235
235
|
]
|
236
236
|
else:
|
237
237
|
edits += [
|
238
238
|
# remove first full
|
239
|
-
("comment", "self.
|
240
|
-
("comment", "self.
|
241
|
-
("comment", "self.
|
242
|
-
("comment", "self.
|
243
|
-
("comment", "self.
|
239
|
+
("comment", "self.log ="),
|
240
|
+
("comment", "self.log("),
|
241
|
+
("comment", "self.log.debug"),
|
242
|
+
("comment", "self.log.info"),
|
243
|
+
("comment", "self.log.warning"),
|
244
244
|
# then short versions
|
245
245
|
("comment", "_log ="),
|
246
246
|
("comment", "_log.debug"),
|
@@ -307,7 +307,7 @@ def minify(
|
|
307
307
|
target = target / "minified.py" # or raise error?
|
308
308
|
target_buf = stack.enter_context(target.open("w+"))
|
309
309
|
elif isinstance(target, IOBase): # type: ignore
|
310
|
-
target_buf = target
|
310
|
+
target_buf = target
|
311
311
|
try:
|
312
312
|
minified = minify_script(source_script=source_buf, keep_report=keep_report, diff=diff)
|
313
313
|
target_buf.write(minified)
|
@@ -342,15 +342,15 @@ def cross_compile(
|
|
342
342
|
# target must be a Path object
|
343
343
|
_target = get_temp_file(suffix=".mpy")
|
344
344
|
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
345
|
+
result = pipx_mpy_cross(version, source_file, _target)
|
346
|
+
if result.stderr and "No matching distribution found for mpy-cross==" in result.stderr:
|
347
|
+
log.warning(f"mpy-cross=={version} not found, using latest")
|
348
|
+
result = pipx_mpy_cross("latest", source_file, _target)
|
349
|
+
|
350
350
|
if result.returncode == 0:
|
351
351
|
log.debug(f"mpy-cross compiled to : {_target.name}")
|
352
352
|
else:
|
353
|
-
log.error("mpy-cross failed to compile:")
|
353
|
+
log.error(f"mpy-cross failed to compile:{result.returncode} \n{result.stderr}")
|
354
354
|
|
355
355
|
if isinstance(target, BytesIO):
|
356
356
|
# copy the byte contents of the temp file to the target file-like object
|
@@ -361,6 +361,21 @@ def cross_compile(
|
|
361
361
|
return result.returncode
|
362
362
|
|
363
363
|
|
364
|
+
def pipx_mpy_cross(version, source_file, _target):
|
365
|
+
"""Run mpy-cross using pipx"""
|
366
|
+
if version == "latest":
|
367
|
+
version = ""
|
368
|
+
if version:
|
369
|
+
version = "==" + version
|
370
|
+
|
371
|
+
cmd = ["pipx", "run", f"mpy-cross{version}"] if version else ["pipx", "run", "mpy-cross"]
|
372
|
+
# Add params
|
373
|
+
cmd += ["-O2", str(source_file), "-o", str(_target), "-s", "createstubs.py"]
|
374
|
+
log.trace(" ".join(cmd))
|
375
|
+
result = subprocess.run(cmd, capture_output=True, text=True)
|
376
|
+
return result
|
377
|
+
|
378
|
+
|
364
379
|
def write_to_temp_file(source: str):
|
365
380
|
"""Writes a string to a temp file and returns the Path object"""
|
366
381
|
_, temp_file = tempfile.mkstemp(suffix=".py", prefix="mpy_cross_")
|
stubber/publish/bump.py
CHANGED
@@ -66,7 +66,7 @@ def bump_version(
|
|
66
66
|
parts.append(f".a{rc}")
|
67
67
|
# ----------------------------------------------------------------------
|
68
68
|
# post
|
69
|
-
|
69
|
+
elif post_bump :
|
70
70
|
parts.append(".post1" if current.post is None else f".post{current.post + 1}")
|
71
71
|
# ----------------------------------------------------------------------
|
72
72
|
# Development release
|