micropython-stubber 1.25.0.post3__py3-none-any.whl → 1.25.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.25.0.post3.dist-info → micropython_stubber-1.25.1.dist-info}/METADATA +3 -4
- {micropython_stubber-1.25.0.post3.dist-info → micropython_stubber-1.25.1.dist-info}/RECORD +24 -24
- {micropython_stubber-1.25.0.post3.dist-info → micropython_stubber-1.25.1.dist-info}/WHEEL +1 -1
- stubber/__init__.py +1 -1
- stubber/board/createstubs.py +1 -1
- stubber/board/createstubs_db.py +2 -2
- stubber/board/createstubs_db_min.py +1 -1
- stubber/board/createstubs_db_mpy.mpy +0 -0
- stubber/board/createstubs_mem.py +2 -2
- 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/visitors/type_helpers.py +16 -7
- stubber/commands/cli.py +4 -3
- stubber/commands/get_docstubs_cmd.py +0 -1
- stubber/minify.py +30 -9
- stubber/publish/package.py +12 -3
- stubber/publish/stubpackage.py +7 -12
- stubber/rst/lookup.py +6 -0
- stubber/rst/reader.py +15 -6
- stubber/stubs_from_docs.py +28 -15
- {micropython_stubber-1.25.0.post3.dist-info → micropython_stubber-1.25.1.dist-info}/LICENSE +0 -0
- {micropython_stubber-1.25.0.post3.dist-info → micropython_stubber-1.25.1.dist-info}/entry_points.txt +0 -0
{micropython_stubber-1.25.0.post3.dist-info → micropython_stubber-1.25.1.dist-info}/METADATA
RENAMED
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.3
|
2
2
|
Name: micropython-stubber
|
3
|
-
Version: 1.25.
|
3
|
+
Version: 1.25.1
|
4
4
|
Summary: Tooling to create and maintain stubs for MicroPython
|
5
5
|
License: MIT
|
6
6
|
Keywords: MicroPython,stubs,vscode,pyright,linting,static type check
|
@@ -25,13 +25,12 @@ Requires-Dist: executing (>=2.0.1,<3.0.0)
|
|
25
25
|
Requires-Dist: importlib-metadata (>=1,<9) ; python_version < "3.8"
|
26
26
|
Requires-Dist: libcst (>=1.1.0,<2.0.0)
|
27
27
|
Requires-Dist: loguru (>=0.6,<0.8)
|
28
|
-
Requires-Dist: mpflash (
|
28
|
+
Requires-Dist: mpflash (==1.25.0.rc3)
|
29
29
|
Requires-Dist: mpremote (>=1.25.0)
|
30
|
+
Requires-Dist: mpy-cross (>=1.25.0.post2,<2.0.0)
|
30
31
|
Requires-Dist: mypy (>=1.10)
|
31
32
|
Requires-Dist: mypy-gitlab-code-quality (>=1.1.0,<2.0.0)
|
32
33
|
Requires-Dist: packaging (>=24.2,<25.0)
|
33
|
-
Requires-Dist: pipx (>=1.1.0,<2.0.0)
|
34
|
-
Requires-Dist: poetry (>=2.0.1,<3.0.0)
|
35
34
|
Requires-Dist: pydeps (==3.0.1)
|
36
35
|
Requires-Dist: pygithub (>=2.1.1,<3.0.0)
|
37
36
|
Requires-Dist: pypi-simple (>=1.0.0,<2.0.0)
|
@@ -1,18 +1,18 @@
|
|
1
|
-
stubber/__init__.py,sha256=
|
1
|
+
stubber/__init__.py,sha256=WLF-UWMZrfYEGB3W8ibf4lGlq0ttLDpiiFVq8cSxvxY,49
|
2
2
|
stubber/board/board_info.csv,sha256=K2VSmfR013fN-oJWkQUmiQ19w09dVwJHDquPy6QmMhY,8627
|
3
3
|
stubber/board/boot.py,sha256=XjWlKErU5nI1HJSugXIP_3hlwgRQboE6sJrpcbSygnk,1120
|
4
|
-
stubber/board/createstubs.py,sha256=
|
5
|
-
stubber/board/createstubs_db.py,sha256=
|
6
|
-
stubber/board/createstubs_db_min.py,sha256=
|
7
|
-
stubber/board/createstubs_db_mpy.mpy,sha256=
|
4
|
+
stubber/board/createstubs.py,sha256=Qw1IY4pYxVDPJbsBXqdLBhMTioF9wFO2BrJENPkRpC8,34715
|
5
|
+
stubber/board/createstubs_db.py,sha256=S89PvG_YDSLAUCm9KELLIMhDOvyo75xGxp2epS7vRbg,31621
|
6
|
+
stubber/board/createstubs_db_min.py,sha256=CSmu7hfR94ehL4hQRNDwSO1WjSVjibKiTclpO2snG1g,12189
|
7
|
+
stubber/board/createstubs_db_mpy.mpy,sha256=sNm2FjoQOxoYqNzfbHYHM7tWd_-KUdRc_yEbPw2GyKY,10148
|
8
8
|
stubber/board/createstubs_lvgl.py,sha256=CTe7eq1ACRK_JJxavaqDD8znn29nSWJiHHTZ_ps6EhM,27217
|
9
9
|
stubber/board/createstubs_lvgl_min.py,sha256=jLkWYmeboI2A8feMC7pT7cYWttLejQTuX7WAEZCylhw,27207
|
10
10
|
stubber/board/createstubs_lvgl_mpy.mpy,sha256=ex-nlq2V5e8anQBJvRWEEc-FzU7nlwg5NSrZ8vOadIA,9267
|
11
|
-
stubber/board/createstubs_mem.py,sha256=
|
12
|
-
stubber/board/createstubs_mem_min.py,sha256=
|
13
|
-
stubber/board/createstubs_mem_mpy.mpy,sha256=
|
14
|
-
stubber/board/createstubs_min.py,sha256=
|
15
|
-
stubber/board/createstubs_mpy.mpy,sha256=
|
11
|
+
stubber/board/createstubs_mem.py,sha256=PFsejWB8MWpwTIAjcZ-swVQqzYJuZMZScUN_I55k_Z4,29939
|
12
|
+
stubber/board/createstubs_mem_min.py,sha256=BSoxt3VRNVYmp6AYlzbq6QAcwC7-H6d-HB6s1tW0wYU,11719
|
13
|
+
stubber/board/createstubs_mem_mpy.mpy,sha256=P7j5AWVSsIjYX--idRInBduHOB_a-vGiquRHBA5KLxI,9735
|
14
|
+
stubber/board/createstubs_min.py,sha256=bJgpv8RQlgqMOLlt5ijoGT0E-zIPbvw_snxymo_QR6o,14463
|
15
|
+
stubber/board/createstubs_mpy.mpy,sha256=6_z65aos0Z-SZkK8P0ByWU9fEC3CkMxChG_xM5cATAg,13071
|
16
16
|
stubber/board/fw_info.py,sha256=6AQbN3jtQgllqWQYl4e-63KeEtV08EXk8_JnM6XBkvo,4554
|
17
17
|
stubber/board/info.py,sha256=b7SOPZHVsVhaayKCwVkFZlYu0BW-UFI7LuG1Eop9480,5629
|
18
18
|
stubber/board/main.py,sha256=f6V3tdt6sPZVLuwemT-NLuK9GySfW2c2J6PJMOOWQQw,413
|
@@ -34,15 +34,15 @@ stubber/codemod/enrich.py,sha256=YB-tXo_UjeVboG2uPAG8d1g81STdhWL4NvCfZ6YPduk,129
|
|
34
34
|
stubber/codemod/merge_docstub.py,sha256=XTvsw4BetCRU1-dJlQisVdDx03ldBh7Yc7aREmLiJPs,27956
|
35
35
|
stubber/codemod/modify_list.py,sha256=xrpFBKug273D9E02owUheZD418BvsIHIZCFj4YDjTxU,2118
|
36
36
|
stubber/codemod/utils.py,sha256=3hk7pwyS4KZxewrWLwbOrdA5ympbum-kfL0ZN-M7rlo,2459
|
37
|
-
stubber/codemod/visitors/type_helpers.py,sha256=
|
37
|
+
stubber/codemod/visitors/type_helpers.py,sha256=F7Xc_f7yp5szg18bf90oew2SpfZlDKK8EdZ3CcvuL2g,11027
|
38
38
|
stubber/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
39
39
|
stubber/commands/build_cmd.py,sha256=Zseci4EHxJuiiy7YS-ucmMokDrVLe4j6fPs-PSbwq1k,2813
|
40
|
-
stubber/commands/cli.py,sha256=
|
40
|
+
stubber/commands/cli.py,sha256=Npt72L598JcQlNevymOT7S0huvQbx8_-s8LSUxR3AaU,1574
|
41
41
|
stubber/commands/clone_cmd.py,sha256=WZnQIqsnkdddXz32riLUw9zhNXHAgk_LODnwbtQlpbo,2714
|
42
42
|
stubber/commands/config_cmd.py,sha256=e8heX27MXfazLxMVtgjK4dsLCWhsoCfdeYGVoH3rqtA,1211
|
43
43
|
stubber/commands/enrich_folder_cmd.py,sha256=LDdSAfDlsAQAddYT9Rp3bFiF6maqA457AmMyWNXdXtg,2236
|
44
44
|
stubber/commands/get_core_cmd.py,sha256=PSjBJz4F8FlT3c_4E-XFo6Xw0dRQzQl0TxsxCoLwIPY,2324
|
45
|
-
stubber/commands/get_docstubs_cmd.py,sha256=
|
45
|
+
stubber/commands/get_docstubs_cmd.py,sha256=lZ7oaixp1jx0OYjeIdCW0ov-qBozaXqZ0zbccCly9ww,5165
|
46
46
|
stubber/commands/get_frozen_cmd.py,sha256=gutYwHdz7XO8CLxutEFiQOUGgKInrKViEKvV8I5eVJU,4253
|
47
47
|
stubber/commands/get_mcu_cmd.py,sha256=CTQVIoGqBx6gwUp1aH1gOysVFEZbeqMvpPb2WJA4EVQ,2807
|
48
48
|
stubber/commands/merge_cmd.py,sha256=0tKgvBiYjleXac0z5vDMxzvAgiZQUF0DafPqoIueKS8,1641
|
@@ -64,7 +64,7 @@ stubber/freeze/get_frozen.py,sha256=ojxUO-Fiy-Tn49Tv_puQrBtZ0dxQEmWj2HfWmHmGODQ,
|
|
64
64
|
stubber/get_cpython.py,sha256=Qnug4TlytwrqBRXCNGnRIMGW63zVcQL_8Ua93eTbrc8,3885
|
65
65
|
stubber/get_lobo.py,sha256=jyysWbeEwNuZZtkTudJP1QbyVvh-TwFom5cE7iCi9lE,1776
|
66
66
|
stubber/merge_config.py,sha256=NCHgpt67uR_yFaiXCtkvZIKqzold2aG7kYUzgvCg2xk,2855
|
67
|
-
stubber/minify.py,sha256=
|
67
|
+
stubber/minify.py,sha256=0uxx6FUW3KXbJ7iKUtB34Yw0QGIEfiPwcjBQ_Mw1Dns,16166
|
68
68
|
stubber/modcat.py,sha256=tKB-8l56SuTWoIn8zEtnu5VuPf25ZIggB9x_qNYeiDI,3752
|
69
69
|
stubber/publish/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
70
70
|
stubber/publish/bump.py,sha256=qSb1DpaIxgyoH3YcPU1XKyDKgqkomxSm0WWf1sAVh0Y,3262
|
@@ -74,20 +74,20 @@ stubber/publish/defaults.py,sha256=naAyHN_k8OFQfqRnXlPU3HNA0IZll-NA5GuJEvDEG_k,1
|
|
74
74
|
stubber/publish/enums.py,sha256=Z_x798ArtxyjQIRRY43GDGNB9BD4uPfpeGsXYdj31w0,780
|
75
75
|
stubber/publish/helpers.py,sha256=909umfKUHBMBoVnAanop1vKx8loCrWntlfiiG6z89lY,716
|
76
76
|
stubber/publish/merge_docstubs.py,sha256=jlMQ3q6DqnLEJ_BvfgtXpTSlD6_XDpn697HG4fi3lRk,6513
|
77
|
-
stubber/publish/package.py,sha256=
|
77
|
+
stubber/publish/package.py,sha256=m1qxyCp1jqBIUVsQxpJYS0R9v4CTmYmqKp2mT7nPltk,5977
|
78
78
|
stubber/publish/pathnames.py,sha256=vORgygaOJJAjlI3cLhNTHfowdewSDsv7zck5evPe1cY,1803
|
79
79
|
stubber/publish/publish.py,sha256=fG95ANcdZibwWW_ZoqjhPpolswb17IOi-gTIpNPwjKc,3989
|
80
80
|
stubber/publish/pypi.py,sha256=LdvwLfjkkSFBTI4MHyl7Ko_ZWn1SflWxJ9uo2mtPKtc,1272
|
81
|
-
stubber/publish/stubpackage.py,sha256
|
81
|
+
stubber/publish/stubpackage.py,sha256=BOfHqlPNP45cKLI65VANAdO0wO1YN9F1Ks-JbEHUoKQ,47491
|
82
82
|
stubber/rst/__init__.py,sha256=5VcbDCotIICa2xnJDs_gw2sFXpjjGOZZbwCrNKXy1OE,293
|
83
83
|
stubber/rst/classsort.py,sha256=-Uji6LzBbX6voKmiXSuexJXyoQ3fmSDQ7Fuz4j1Kk8E,2655
|
84
|
-
stubber/rst/lookup.py,sha256=
|
84
|
+
stubber/rst/lookup.py,sha256=2s3ZT1pNKddL9cUrIsHzP5yGBi0sIYBikYoMlP9kbKY,26132
|
85
85
|
stubber/rst/output_dict.py,sha256=cpBXRtUD-uh0EgjWIBiRrMLBmIAEXjoJFSOAg-qJQiU,14755
|
86
|
-
stubber/rst/reader.py,sha256=
|
86
|
+
stubber/rst/reader.py,sha256=kCjQpL4QbVyChUQcXO_T1rwaZjE3WUcq9UksQmRq0U8,35408
|
87
87
|
stubber/rst/report_return.py,sha256=p0JfJs_WTWTtRZREcQeqUgDW-_TP2VuuX7k7-c49y5E,3024
|
88
88
|
stubber/rst/rst_utils.py,sha256=-F6J09-WQBzI5419ItzOlm4gUKxF4BMru2OyXx-M6ko,18314
|
89
89
|
stubber/stubber.py,sha256=GxLfHIzDyfFvgiTqMj9DB3tq7I3EnEUNbdoCtYr8gHM,1640
|
90
|
-
stubber/stubs_from_docs.py,sha256=
|
90
|
+
stubber/stubs_from_docs.py,sha256=Z8BFBuUQ1su4MUZTXiHRC4y80c8m9EDHTE7FxD2KUco,3700
|
91
91
|
stubber/tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
92
92
|
stubber/tools/manifestfile.py,sha256=YzPMc7PNciLOBpoc4xgUZ38t88C1C8b4fjG0qfWd6K8,25749
|
93
93
|
stubber/tools/readme.md,sha256=uI0higcFUtjSLKobn7NK2LoqZ0BqcbftXSDgNjbsnzo,284
|
@@ -103,8 +103,8 @@ stubber/utils/repos.py,sha256=kI2VcbKS1sNzFRr8mUDMdKYOYRvxpFIwy7JRyQ5Nxuk,7147
|
|
103
103
|
stubber/utils/stubmaker.py,sha256=gB6n41o13WcShnSzc_lyoTFplotaPSQ3hekoLJvd2BU,5236
|
104
104
|
stubber/utils/typed_config_toml.py,sha256=ZR7eo-whyL4nhFXj6xs7E121sLuE-ivlUDevII4K2xg,2653
|
105
105
|
stubber/variants.py,sha256=NnwUP-aiGUPAn15BeRRFcBWQUOzAFFnN2oL4u9zio-s,3792
|
106
|
-
micropython_stubber-1.25.
|
107
|
-
micropython_stubber-1.25.
|
108
|
-
micropython_stubber-1.25.
|
109
|
-
micropython_stubber-1.25.
|
110
|
-
micropython_stubber-1.25.
|
106
|
+
micropython_stubber-1.25.1.dist-info/entry_points.txt,sha256=JoR8NWh8t6pbDyn0WOMCIfRfDQAOGxqbOgJWuxv3Cxw,116
|
107
|
+
micropython_stubber-1.25.1.dist-info/LICENSE,sha256=Fx9qrL45ayRXgH6QzttboqZEjKXms0w1t_b_nkOqYCU,1572
|
108
|
+
micropython_stubber-1.25.1.dist-info/METADATA,sha256=WedY9LNxDQqQ-bP6Z_MBI3b3i7rzFPkmzjyhuapdgUg,19949
|
109
|
+
micropython_stubber-1.25.1.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
110
|
+
micropython_stubber-1.25.1.dist-info/RECORD,,
|
stubber/__init__.py
CHANGED
stubber/board/createstubs.py
CHANGED
stubber/board/createstubs_db.py
CHANGED
@@ -18,7 +18,7 @@ Create stubs for (all) modules on a MicroPython board.
|
|
18
18
|
- cross compilation, using mpy-cross, to avoid the compilation step on the micropython device
|
19
19
|
|
20
20
|
|
21
|
-
This variant was generated from createstubs.py by micropython-stubber v1.
|
21
|
+
This variant was generated from createstubs.py by micropython-stubber v1.25.1
|
22
22
|
"""
|
23
23
|
|
24
24
|
# Copyright (c) 2019-2024 Jos Verlinde
|
@@ -43,7 +43,7 @@ try:
|
|
43
43
|
except ImportError:
|
44
44
|
from ucollections import OrderedDict # type: ignore
|
45
45
|
|
46
|
-
__version__ = "v1.25.
|
46
|
+
__version__ = "v1.25.1"
|
47
47
|
ENOENT = 2 # on most ports
|
48
48
|
ENOMESSAGE = 44 # on pyscript
|
49
49
|
_MAX_CLASS_LEVEL = 2 # Max class nesting
|
Binary file
|
stubber/board/createstubs_mem.py
CHANGED
@@ -9,7 +9,7 @@
|
|
9
9
|
- cross compilation, using mpy-cross,
|
10
10
|
to avoid the compilation step on the micropython device
|
11
11
|
|
12
|
-
This variant was generated from createstubs.py by micropython-stubber v1.
|
12
|
+
This variant was generated from createstubs.py by micropython-stubber v1.25.1
|
13
13
|
"""
|
14
14
|
|
15
15
|
# Copyright (c) 2019-2024 Jos Verlinde
|
@@ -34,7 +34,7 @@ try:
|
|
34
34
|
except ImportError:
|
35
35
|
from ucollections import OrderedDict # type: ignore
|
36
36
|
|
37
|
-
__version__ = "v1.25.
|
37
|
+
__version__ = "v1.25.1"
|
38
38
|
ENOENT = 2 # on most ports
|
39
39
|
ENOMESSAGE = 44 # on pyscript
|
40
40
|
_MAX_CLASS_LEVEL = 2 # Max class nesting
|
Binary file
|
stubber/board/createstubs_min.py
CHANGED
Binary file
|
@@ -47,13 +47,22 @@ def is_CONSTANT(statement):
|
|
47
47
|
AnnAssign- FOO:bool = ...
|
48
48
|
"""
|
49
49
|
|
50
|
-
|
51
|
-
statement
|
52
|
-
|
53
|
-
if
|
54
|
-
|
55
|
-
|
56
|
-
|
50
|
+
try:
|
51
|
+
if m.matches(statement, m.SimpleStatementLine()):
|
52
|
+
statement = statement.body[0]
|
53
|
+
if m.matches(statement, m.Assign()):
|
54
|
+
if len(statement.targets) != 1:
|
55
|
+
return False
|
56
|
+
if m.matches(statement.targets[0], m.Name()):
|
57
|
+
if statement.targets[0].target.value.isupper():
|
58
|
+
return True
|
59
|
+
elif m.matches(statement.targets[0], m.AssignTarget()):
|
60
|
+
if m.matches(statement.targets[0].target, m.Name()):
|
61
|
+
if statement.targets[0].children[0].value.isupper():
|
62
|
+
return True
|
63
|
+
except Exception as e:
|
64
|
+
log.debug(f"Error in is_CONSTANT: {e}")
|
65
|
+
return False
|
57
66
|
return False
|
58
67
|
|
59
68
|
|
stubber/commands/cli.py
CHANGED
@@ -4,16 +4,17 @@ command line interface - main group
|
|
4
4
|
|
5
5
|
import sys
|
6
6
|
|
7
|
-
from mpflash.vendor.click_aliases import ClickAliasedGroup
|
8
7
|
import rich_click as click
|
9
|
-
from mpflash.logger import log
|
8
|
+
from mpflash.logger import log
|
9
|
+
from mpflash.logger import set_loglevel as mpf_set_loglevel
|
10
|
+
from mpflash.vendor.click_aliases import ClickAliasedGroup
|
11
|
+
|
10
12
|
from stubber import __version__
|
11
13
|
|
12
14
|
|
13
15
|
@click.group(chain=True, cls=ClickAliasedGroup)
|
14
16
|
@click.version_option(package_name="micropython-stubber", prog_name="micropython-stubber✏️ ")
|
15
17
|
@click.option(
|
16
|
-
"-V",
|
17
18
|
"-V",
|
18
19
|
"--verbose",
|
19
20
|
count=True,
|
stubber/minify.py
CHANGED
@@ -5,6 +5,7 @@ Minimizes and cross-compiles a MicroPyton file.
|
|
5
5
|
|
6
6
|
import itertools
|
7
7
|
import subprocess
|
8
|
+
import sys
|
8
9
|
import tempfile
|
9
10
|
from contextlib import ExitStack
|
10
11
|
from io import BytesIO, IOBase, StringIO, TextIOWrapper
|
@@ -18,6 +19,8 @@ except ImportError:
|
|
18
19
|
|
19
20
|
from mpflash.logger import log
|
20
21
|
from mpflash.versions import SET_PREVIEW, V_PREVIEW
|
22
|
+
import shutil
|
23
|
+
import os
|
21
24
|
|
22
25
|
# Type Aliases for minify
|
23
26
|
StubSource = Union[Path, str, StringIO, TextIOWrapper]
|
@@ -369,10 +372,10 @@ def cross_compile(
|
|
369
372
|
else:
|
370
373
|
# target must be a Path object
|
371
374
|
_target = get_temp_file(suffix=".mpy")
|
372
|
-
result =
|
375
|
+
result = run_mpy_cross(version, source_file, _target)
|
373
376
|
if result.stderr and "No matching distribution found for mpy-cross~=" in result.stderr:
|
374
377
|
log.warning(f"mpy-cross~={version} not found, using most current version.")
|
375
|
-
result =
|
378
|
+
result = run_mpy_cross(V_PREVIEW, source_file, _target)
|
376
379
|
|
377
380
|
if result.returncode == 0:
|
378
381
|
log.debug(f"mpy-cross compiled to : {_target.name}")
|
@@ -388,18 +391,36 @@ def cross_compile(
|
|
388
391
|
return result.returncode
|
389
392
|
|
390
393
|
|
391
|
-
def
|
392
|
-
"""
|
393
|
-
|
394
|
+
def locate_mpy_cross():
|
395
|
+
"""Locate the path of the mpy-cross commandline tool in the active environment"""
|
396
|
+
try:
|
397
|
+
# Check if it's available as a command in PATH
|
398
|
+
mpy_cross_path = shutil.which("mpy-cross")
|
399
|
+
if mpy_cross_path:
|
400
|
+
log.info(f"Found mpy-cross executable in PATH: {mpy_cross_path}")
|
401
|
+
return mpy_cross_path
|
402
|
+
|
403
|
+
# Check in the Scripts/bin directory of the current Python environment
|
404
|
+
bin_dir = "Scripts" if sys.platform == "win32" else "bin"
|
405
|
+
env_path = os.path.join(os.path.dirname(sys.executable), bin_dir, "mpy-cross")
|
406
|
+
if os.path.exists(env_path):
|
407
|
+
log.info(f"Found mpy-cross executable in Python environment: {env_path}")
|
408
|
+
return env_path
|
409
|
+
raise FileNotFoundError("mpy-cross executable not found in PATH or Python environment")
|
410
|
+
except Exception as e:
|
411
|
+
log.debug(f"Error locating mpy-cross: {e}")
|
412
|
+
raise FileNotFoundError("mpy-cross executable not found in PATH or Python environment") from e
|
413
|
+
|
414
|
+
def run_mpy_cross(version: str, source_file, _target):
|
415
|
+
"""Run mpy-cross using --compat if needed"""
|
394
416
|
log.info(f"Compiling with mpy-cross version: {version}")
|
395
417
|
if version in SET_PREVIEW:
|
396
418
|
version = ""
|
397
419
|
if version:
|
398
|
-
version =
|
420
|
+
version = version.lstrip("v")
|
421
|
+
compat = ["--compat", version] if version else []
|
399
422
|
|
400
|
-
cmd = [
|
401
|
-
# Add params
|
402
|
-
cmd += ["-O2", str(source_file), "-o", str(_target), "-s", "createstubs.py"]
|
423
|
+
cmd = [locate_mpy_cross() ] + compat + ["-O2", str(source_file), "-o", str(_target), "-s", "createstubs.py"]
|
403
424
|
log.trace(" ".join(cmd))
|
404
425
|
result = subprocess.run(
|
405
426
|
cmd, capture_output=True, text=True, encoding="utf-8"
|
stubber/publish/package.py
CHANGED
@@ -56,6 +56,15 @@ def get_package(
|
|
56
56
|
version=version,
|
57
57
|
json_data=package_info,
|
58
58
|
)
|
59
|
+
# TODO @Josverl: Check or update stub_sources in len < 3
|
60
|
+
EXPECTED_STUBS = 3
|
61
|
+
if len(p_db.stub_sources) < EXPECTED_STUBS:
|
62
|
+
log.warning(f"Package {pkg_name} has less than 3 stub sources, updating...")
|
63
|
+
stub_sources = combo_sources(family, port, board, clean_version(p_db.mpy_version, flat=True))
|
64
|
+
if len(stub_sources) >= EXPECTED_STUBS:
|
65
|
+
p_db.stub_sources = stub_sources
|
66
|
+
p_db.update_sources()
|
67
|
+
log.info(f"Updated stub sources for {pkg_name} to {p_db.stub_sources}")
|
59
68
|
return p_db
|
60
69
|
|
61
70
|
log.debug(f"No package found for {pkg_name} in database, creating new package")
|
@@ -115,13 +124,13 @@ def create_package(
|
|
115
124
|
create and initialize a package with the correct sources
|
116
125
|
"""
|
117
126
|
ver_flat = clean_version(mpy_version, flat=True)
|
118
|
-
|
127
|
+
stub_sources: StubSources = []
|
119
128
|
# if pkg_type != COMBO_STUBS:
|
120
129
|
# raise ValueError("Not Supported")
|
121
130
|
|
122
131
|
assert port != "", "port must be specified for combo stubs"
|
123
|
-
|
124
|
-
return StubPackage(pkg_name, port=port, board=board, version=mpy_version,
|
132
|
+
stub_sources = combo_sources(family, port, board, ver_flat)
|
133
|
+
return StubPackage(pkg_name, port=port, board=board, version=mpy_version, stub_sources=stub_sources)
|
125
134
|
|
126
135
|
|
127
136
|
def combo_sources(family: str, port: str, board: str, ver_flat: str) -> StubSources:
|
stubber/publish/stubpackage.py
CHANGED
@@ -210,7 +210,7 @@ class Builder(VersionedPackage):
|
|
210
210
|
board: str = GENERIC_U,
|
211
211
|
variant: Optional[str] = None,
|
212
212
|
description: str = "MicroPython stubs",
|
213
|
-
|
213
|
+
stub_sources: Optional[StubSources] = None,
|
214
214
|
# json_data: Optional[Dict[str, Any]] = None,
|
215
215
|
): # port: str, board: str
|
216
216
|
super().__init__(package_name=package_name, mpy_version=mpy_version)
|
@@ -221,7 +221,7 @@ class Builder(VersionedPackage):
|
|
221
221
|
self.board = board
|
222
222
|
self.variant = variant or ""
|
223
223
|
self.description = description
|
224
|
-
self.stub_sources =
|
224
|
+
self.stub_sources = stub_sources or []
|
225
225
|
self.hash = None # intial hash
|
226
226
|
"""Hash of all the files in the package"""
|
227
227
|
self.stub_hash = None # intial hash
|
@@ -323,7 +323,7 @@ class Builder(VersionedPackage):
|
|
323
323
|
for n in range(len(self.stub_sources)):
|
324
324
|
stub_type, src_path = self.stub_sources[n]
|
325
325
|
try:
|
326
|
-
log.debug(f"
|
326
|
+
log.debug(f"Copy {stub_type:<20} from {src_path}")
|
327
327
|
self.copy_folder(stub_type, src_path)
|
328
328
|
except OSError as e:
|
329
329
|
if stub_type != StubSource.FROZEN:
|
@@ -587,7 +587,7 @@ class PoetryBuilder(Builder):
|
|
587
587
|
mpy_version: str = "0.0.1",
|
588
588
|
board: str = GENERIC_U,
|
589
589
|
description: str = "MicroPython stubs",
|
590
|
-
|
590
|
+
stub_sources: Optional[StubSources] = None,
|
591
591
|
json_data: Optional[Dict[str, Any]] = None,
|
592
592
|
):
|
593
593
|
super().__init__(
|
@@ -596,7 +596,7 @@ class PoetryBuilder(Builder):
|
|
596
596
|
port=port,
|
597
597
|
board=board,
|
598
598
|
description=description,
|
599
|
-
|
599
|
+
stub_sources=stub_sources,
|
600
600
|
)
|
601
601
|
|
602
602
|
# -----------------------------------------------
|
@@ -799,7 +799,7 @@ class StubPackage(PoetryBuilder):
|
|
799
799
|
board: str = GENERIC_U,
|
800
800
|
version: str = "0.0.1",
|
801
801
|
description: str = "MicroPython stubs",
|
802
|
-
|
802
|
+
stub_sources: Optional[StubSources] = None,
|
803
803
|
json_data: Optional[Dict[str, Any]] = None,
|
804
804
|
):
|
805
805
|
"""
|
@@ -826,7 +826,7 @@ class StubPackage(PoetryBuilder):
|
|
826
826
|
port=port,
|
827
827
|
board=board,
|
828
828
|
description=description,
|
829
|
-
|
829
|
+
stub_sources=stub_sources or [],
|
830
830
|
)
|
831
831
|
self.port = port
|
832
832
|
self.board = board
|
@@ -840,11 +840,6 @@ class StubPackage(PoetryBuilder):
|
|
840
840
|
|
841
841
|
self.create_update_pyproject_toml()
|
842
842
|
|
843
|
-
# self.stub_sources: StubSources = []
|
844
|
-
# # save the stub sources
|
845
|
-
# if stubs:
|
846
|
-
# self.stub_sources = stubs
|
847
|
-
|
848
843
|
self.status: Status = Status(
|
849
844
|
{
|
850
845
|
"result": "-",
|
stubber/rst/lookup.py
CHANGED
@@ -445,6 +445,12 @@ PARAM_FIXES = [
|
|
445
445
|
"(ip, subnet, gateway, dns):Optional[Any]=None",
|
446
446
|
"configtuple: Optional[Tuple]",
|
447
447
|
),
|
448
|
+
# network.ipconfig
|
449
|
+
Fix(
|
450
|
+
"param=value",
|
451
|
+
"param:Optional[str]=None",
|
452
|
+
name="ipconfig",
|
453
|
+
),
|
448
454
|
# framebuffer
|
449
455
|
# unresolvable parameter defaults # FrameBuffer: def __init__
|
450
456
|
Fix(
|
stubber/rst/reader.py
CHANGED
@@ -69,10 +69,19 @@ from typing import List, Optional, Tuple
|
|
69
69
|
|
70
70
|
from mpflash.logger import log
|
71
71
|
from mpflash.versions import V_PREVIEW
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
72
|
+
|
73
|
+
from stubber.rst import (
|
74
|
+
CHILD_PARENT_CLASS,
|
75
|
+
MODULE_GLUE,
|
76
|
+
PARAM_FIXES,
|
77
|
+
PARAM_RE_FIXES,
|
78
|
+
RST_DOC_FIXES,
|
79
|
+
TYPING_IMPORT,
|
80
|
+
ClassSourceDict,
|
81
|
+
FunctionSourceDict,
|
82
|
+
ModuleSourceDict,
|
83
|
+
return_type_from_context,
|
84
|
+
)
|
76
85
|
from stubber.rst.lookup import Fix
|
77
86
|
from stubber.utils.config import CONFIG
|
78
87
|
|
@@ -496,8 +505,8 @@ class RSTParser(RSTReader):
|
|
496
505
|
self.read_file(file_path)
|
497
506
|
self.parse()
|
498
507
|
# reset this file to done
|
499
|
-
self.rst_text = []
|
500
|
-
self.line_no = 1
|
508
|
+
# self.rst_text = []
|
509
|
+
# self.line_no = 1
|
501
510
|
|
502
511
|
def parse_module(self):
|
503
512
|
"parse a module tag and set the module's docstring"
|
stubber/stubs_from_docs.py
CHANGED
@@ -78,23 +78,11 @@ def get_rst_sources(rst_path: Path, pattern: str) -> List[Path]:
|
|
78
78
|
def make_docstubs(
|
79
79
|
dst_path: Path, v_tag: str, release: str, suffix: str, files: List[Path], clean_rst: bool
|
80
80
|
):
|
81
|
-
"""Create the
|
81
|
+
"""Create docstubs from the list of rst files"""
|
82
82
|
|
83
83
|
for file in files:
|
84
|
-
|
85
|
-
|
86
|
-
reader.source_release = release
|
87
|
-
log.debug(f"Reading: {file}")
|
88
|
-
reader.read_file(file)
|
89
|
-
reader.parse()
|
90
|
-
# Destination = "module.__init__.pyi"
|
91
|
-
if "." in file.stem:
|
92
|
-
target = dst_path / f"{(file.stem).replace('.', '/')}{suffix}"
|
93
|
-
else:
|
94
|
-
target = dst_path / file.stem / f"__init__{suffix}"
|
95
|
-
# fname = (dst_path / file.name).with_suffix(suffix)
|
96
|
-
reader.write_file(target)
|
97
|
-
del reader
|
84
|
+
make_docstub(file, dst_path, v_tag, release, suffix, clean_rst)
|
85
|
+
|
98
86
|
for name in U_MODULES:
|
99
87
|
# create a file "umodule.pyi" for each module
|
100
88
|
# and add a line : from module import *
|
@@ -107,3 +95,28 @@ def make_docstubs(
|
|
107
95
|
f.write("# Allow the use of micro-module notation \n\n")
|
108
96
|
f.write(f"from {name} import * # type: ignore\n")
|
109
97
|
f.flush()
|
98
|
+
|
99
|
+
|
100
|
+
def make_docstub(
|
101
|
+
file: Path,
|
102
|
+
dst_path: Path,
|
103
|
+
v_tag: str,
|
104
|
+
release: str,
|
105
|
+
suffix: str,
|
106
|
+
clean_rst: bool,
|
107
|
+
):
|
108
|
+
"""Create a docstub from a single rst file"""
|
109
|
+
reader = RSTWriter(v_tag)
|
110
|
+
reader.clean_rst = clean_rst
|
111
|
+
reader.source_release = release
|
112
|
+
log.debug(f"Reading: {file}")
|
113
|
+
reader.read_file(file)
|
114
|
+
reader.parse()
|
115
|
+
|
116
|
+
if "." in file.stem:
|
117
|
+
target = dst_path / f"{(file.stem).replace('.', '/')}{suffix}"
|
118
|
+
else:
|
119
|
+
target = dst_path / file.stem / f"__init__{suffix}"
|
120
|
+
|
121
|
+
reader.write_file(target)
|
122
|
+
del reader
|
File without changes
|
{micropython_stubber-1.25.0.post3.dist-info → micropython_stubber-1.25.1.dist-info}/entry_points.txt
RENAMED
File without changes
|