micropython-stubber 1.16.3__py3-none-any.whl → 1.17.0__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.16.3.dist-info → micropython_stubber-1.17.0.dist-info}/METADATA +1 -1
- {micropython_stubber-1.16.3.dist-info → micropython_stubber-1.17.0.dist-info}/RECORD +48 -49
- stubber/__init__.py +1 -1
- stubber/basicgit.py +11 -13
- stubber/board/createstubs.py +138 -97
- stubber/board/createstubs_db.py +211 -239
- stubber/board/createstubs_db_min.py +322 -844
- stubber/board/createstubs_db_mpy.mpy +0 -0
- stubber/board/createstubs_lvgl.py +91 -137
- stubber/board/createstubs_lvgl_min.py +87 -129
- stubber/board/createstubs_lvgl_mpy.mpy +0 -0
- stubber/board/createstubs_mem.py +164 -199
- stubber/board/createstubs_mem_min.py +297 -791
- stubber/board/createstubs_mem_mpy.mpy +0 -0
- stubber/board/createstubs_min.py +286 -1009
- stubber/board/createstubs_mpy.mpy +0 -0
- stubber/board/modulelist.txt +1 -2
- stubber/codemod/_partials/__init__.py +1 -1
- stubber/codemod/_partials/db_main.py +90 -72
- stubber/codemod/_partials/modules_reader.py +29 -17
- stubber/codemod/board.py +2 -4
- stubber/codemod/enrich.py +1 -1
- stubber/commands/build_cmd.py +6 -4
- stubber/commands/get_docstubs_cmd.py +6 -11
- stubber/commands/get_frozen_cmd.py +6 -11
- stubber/commands/switch_cmd.py +6 -4
- stubber/freeze/freeze_manifest_2.py +2 -1
- stubber/freeze/get_frozen.py +28 -13
- stubber/minify.py +51 -38
- stubber/publish/candidates.py +15 -23
- stubber/publish/defaults.py +2 -2
- stubber/publish/merge_docstubs.py +5 -7
- stubber/publish/missing_class_methods.py +2 -2
- stubber/publish/pathnames.py +2 -2
- stubber/publish/publish.py +2 -1
- stubber/publish/stubpackage.py +20 -41
- stubber/rst/lookup.py +9 -7
- stubber/rst/reader.py +2 -1
- stubber/stubber.py +5 -6
- stubber/update_fallback.py +3 -1
- stubber/utils/__init__.py +1 -1
- stubber/utils/config.py +7 -9
- stubber/utils/repos.py +6 -5
- stubber/utils/versions.py +48 -7
- stubber/variants.py +3 -3
- stubber/board/logging.py +0 -99
- {micropython_stubber-1.16.3.dist-info → micropython_stubber-1.17.0.dist-info}/LICENSE +0 -0
- {micropython_stubber-1.16.3.dist-info → micropython_stubber-1.17.0.dist-info}/WHEEL +0 -0
- {micropython_stubber-1.16.3.dist-info → micropython_stubber-1.17.0.dist-info}/entry_points.txt +0 -0
stubber/utils/config.py
CHANGED
@@ -2,12 +2,14 @@
|
|
2
2
|
|
3
3
|
from pathlib import Path
|
4
4
|
|
5
|
+
from loguru import logger as log
|
5
6
|
from typedconfig.config import Config, key, section
|
6
7
|
from typedconfig.source import EnvironmentConfigSource
|
7
|
-
from .typed_config_toml import TomlConfigSource
|
8
8
|
|
9
|
-
from loguru import logger as log
|
10
9
|
import stubber.basicgit as git
|
10
|
+
from stubber.utils.versions import V_PREVIEW
|
11
|
+
|
12
|
+
from .typed_config_toml import TomlConfigSource
|
11
13
|
|
12
14
|
|
13
15
|
@section("micropython-stubber")
|
@@ -16,9 +18,7 @@ class StubberConfig(Config):
|
|
16
18
|
stub_path = key(key_name="stub-path", cast=Path, required=False, default=Path("./stubs"))
|
17
19
|
"a Path to the stubs directory"
|
18
20
|
# relative to stubs folder
|
19
|
-
fallback_path = key(
|
20
|
-
key_name="fallback-path", cast=Path, required=False, default=Path("typings/fallback")
|
21
|
-
)
|
21
|
+
fallback_path = key(key_name="fallback-path", cast=Path, required=False, default=Path("typings/fallback"))
|
22
22
|
"a Path to the fallback stubs directory"
|
23
23
|
|
24
24
|
# ------------------------------------------------------------------------------------------
|
@@ -29,9 +29,7 @@ class StubberConfig(Config):
|
|
29
29
|
mpy_path = key(key_name="mpy-path", cast=Path, required=False, default=Path("micropython"))
|
30
30
|
"a Path to the micropython folder in the repos directory"
|
31
31
|
|
32
|
-
mpy_lib_path = key(
|
33
|
-
key_name="mpy-lib-path", cast=Path, required=False, default=Path("micropython-lib")
|
34
|
-
)
|
32
|
+
mpy_lib_path = key(key_name="mpy-lib-path", cast=Path, required=False, default=Path("micropython-lib"))
|
35
33
|
"a Path to the micropython-lib folder in the repos directory"
|
36
34
|
|
37
35
|
# mpy_stubs_repo_path = key(key_name="mpy-stubs-repo-path", cast=Path, required=False, default=Path("./micropython-stubs"))
|
@@ -96,7 +94,7 @@ class StubberConfig(Config):
|
|
96
94
|
all_versions = ["1.19", "1.19.1", "1.20.0", "1.21.0"]
|
97
95
|
config_updates.update(all_versions=all_versions)
|
98
96
|
config_updates.update(
|
99
|
-
stable_version=[v for v in all_versions if not v.endswith(
|
97
|
+
stable_version=[v for v in all_versions if not v.endswith(V_PREVIEW)][-1]
|
100
98
|
) # second last version - last version is the preview version
|
101
99
|
return config_updates
|
102
100
|
|
stubber/utils/repos.py
CHANGED
@@ -13,6 +13,7 @@ from packaging.version import Version
|
|
13
13
|
|
14
14
|
import stubber.basicgit as git
|
15
15
|
from stubber.utils.config import CONFIG
|
16
|
+
from stubber.utils.versions import SET_PREVIEW, V_PREVIEW
|
16
17
|
|
17
18
|
# # log = logging.getLogger(__name__)
|
18
19
|
|
@@ -34,8 +35,8 @@ def switch(tag: str, *, mpy_path: Path, mpy_lib_path: Path):
|
|
34
35
|
git.fetch(mpy_lib_path)
|
35
36
|
|
36
37
|
if not tag or tag in {"master", ""}:
|
37
|
-
tag =
|
38
|
-
if tag
|
38
|
+
tag = V_PREVIEW
|
39
|
+
if tag in SET_PREVIEW:
|
39
40
|
git.switch_branch(repo=mpy_path, branch="master")
|
40
41
|
else:
|
41
42
|
git.checkout_tag(repo=mpy_path, tag=tag)
|
@@ -76,7 +77,7 @@ def match_lib_with_mpy(version_tag: str, mpy_path: Path, lib_path: Path) -> bool
|
|
76
77
|
micropython_lib_commits = read_micropython_lib_commits()
|
77
78
|
# Make sure that the correct micropython-lib release is checked out
|
78
79
|
# check if micropython-lib has matching tags
|
79
|
-
if version_tag
|
80
|
+
if version_tag in SET_PREVIEW:
|
80
81
|
# micropython-lib is now a submodule
|
81
82
|
result = git.checkout_commit("master", lib_path)
|
82
83
|
if not result:
|
@@ -111,10 +112,10 @@ def fetch_repos(tag: str, mpy_path: Path, mpy_lib_path: Path):
|
|
111
112
|
log.trace("no stubs repo found : {CONFIG.stub_path.parent}")
|
112
113
|
|
113
114
|
if not tag:
|
114
|
-
tag =
|
115
|
+
tag = V_PREVIEW
|
115
116
|
|
116
117
|
log.info(f"Switching to {tag}")
|
117
|
-
if tag ==
|
118
|
+
if tag == V_PREVIEW:
|
118
119
|
git.switch_branch(repo=mpy_path, branch="master")
|
119
120
|
else:
|
120
121
|
git.checkout_tag(repo=mpy_path, tag=tag)
|
stubber/utils/versions.py
CHANGED
@@ -1,8 +1,21 @@
|
|
1
1
|
"""Handle versions of micropython based on the git tags in the repo """
|
2
2
|
|
3
|
+
from pathlib import Path
|
4
|
+
|
3
5
|
from github import Github
|
4
6
|
from packaging.version import parse
|
5
7
|
|
8
|
+
import stubber.basicgit as git
|
9
|
+
import stubber.utils as utils
|
10
|
+
|
11
|
+
OLDEST_VERSION = "1.16"
|
12
|
+
"This is the oldest MicroPython version to build the stubs on"
|
13
|
+
|
14
|
+
V_PREVIEW = "preview"
|
15
|
+
"Latest preview version"
|
16
|
+
|
17
|
+
SET_PREVIEW = {"preview", "latest", "master"}
|
18
|
+
|
6
19
|
|
7
20
|
def clean_version(
|
8
21
|
version: str,
|
@@ -15,9 +28,9 @@ def clean_version(
|
|
15
28
|
):
|
16
29
|
"Clean up and transform the many flavours of versions"
|
17
30
|
# 'v1.13.0-103-gb137d064e' --> 'v1.13-103'
|
18
|
-
|
19
31
|
if version in {"", "-"}:
|
20
32
|
return version
|
33
|
+
is_preview = "-preview" in version
|
21
34
|
nibbles = version.split("-")
|
22
35
|
ver_ = nibbles[0].lower().lstrip("v")
|
23
36
|
if not patch and ver_ >= "1.10.0" and ver_ < "1.20.0" and ver_.endswith(".0"):
|
@@ -25,21 +38,35 @@ def clean_version(
|
|
25
38
|
nibbles[0] = nibbles[0][:-2]
|
26
39
|
if len(nibbles) == 1:
|
27
40
|
version = nibbles[0]
|
28
|
-
elif build:
|
41
|
+
elif build and not is_preview:
|
29
42
|
version = "-".join(nibbles) if commit else "-".join(nibbles[:-1])
|
30
43
|
else:
|
31
44
|
# version = "-".join((nibbles[0], LATEST))
|
32
45
|
# HACK: this is not always right, but good enough most of the time
|
33
|
-
|
46
|
+
if is_preview:
|
47
|
+
version = "-".join((nibbles[0], V_PREVIEW))
|
48
|
+
else:
|
49
|
+
version = V_PREVIEW
|
34
50
|
if flat:
|
35
|
-
version = version.strip().replace(".", "_")
|
51
|
+
version = version.strip().replace(".", "_").replace("-", "_")
|
36
52
|
else:
|
37
|
-
version = version.strip().replace("_", ".")
|
53
|
+
version = version.strip().replace("_preview", "-preview").replace("_", ".")
|
38
54
|
|
39
55
|
if drop_v:
|
40
56
|
version = version.lstrip("v")
|
41
|
-
elif not version.startswith("v") and version.lower()
|
57
|
+
elif not version.startswith("v") and version.lower() not in SET_PREVIEW:
|
42
58
|
version = "v" + version
|
59
|
+
if version == "latest":
|
60
|
+
version = V_PREVIEW
|
61
|
+
return version
|
62
|
+
|
63
|
+
|
64
|
+
def checkedout_version(path: Path, flat: bool = False) -> str:
|
65
|
+
"""Get the checked-out version of the repo"""
|
66
|
+
version = git.get_local_tag(path.as_posix())
|
67
|
+
if not version:
|
68
|
+
raise ValueError("No valid Tag found")
|
69
|
+
version = utils.clean_version(version, flat=flat, drop_v=False)
|
43
70
|
return version
|
44
71
|
|
45
72
|
|
@@ -50,4 +77,18 @@ def micropython_versions(start: str = "v1.9.2"):
|
|
50
77
|
repo = g.get_repo("micropython/micropython")
|
51
78
|
return [tag.name for tag in repo.get_tags() if parse(tag.name) >= parse(start)]
|
52
79
|
except Exception:
|
53
|
-
return [
|
80
|
+
return [
|
81
|
+
"v1.19.1",
|
82
|
+
"v1.19",
|
83
|
+
"v1.18",
|
84
|
+
"v1.17",
|
85
|
+
"v1.16",
|
86
|
+
"v1.15",
|
87
|
+
"v1.14",
|
88
|
+
"v1.13",
|
89
|
+
"v1.12",
|
90
|
+
"v1.11",
|
91
|
+
"v1.10",
|
92
|
+
"v1.9.4",
|
93
|
+
"v1.9.3",
|
94
|
+
]
|
stubber/variants.py
CHANGED
@@ -26,7 +26,7 @@ def create_variants(
|
|
26
26
|
*,
|
27
27
|
target_path: Optional[Path] = None,
|
28
28
|
version: str = "",
|
29
|
-
make_variants: List[CreateStubsVariant] = ALL_VARIANTS,
|
29
|
+
make_variants: List[CreateStubsVariant] = ALL_VARIANTS[:3],
|
30
30
|
update_modules: bool = True,
|
31
31
|
):
|
32
32
|
"""
|
@@ -50,7 +50,7 @@ def create_variants(
|
|
50
50
|
ctx = codemod.CodemodContext()
|
51
51
|
base_file = base_path / "createstubs.py"
|
52
52
|
log.info(f"Reading : {base_file}")
|
53
|
-
base_txt = (base_path / "createstubs.py").read_text()
|
53
|
+
base_txt = (base_path / "createstubs.py").read_text(encoding="utf-8")
|
54
54
|
base_module = cst.parse_module(base_txt)
|
55
55
|
|
56
56
|
for var in make_variants:
|
@@ -89,7 +89,7 @@ def create_variants(
|
|
89
89
|
|
90
90
|
# str -> path
|
91
91
|
# read minified file
|
92
|
-
minified_txt = minified_path.read_text()
|
92
|
+
minified_txt = minified_path.read_text(encoding="utf-8")
|
93
93
|
cross_compile(minified_txt, mpy_path, version=version)
|
94
94
|
|
95
95
|
|
stubber/board/logging.py
DELETED
@@ -1,99 +0,0 @@
|
|
1
|
-
import sys
|
2
|
-
|
3
|
-
CRITICAL = 50
|
4
|
-
ERROR = 40
|
5
|
-
WARNING = 30
|
6
|
-
INFO = 20
|
7
|
-
DEBUG = 10
|
8
|
-
NOTSET = 0
|
9
|
-
|
10
|
-
_level_dict = {
|
11
|
-
CRITICAL: "CRIT",
|
12
|
-
ERROR: "ERROR",
|
13
|
-
WARNING: "WARN",
|
14
|
-
INFO: "INFO",
|
15
|
-
DEBUG: "DEBUG",
|
16
|
-
}
|
17
|
-
|
18
|
-
_stream = sys.stderr
|
19
|
-
|
20
|
-
|
21
|
-
class Logger:
|
22
|
-
|
23
|
-
level = NOTSET
|
24
|
-
|
25
|
-
def __init__(self, name):
|
26
|
-
self.name = name
|
27
|
-
|
28
|
-
def _level_str(self, level):
|
29
|
-
l = _level_dict.get(level)
|
30
|
-
if l is not None:
|
31
|
-
return l
|
32
|
-
return "LVL%s" % level
|
33
|
-
|
34
|
-
def setLevel(self, level):
|
35
|
-
self.level = level
|
36
|
-
|
37
|
-
def isEnabledFor(self, level):
|
38
|
-
return level >= (self.level or _level)
|
39
|
-
|
40
|
-
def log(self, level, msg, *args):
|
41
|
-
if level >= (self.level or _level):
|
42
|
-
_stream.write("%-6s:%-8s:" % (self._level_str(level), self.name))
|
43
|
-
if not args:
|
44
|
-
print(msg, file=_stream)
|
45
|
-
else:
|
46
|
-
print(msg % args, file=_stream)
|
47
|
-
|
48
|
-
def debug(self, msg, *args):
|
49
|
-
self.log(DEBUG, msg, *args)
|
50
|
-
|
51
|
-
def info(self, msg, *args):
|
52
|
-
self.log(INFO, msg, *args)
|
53
|
-
|
54
|
-
def warning(self, msg, *args):
|
55
|
-
self.log(WARNING, msg, *args)
|
56
|
-
|
57
|
-
def error(self, msg, *args):
|
58
|
-
self.log(ERROR, msg, *args)
|
59
|
-
|
60
|
-
def critical(self, msg, *args):
|
61
|
-
self.log(CRITICAL, msg, *args)
|
62
|
-
|
63
|
-
# def exc(self, e, msg, *args):
|
64
|
-
# self.log(ERROR, msg, *args)
|
65
|
-
# sys.print_exception(e, _stream) # type : disable
|
66
|
-
|
67
|
-
def exception(self, msg, *args):
|
68
|
-
self.critical(sys.exc_info()[1], msg, *args)
|
69
|
-
|
70
|
-
|
71
|
-
_level = INFO
|
72
|
-
_loggers = {}
|
73
|
-
|
74
|
-
|
75
|
-
def getLogger(name):
|
76
|
-
if name in _loggers:
|
77
|
-
return _loggers[name]
|
78
|
-
l = Logger(name)
|
79
|
-
_loggers[name] = l
|
80
|
-
return l
|
81
|
-
|
82
|
-
|
83
|
-
def info(msg, *args):
|
84
|
-
getLogger(None).info(msg, *args)
|
85
|
-
|
86
|
-
|
87
|
-
def debug(msg, *args):
|
88
|
-
getLogger(None).debug(msg, *args)
|
89
|
-
|
90
|
-
|
91
|
-
def basicConfig(level=INFO, filename=None, stream=None, format=None):
|
92
|
-
global _level, _stream
|
93
|
-
_level = level
|
94
|
-
if stream:
|
95
|
-
_stream = stream
|
96
|
-
if filename is not None:
|
97
|
-
print("logging.basicConfig: filename arg is not supported")
|
98
|
-
if format is not None:
|
99
|
-
print("logging.basicConfig: format arg is not supported")
|
File without changes
|
File without changes
|
{micropython_stubber-1.16.3.dist-info → micropython_stubber-1.17.0.dist-info}/entry_points.txt
RENAMED
File without changes
|