micropython-stubber 1.25.0.post2__py3-none-any.whl → 1.25.0rc5__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.post2.dist-info → micropython_stubber-1.25.0rc5.dist-info}/METADATA +3 -3
- {micropython_stubber-1.25.0.post2.dist-info → micropython_stubber-1.25.0rc5.dist-info}/RECORD +9 -9
- stubber/codemod/visitors/type_helpers.py +16 -7
- stubber/minify.py +30 -9
- stubber/publish/package.py +12 -3
- stubber/publish/stubpackage.py +7 -12
- {micropython_stubber-1.25.0.post2.dist-info → micropython_stubber-1.25.0rc5.dist-info}/LICENSE +0 -0
- {micropython_stubber-1.25.0.post2.dist-info → micropython_stubber-1.25.0rc5.dist-info}/WHEEL +0 -0
- {micropython_stubber-1.25.0.post2.dist-info → micropython_stubber-1.25.0rc5.dist-info}/entry_points.txt +0 -0
{micropython_stubber-1.25.0.post2.dist-info → micropython_stubber-1.25.0rc5.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.0rc5
|
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,12 +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 (>=1.25.0)
|
28
|
+
Requires-Dist: mpflash (>=1.25.0.rc2)
|
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
34
|
Requires-Dist: poetry (>=2.0.1,<3.0.0)
|
35
35
|
Requires-Dist: pydeps (==3.0.1)
|
36
36
|
Requires-Dist: pygithub (>=2.1.1,<3.0.0)
|
{micropython_stubber-1.25.0.post2.dist-info → micropython_stubber-1.25.0rc5.dist-info}/RECORD
RENAMED
@@ -34,7 +34,7 @@ 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
40
|
stubber/commands/cli.py,sha256=HY4CqB0PPTmzew2sABNsHeNKDPblcGzzbmvtF46oVsU,1556
|
@@ -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,11 +74,11 @@ 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
84
|
stubber/rst/lookup.py,sha256=8nnU8MZPMEUKhuZ_tbtV_eh6C7K4A1RN1wemsCodTtw,26003
|
@@ -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.0rc5.dist-info/entry_points.txt,sha256=JoR8NWh8t6pbDyn0WOMCIfRfDQAOGxqbOgJWuxv3Cxw,116
|
107
|
+
micropython_stubber-1.25.0rc5.dist-info/LICENSE,sha256=Fx9qrL45ayRXgH6QzttboqZEjKXms0w1t_b_nkOqYCU,1572
|
108
|
+
micropython_stubber-1.25.0rc5.dist-info/METADATA,sha256=HSHM20J6KSOBYrvb6778ZwSulnnLtL5y10Myam8LeTQ,19991
|
109
|
+
micropython_stubber-1.25.0rc5.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
|
110
|
+
micropython_stubber-1.25.0rc5.dist-info/RECORD,,
|
@@ -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/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": "-",
|
{micropython_stubber-1.25.0.post2.dist-info → micropython_stubber-1.25.0rc5.dist-info}/LICENSE
RENAMED
File without changes
|
{micropython_stubber-1.25.0.post2.dist-info → micropython_stubber-1.25.0rc5.dist-info}/WHEEL
RENAMED
File without changes
|
File without changes
|