micropython-stubber 1.17.5__py3-none-any.whl → 1.19.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.
Files changed (74) hide show
  1. {micropython_stubber-1.17.5.dist-info → micropython_stubber-1.19.0.dist-info}/METADATA +7 -6
  2. {micropython_stubber-1.17.5.dist-info → micropython_stubber-1.19.0.dist-info}/RECORD +71 -52
  3. mpflash/README.md +22 -3
  4. mpflash/libusb_flash.ipynb +203 -0
  5. mpflash/mpflash/ask_input.py +234 -0
  6. mpflash/mpflash/cli_download.py +107 -0
  7. mpflash/mpflash/cli_flash.py +165 -0
  8. mpflash/mpflash/cli_group.py +41 -8
  9. mpflash/mpflash/cli_list.py +41 -0
  10. mpflash/mpflash/cli_main.py +13 -8
  11. mpflash/mpflash/common.py +33 -122
  12. mpflash/mpflash/config.py +9 -0
  13. mpflash/mpflash/{downloader.py → download.py} +112 -120
  14. mpflash/mpflash/downloaded.py +108 -0
  15. mpflash/mpflash/errors.py +5 -0
  16. mpflash/mpflash/flash.py +69 -0
  17. mpflash/mpflash/flash_esp.py +17 -23
  18. mpflash/mpflash/flash_stm32.py +16 -113
  19. mpflash/mpflash/flash_stm32_cube.py +111 -0
  20. mpflash/mpflash/flash_stm32_dfu.py +101 -0
  21. mpflash/mpflash/flash_uf2.py +8 -8
  22. mpflash/mpflash/flash_uf2_linux.py +25 -12
  23. mpflash/mpflash/flash_uf2_windows.py +24 -12
  24. mpflash/mpflash/list.py +34 -37
  25. mpflash/mpflash/logger.py +12 -13
  26. mpflash/mpflash/mpboard_id/__init__.py +96 -0
  27. mpflash/mpflash/mpboard_id/board_id.py +63 -0
  28. mpflash/mpflash/mpboard_id/board_info.csv +2213 -0
  29. mpflash/mpflash/mpboard_id/board_info.json +19910 -0
  30. mpflash/mpflash/mpremoteboard/__init__.py +208 -0
  31. mpflash/mpflash/mpremoteboard/mpy_fw_info.py +141 -0
  32. {stubber/bulk → mpflash/mpflash/mpremoteboard}/runner.py +22 -5
  33. mpflash/mpflash/vendor/dfu.py +164 -0
  34. mpflash/mpflash/vendor/pydfu.py +605 -0
  35. mpflash/mpflash/vendor/readme.md +3 -0
  36. mpflash/mpflash/vendor/versions.py +113 -0
  37. mpflash/mpflash/worklist.py +147 -0
  38. mpflash/poetry.lock +411 -595
  39. mpflash/pyproject.toml +24 -8
  40. mpflash/stm32_udev_rules.md +63 -0
  41. stubber/__init__.py +1 -1
  42. stubber/basicgit.py +1 -0
  43. stubber/board/createstubs.py +10 -4
  44. stubber/board/createstubs_db.py +11 -5
  45. stubber/board/createstubs_db_min.py +61 -58
  46. stubber/board/createstubs_db_mpy.mpy +0 -0
  47. stubber/board/createstubs_mem.py +11 -5
  48. stubber/board/createstubs_mem_min.py +56 -53
  49. stubber/board/createstubs_mem_mpy.mpy +0 -0
  50. stubber/board/createstubs_min.py +54 -51
  51. stubber/board/createstubs_mpy.mpy +0 -0
  52. stubber/bulk/mcu_stubber.py +9 -5
  53. stubber/codemod/_partials/db_main.py +14 -25
  54. stubber/codemod/_partials/lvgl_main.py +2 -2
  55. stubber/codemod/board.py +10 -3
  56. stubber/commands/clone_cmd.py +7 -7
  57. stubber/commands/config_cmd.py +3 -0
  58. stubber/freeze/get_frozen.py +0 -2
  59. stubber/publish/candidates.py +1 -1
  60. stubber/publish/package.py +1 -1
  61. stubber/publish/pathnames.py +1 -1
  62. stubber/publish/stubpackage.py +1 -0
  63. stubber/rst/lookup.py +1 -1
  64. stubber/tools/manifestfile.py +5 -3
  65. stubber/utils/config.py +26 -36
  66. stubber/utils/repos.py +2 -2
  67. stubber/utils/versions.py +1 -0
  68. mpflash/mpflash/flasher.py +0 -287
  69. stubber/bulk/board_id.py +0 -40
  70. stubber/bulk/mpremoteboard.py +0 -141
  71. {micropython_stubber-1.17.5.dist-info → micropython_stubber-1.19.0.dist-info}/LICENSE +0 -0
  72. {micropython_stubber-1.17.5.dist-info → micropython_stubber-1.19.0.dist-info}/WHEEL +0 -0
  73. {micropython_stubber-1.17.5.dist-info → micropython_stubber-1.19.0.dist-info}/entry_points.txt +0 -0
  74. /mpflash/mpflash/{uf2_boardid.py → flash_uf2_boardid.py} +0 -0
mpflash/pyproject.toml CHANGED
@@ -1,11 +1,11 @@
1
1
  [tool.poetry]
2
2
  name = "mpflash"
3
- version = "0.2.0"
4
- description = "Download and flashing tool for MicroPython firmwares"
3
+ version = "0.6.0"
4
+ description = "Flash and download tool for MicroPython firmwares"
5
5
  authors = ["Jos Verlinde <jos_verlinde@hotmail.com>"]
6
6
  license = "MIT"
7
7
  readme = "README.md"
8
- keywords = ["MicroPython", "firmware", "flashing", "download"]
8
+ keywords = ["MicroPython", "firmware", "flash", "download", "UF2", "esptool"]
9
9
  homepage = "https://github.com/Josverl/micropython-stubber/blob/main/src/mpflash/README.md"
10
10
  repository = "https://github.com/Josverl/micropython-stubber"
11
11
  classifiers = [
@@ -18,7 +18,7 @@ classifiers = [
18
18
  mpflash = "mpflash.cli_main:mpflash"
19
19
 
20
20
  [tool.poetry.dependencies]
21
- python = ">=3.9,<3.12"
21
+ python = ">=3.8.1,<4.0"
22
22
  requests = "^2.31.0"
23
23
  beautifulsoup4 = "^4.12.3"
24
24
  loguru = "^0.7.2"
@@ -27,14 +27,30 @@ jsonlines = "^4.0.0"
27
27
  bincopy = "^20.0.0"
28
28
  strip-ansi = "^0.1.1"
29
29
  rich-click = "^1.7.3"
30
- # micropython-stubber = {git = "https://github.com/josverl/micropython-stubber.git", rev = "action_board_stubber"}
31
- micropython-stubber = "1.17.4"
32
30
  psutil = "^5.9.8"
33
31
  blkinfo = "^0.2.0"
34
32
  pygithub = "^2.1.1"
33
+ platformdirs = "^4.2.0"
34
+ pyusb = "^1.2.1"
35
+ packaging = "23.2"
36
+ tenacity = "8.2.3"
37
+ mpremote = "^1.22.0"
38
+ inquirer = "^3.2.4"
39
+ libusb = {version = "^1.0.27", platform = "win32"}
40
+
41
+ [tool.poetry.group.test]
42
+ optional = true
43
+ [tool.poetry.group.test.dependencies]
44
+ coverage = ">=6.4.3,<8.0.0"
45
+ pytest = "^7.1.2"
46
+ pytest-github-actions-annotate-failures = ">=0.1.7,<0.3.0"
47
+ pytest-json-report = "^1.5.0"
48
+ pytest-metadata = ">=2.0.2,<4.0.0"
49
+ pytest-mock = "^3.10.0"
50
+ mock = "^4.0.3"
51
+ distro = "^1.8.0"
52
+ fasteners = "^0.19"
35
53
 
36
- [tool.poetry.group.dev.dependencies]
37
- types-beautifulsoup4 = "^4.12.0.20240106"
38
54
 
39
55
  [build-system]
40
56
  requires = ["poetry-core"]
@@ -0,0 +1,63 @@
1
+ ## Linux permissions for usb devices
2
+
3
+ In order to flash the firmware to the board, you need to have the correct permissions to access the USB devices.
4
+ The details will depend on the specific USB device and the operating system you are using.
5
+
6
+ You can use the following udev rules to give non-root users access to the USB devices.
7
+
8
+ File: `/etc/udev/rules.d/65-mpflash.rules`
9
+ ```bash
10
+ # allow non-root users to access to stm32 device in dfu mode (bootloader)
11
+ SUBSYSTEM=="usb", ACTION=="add", ATTR{product}=="STM32 BOOTLOADER", GROUP="plugdev", MODE="0660"
12
+ ```
13
+ reload the udev rules with the following command:
14
+ ```bash
15
+ sudo udevadm control --reload
16
+ ```
17
+ Unplug and replug the usb device to apply the new rules.
18
+
19
+
20
+ ## to check
21
+ Enter the stm32 bootloader mode
22
+ ``` bash
23
+ mpremote bootloader
24
+ ```
25
+
26
+
27
+ List usb devices
28
+ ```bash
29
+ (.venv) jos@jvnuc:~/projects/micropython-stubber$ lsusb -vv -t
30
+ /: Bus 02.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/6p, 10000M
31
+ ID 1d6b:0003 Linux Foundation 3.0 root hub
32
+ /sys/bus/usb/devices/usb2 /dev/bus/usb/002/001
33
+ /: Bus 01.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/12p, 480M
34
+ ID 1d6b:0002 Linux Foundation 2.0 root hub
35
+ /sys/bus/usb/devices/usb1 /dev/bus/usb/001/001
36
+ |__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/4p, 12M
37
+ ID 0a05:7211 Unknown Manufacturer hub
38
+ /sys/bus/usb/devices/1-1 /dev/bus/usb/001/002
39
+ |__ Port 1: Dev 4, If 0, Class=Hub, Driver=hub/4p, 12M
40
+ ID 0a05:7211 Unknown Manufacturer hub
41
+ /sys/bus/usb/devices/1-1.1 /dev/bus/usb/001/004
42
+ |__ Port 2: Dev 22, If 0, Class=Application Specific Interface, Driver=, 12M
43
+ ID 0483:df11 STMicroelectronics STM Device in DFU Mode
44
+ /sys/bus/usb/devices/1-1.2 /dev/bus/usb/001/022
45
+ |__ Port 10: Dev 3, If 0, Class=Wireless, Driver=btusb, 12M
46
+ ID 8087:0aaa Intel Corp. Bluetooth 9460/9560 Jefferson Peak (JfP)
47
+ /sys/bus/usb/devices/1-10 /dev/bus/usb/001/003
48
+ |__ Port 10: Dev 3, If 1, Class=Wireless, Driver=btusb, 12M
49
+ ID 8087:0aaa Intel Corp. Bluetooth 9460/9560 Jefferson Peak (JfP)
50
+ /sys/bus/usb/devices/1-10 /dev/bus/usb/001/003
51
+ ```
52
+ Lookup the stm32 device device path ( /dev/bus/usb/001/022),
53
+ and check if the group `plugdev` is granted access using `ll`
54
+ ```bash
55
+ (.venv) jos@jvnuc:~/projects/micropython-stubber$ ll /dev/bus/usb/001/022
56
+ crw-rw-r-- 1 root plugdev 189, 21 mrt 11 22:38 /dev/bus/usb/001/022
57
+ ```
58
+
59
+ Check `groups` to see if user is in plugdev group
60
+ ```
61
+ (.venv) jos@jvnuc:~/projects/micropython-stubber$ groups
62
+ jos adm disk dialout cdrom sudo dip plugdev kvm lpadmin lxd sambashare usb
63
+ ```
stubber/__init__.py CHANGED
@@ -1,3 +1,3 @@
1
1
  """get the version"""
2
2
 
3
- __version__ = "1.17.5"
3
+ __version__ = "1.19.0"
stubber/basicgit.py CHANGED
@@ -3,6 +3,7 @@ Simple Git module, where needed via powershell
3
3
 
4
4
  Some of the functions are based on the PyGithub module
5
5
  """
6
+
6
7
  import os
7
8
  import subprocess
8
9
  from pathlib import Path
@@ -2,7 +2,7 @@
2
2
  Create stubs for (all) modules on a MicroPython board
3
3
  """
4
4
 
5
- # Copyright (c) 2019-2023 Jos Verlinde
5
+ # Copyright (c) 2019-2024 Jos Verlinde
6
6
 
7
7
  import gc
8
8
  import os
@@ -24,7 +24,7 @@ try:
24
24
  except ImportError:
25
25
  from ucollections import OrderedDict # type: ignore
26
26
 
27
- __version__ = "v1.17.5"
27
+ __version__ = "v1.19.0"
28
28
  ENOENT = 2
29
29
  _MAX_CLASS_LEVEL = 2 # Max class nesting
30
30
  LIBS = ["lib", "/lib", "/sd/lib", "/flash/lib", "."]
@@ -77,7 +77,7 @@ class Stubber:
77
77
  if os.uname().release == "1.13.0" and os.uname().version < "v1.13-103": # type: ignore
78
78
  raise NotImplementedError("MicroPython 1.13.0 cannot be stubbed")
79
79
  except AttributeError:
80
- pass
80
+ pass # Allow testing on CPython 3.11
81
81
  self.info = _info()
82
82
  log.info("Port: {}".format(self.info["port"]))
83
83
  log.info("Board: {}".format(self.info["board"]))
@@ -506,9 +506,15 @@ def _build(s):
506
506
 
507
507
 
508
508
  def _info(): # type:() -> dict[str, str]
509
+ try:
510
+ fam = sys.implementation[0] # type: ignore
511
+ except TypeError:
512
+ # testing on CPython 3.11
513
+ fam = sys.implementation.name
514
+
509
515
  info = OrderedDict(
510
516
  {
511
- "family": sys.implementation[0], # type: ignore
517
+ "family": fam,
512
518
  "version": "",
513
519
  "build": "",
514
520
  "ver": "",
@@ -18,10 +18,10 @@ 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.17.5
21
+ This variant was generated from createstubs.py by micropython-stubber v1.19.0
22
22
  """
23
23
 
24
- # Copyright (c) 2019-2023 Jos Verlinde
24
+ # Copyright (c) 2019-2024 Jos Verlinde
25
25
 
26
26
  import gc
27
27
  import os
@@ -43,7 +43,7 @@ try:
43
43
  except ImportError:
44
44
  from ucollections import OrderedDict # type: ignore
45
45
 
46
- __version__ = "v1.17.5"
46
+ __version__ = "v1.19.0"
47
47
  ENOENT = 2
48
48
  _MAX_CLASS_LEVEL = 2 # Max class nesting
49
49
  LIBS = ["lib", "/lib", "/sd/lib", "/flash/lib", "."]
@@ -96,7 +96,7 @@ class Stubber:
96
96
  if os.uname().release == "1.13.0" and os.uname().version < "v1.13-103": # type: ignore
97
97
  raise NotImplementedError("MicroPython 1.13.0 cannot be stubbed")
98
98
  except AttributeError:
99
- pass
99
+ pass # Allow testing on CPython 3.11
100
100
  self.info = _info()
101
101
  log.info("Port: {}".format(self.info["port"]))
102
102
  log.info("Board: {}".format(self.info["board"]))
@@ -519,9 +519,15 @@ def _build(s):
519
519
 
520
520
 
521
521
  def _info(): # type:() -> dict[str, str]
522
+ try:
523
+ fam = sys.implementation[0] # type: ignore
524
+ except TypeError:
525
+ # testing on CPython 3.11
526
+ fam = sys.implementation.name
527
+
522
528
  info = OrderedDict(
523
529
  {
524
- "family": sys.implementation[0], # type: ignore
530
+ "family": fam,
525
531
  "version": "",
526
532
  "build": "",
527
533
  "ver": "",
@@ -8,19 +8,19 @@ w='float'
8
8
  v='int'
9
9
  u='micropython'
10
10
  t='stubber'
11
- s=TypeError
12
- r=Exception
13
- q=KeyError
14
- p=sorted
15
- o=MemoryError
16
- n=NotImplementedError
17
- j=',\n'
18
- i='modules.json'
19
- h='{}/{}'
20
- g='w'
21
- f='dict'
22
- e='list'
23
- d='tuple'
11
+ s=Exception
12
+ r=KeyError
13
+ q=sorted
14
+ p=MemoryError
15
+ o=NotImplementedError
16
+ k=',\n'
17
+ j='modules.json'
18
+ i='{}/{}'
19
+ h='w'
20
+ g='dict'
21
+ f='list'
22
+ e='tuple'
23
+ d=TypeError
24
24
  c=str
25
25
  b=repr
26
26
  W='-preview'
@@ -49,9 +49,9 @@ try:from ujson import dumps
49
49
  except:from json import dumps
50
50
  try:from machine import reset
51
51
  except O:pass
52
- try:from collections import OrderedDict as k
53
- except O:from ucollections import OrderedDict as k
54
- __version__='v1.17.5'
52
+ try:from collections import OrderedDict as l
53
+ except O:from ucollections import OrderedDict as l
54
+ __version__='v1.19.0'
55
55
  A3=2
56
56
  A4=2
57
57
  A5=['lib','/lib','/sd/lib','/flash/lib',J]
@@ -73,7 +73,7 @@ class Stubber:
73
73
  def __init__(B,path=E,firmware_id=E):
74
74
  C=firmware_id
75
75
  try:
76
- if os.uname().release=='1.13.0'and os.uname().version<'v1.13-103':raise n('MicroPython 1.13.0 cannot be stubbed')
76
+ if os.uname().release=='1.13.0'and os.uname().version<'v1.13-103':raise o('MicroPython 1.13.0 cannot be stubbed')
77
77
  except I:pass
78
78
  B.info=_info();A.info('Port: {}'.format(B.info[K]));A.info('Board: {}'.format(B.info[U]));F.collect()
79
79
  if C:B._fwid=C.lower()
@@ -95,15 +95,15 @@ class Stubber:
95
95
  D=getattr(H,A)
96
96
  try:E=b(type(D)).split("'")[1]
97
97
  except T:E=B
98
- if E in{v,w,x,y,d,e,f}:G=1
98
+ if E in{v,w,x,y,e,f,g}:G=1
99
99
  elif E in{z,A0}:G=2
100
100
  elif E in'class':G=3
101
101
  else:G=4
102
102
  C.append((A,b(D),b(type(D)),D,G))
103
103
  except I as J:K.append("Couldn't get attribute '{}' from object '{}', Err: {}".format(A,H,J))
104
- except o as J:S('MemoryError: {}'.format(J));sleep(1);reset()
105
- C=p([A for A in C if not A[0].startswith('__')],key=lambda x:x[4]);F.collect();return C,K
106
- def add_modules(A,modules):A.modules=p(set(A.modules)|set(modules))
104
+ except p as J:S('MemoryError: {}'.format(J));sleep(1);reset()
105
+ C=q([A for A in C if not A[0].startswith('__')],key=lambda x:x[4]);F.collect();return C,K
106
+ def add_modules(A,modules):A.modules=q(set(A.modules)|set(modules))
107
107
  def create_all_stubs(B):
108
108
  A.info('Start micropython-stubber {} on {}'.format(__version__,B._fwid));B.report_start();F.collect()
109
109
  for C in B.modules:B.create_one_stub(C)
@@ -125,18 +125,18 @@ class Stubber:
125
125
  try:N=__import__(C,E,E,'*');Q=F.mem_free();A.info('Stub module: {:<25} to file: {:<70} mem:{:>5}'.format(C,L,Q))
126
126
  except O:return H
127
127
  X(I)
128
- with M(I,g)as P:S=c(K.info).replace('OrderedDict(',B).replace('})','}');T='"""\nModule: \'{0}\' on {1}\n"""\n# MCU: {2}\n# Stubber: {3}\n'.format(C,K._fwid,S,__version__);P.write(T);P.write('from __future__ import annotations\nfrom typing import Any, Generator\nfrom _typeshed import Incomplete\n\n');K.write_object_stub(P,N,C,B)
128
+ with M(I,h)as P:S=c(K.info).replace('OrderedDict(',B).replace('})','}');T='"""\nModule: \'{0}\' on {1}\n"""\n# MCU: {2}\n# Stubber: {3}\n'.format(C,K._fwid,S,__version__);P.write(T);P.write('from __future__ import annotations\nfrom typing import Any, Generator\nfrom _typeshed import Incomplete\n\n');K.write_object_stub(P,N,C,B)
129
129
  K.report_add(C,I)
130
130
  if C not in{'os','sys','logging','gc'}:
131
131
  try:del N
132
- except(D,q):A.warning('could not del new_module')
132
+ except(D,r):A.warning('could not del new_module')
133
133
  F.collect();return R
134
134
  def write_object_stub(L,fp,object_expr,obj_name,indent,in_class=0):
135
135
  Z=' at ...>';Y='generator';X='{0}{1}: {3} = {2}\n';W='bound_method';V='Incomplete';O=in_class;N='Exception';M=object_expr;K=' at ';J=fp;D=indent;F.collect()
136
136
  if M in L.problematic:A.warning('SKIPPING problematic module:{}'.format(M));return
137
137
  a,Q=L.get_obj_attributes(M)
138
138
  if Q:A.error(Q)
139
- for(E,H,I,b,g)in a:
139
+ for(E,H,I,b,d)in a:
140
140
  if E in['classmethod','staticmethod','BaseException',N]:continue
141
141
  if E[0].isdigit():A.warning('NameError: invalid name {}'.format(E));continue
142
142
  if I=="<class 'type'>"and P(D)<=A4*4:
@@ -155,7 +155,7 @@ class Stubber:
155
155
  elif I.startswith("<class '"):
156
156
  G=I[8:-2];C=B
157
157
  if G in(x,v,w,y,'bytearray','bytes'):C=X.format(D,E,H,G)
158
- elif G in(f,e,d):c={f:'{}',e:'[]',d:'()'};C=X.format(D,E,c[G],G)
158
+ elif G in(g,f,e):c={g:'{}',f:'[]',e:'()'};C=X.format(D,E,c[G],G)
159
159
  elif G in('object','set','frozenset','Pin',Y):
160
160
  if G==Y:G='Generator'
161
161
  C='{0}{1}: {2} ## = {4}\n'.format(D,E,G,I,H)
@@ -177,26 +177,26 @@ class Stubber:
177
177
  try:os.stat(path);F=os.listdir(path)
178
178
  except(D,I):return
179
179
  for G in F:
180
- B=h.format(path,G)
180
+ B=i.format(path,G)
181
181
  try:os.remove(B)
182
182
  except D:
183
183
  try:C.clean(B);os.rmdir(B)
184
184
  except D:pass
185
- def report_start(B,filename=i):
186
- H='firmware';B._json_name=h.format(B.path,filename);B._json_first=R;X(B._json_name);A.info('Report file: {}'.format(B._json_name));F.collect()
185
+ def report_start(B,filename=j):
186
+ H='firmware';B._json_name=i.format(B.path,filename);B._json_first=R;X(B._json_name);A.info('Report file: {}'.format(B._json_name));F.collect()
187
187
  try:
188
- with M(B._json_name,g)as G:G.write('{');G.write(dumps({H:B.info})[1:-1]);G.write(j);G.write(dumps({t:{C:__version__},'stubtype':H})[1:-1]);G.write(j);G.write('"modules" :[\n')
188
+ with M(B._json_name,h)as G:G.write('{');G.write(dumps({H:B.info})[1:-1]);G.write(k);G.write(dumps({t:{C:__version__},'stubtype':H})[1:-1]);G.write(k);G.write('"modules" :[\n')
189
189
  except D as I:A.error(A1);B._json_name=E;raise I
190
190
  def report_add(B,module_name,stub_file):
191
- if not B._json_name:raise r(A2)
191
+ if not B._json_name:raise s(A2)
192
192
  try:
193
193
  with M(B._json_name,'a')as C:
194
- if not B._json_first:C.write(j)
194
+ if not B._json_first:C.write(k)
195
195
  else:B._json_first=H
196
196
  E='{{"module": "{}", "file": "{}"}}'.format(module_name,stub_file.replace('\\',G));C.write(E)
197
197
  except D:A.error(A1)
198
198
  def report_end(B):
199
- if not B._json_name:raise r(A2)
199
+ if not B._json_name:raise s(A2)
200
200
  with M(B._json_name,'a')as C:C.write('\n]}')
201
201
  A.info('Path: {}'.format(B.path))
202
202
  def X(path):
@@ -221,13 +221,16 @@ def Y(s):
221
221
  if not W in s:return B
222
222
  A=s.split(W)[1].split(J)[1];return A
223
223
  def _info():
224
- Z='ev3-pybricks';X='pycom';V='pycopy';S='unix';R='win32';P='arch';M='cpu';L='ver';F='mpy';D='build';A=k({Q:sys.implementation[0],C:B,D:B,L:B,K:sys.platform,U:'UNKNOWN',M:B,F:B,P:B})
224
+ a='ev3-pybricks';Z='pycom';X='pycopy';V='unix';S='win32';R='arch';P='cpu';M='ver';F='mpy';D='build'
225
+ try:H=sys.implementation[0]
226
+ except d:H=sys.implementation.name
227
+ A=l({Q:H,C:B,D:B,M:B,K:sys.platform,U:'UNKNOWN',P:B,F:B,R:B})
225
228
  if A[K].startswith('pyb'):A[K]='stm32'
226
- elif A[K]==R:A[K]='windows'
227
- elif A[K]=='linux':A[K]=S
229
+ elif A[K]==S:A[K]='windows'
230
+ elif A[K]=='linux':A[K]=V
228
231
  try:A[C]=A6(sys.implementation.version)
229
232
  except I:pass
230
- try:H=sys.implementation._machine if'_machine'in N(sys.implementation)else os.uname().machine;A[U]=H;A[M]=H.split('with')[-1].strip();A[F]=sys.implementation._mpy if'_mpy'in N(sys.implementation)else sys.implementation.mpy if F in N(sys.implementation)else B
233
+ try:J=sys.implementation._machine if'_machine'in N(sys.implementation)else os.uname().machine;A[U]=J;A[P]=J.split('with')[-1].strip();A[F]=sys.implementation._mpy if'_mpy'in N(sys.implementation)else sys.implementation.mpy if F in N(sys.implementation)else B
231
234
  except(I,T):pass
232
235
  A[U]=A7()
233
236
  try:
@@ -235,23 +238,23 @@ def _info():
235
238
  A[D]=Y(os.uname()[3])
236
239
  if not A[D]:A[D]=Y(os.uname()[2])
237
240
  elif C in N(sys):A[D]=Y(sys.version)
238
- except(I,T,s):pass
239
- if A[C]==B and sys.platform not in(S,R):
240
- try:a=os.uname();A[C]=a.release
241
- except(T,I,s):pass
242
- for(b,c,d)in[(V,V,'const'),(X,X,'FAT'),(Z,'pybricks.hubs','EV3Brick')]:
243
- try:e=__import__(c,E,E,d);A[Q]=b;del e;break
244
- except(O,q):pass
245
- if A[Q]==Z:A['release']='2.0.0'
241
+ except(I,T,d):pass
242
+ if A[C]==B and sys.platform not in(V,S):
243
+ try:b=os.uname();A[C]=b.release
244
+ except(T,I,d):pass
245
+ for(c,e,f)in[(X,X,'const'),(Z,Z,'FAT'),(a,'pybricks.hubs','EV3Brick')]:
246
+ try:g=__import__(e,E,E,f);A[Q]=c;del g;break
247
+ except(O,r):pass
248
+ if A[Q]==a:A['release']='2.0.0'
246
249
  if A[Q]==u:
247
250
  A[C]
248
251
  if A[C]and A[C].endswith('.0')and A[C]>='1.10.0'and A[C]<='1.19.9':A[C]=A[C][:-2]
249
252
  if F in A and A[F]:
250
- G=int(A[F]);J=[E,'x86','x64','armv6','armv6m','armv7m','armv7em','armv7emsp','armv7emdp','xtensa','xtensawin'][G>>10]
251
- if J:A[P]=J
253
+ G=int(A[F]);L=[E,'x86','x64','armv6','armv6m','armv7m','armv7em','armv7emsp','armv7emdp','xtensa','xtensawin'][G>>10]
254
+ if L:A[R]=L
252
255
  A[F]='v{}.{}'.format(G&255,G>>8&3)
253
256
  if A[D]and not A[C].endswith(W):A[C]=A[C]+W
254
- A[L]=f"{A[C]}-{A[D]}"if A[D]else f"{A[C]}";return A
257
+ A[M]=f"{A[C]}-{A[D]}"if A[D]else f"{A[C]}";return A
255
258
  def A6(version):
256
259
  A=version;B=J.join([c(A)for A in A[:3]])
257
260
  if P(A)>3 and A[3]:B+=V+A[3]
@@ -273,18 +276,18 @@ def Z(filename):
273
276
  if os.stat(filename)[0]>>14:return R
274
277
  return H
275
278
  except D:return H
276
- def l():S("-p, --path path to store the stubs in, defaults to '.'");sys.exit(1)
279
+ def m():S("-p, --path path to store the stubs in, defaults to '.'");sys.exit(1)
277
280
  def read_path():
278
281
  path=B
279
282
  if P(sys.argv)==3:
280
283
  A=sys.argv[1].lower()
281
284
  if A in('--path','-p'):path=sys.argv[2]
282
- else:l()
283
- elif P(sys.argv)==2:l()
285
+ else:m()
286
+ elif P(sys.argv)==2:m()
284
287
  return path
285
- def m():
286
- try:A=bytes('abc',encoding='utf8');B=m.__module__;return H
287
- except(n,I):return R
288
+ def n():
289
+ try:A=bytes('abc',encoding='utf8');B=n.__module__;return H
290
+ except(o,I):return R
288
291
  a='modulelist.done'
289
292
  def A8(skip=0):
290
293
  for E in A5:
@@ -303,7 +306,7 @@ def A8(skip=0):
303
306
  break
304
307
  except D:pass
305
308
  def A9(done):
306
- with M(a,g)as A:A.write(c(done)+'\n')
309
+ with M(a,h)as A:A.write(c(done)+'\n')
307
310
  def AA():
308
311
  A=0
309
312
  try:
@@ -315,14 +318,14 @@ def main():
315
318
  if C:A.info('Continue from last run')
316
319
  else:A.info('Starting new run')
317
320
  stubber=Stubber(path=read_path());B=0
318
- if not C:stubber.clean();stubber.report_start(i)
319
- else:B=AA();stubber._json_name=h.format(stubber.path,i)
321
+ if not C:stubber.clean();stubber.report_start(j)
322
+ else:B=AA();stubber._json_name=i.format(stubber.path,j)
320
323
  for E in A8(B):
321
324
  try:stubber.create_one_stub(E)
322
- except o:D.reset()
325
+ except p:D.reset()
323
326
  F.collect();B+=1;A9(B)
324
327
  S('All modules have been processed, Finalizing report');stubber.report_end()
325
- if __name__=='__main__'or m():
328
+ if __name__=='__main__'or n():
326
329
  if not Z('no_auto_stubber.txt'):
327
330
  try:F.threshold(4*1024);F.enable()
328
331
  except BaseException:pass
Binary file
@@ -9,10 +9,10 @@
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.17.5
12
+ This variant was generated from createstubs.py by micropython-stubber v1.19.0
13
13
  """
14
14
 
15
- # Copyright (c) 2019-2023 Jos Verlinde
15
+ # Copyright (c) 2019-2024 Jos Verlinde
16
16
 
17
17
  import gc
18
18
  import os
@@ -34,7 +34,7 @@ try:
34
34
  except ImportError:
35
35
  from ucollections import OrderedDict # type: ignore
36
36
 
37
- __version__ = "v1.17.5"
37
+ __version__ = "v1.19.0"
38
38
  ENOENT = 2
39
39
  _MAX_CLASS_LEVEL = 2 # Max class nesting
40
40
  LIBS = ["lib", "/lib", "/sd/lib", "/flash/lib", "."]
@@ -87,7 +87,7 @@ class Stubber:
87
87
  if os.uname().release == "1.13.0" and os.uname().version < "v1.13-103": # type: ignore
88
88
  raise NotImplementedError("MicroPython 1.13.0 cannot be stubbed")
89
89
  except AttributeError:
90
- pass
90
+ pass # Allow testing on CPython 3.11
91
91
  self.info = _info()
92
92
  log.info("Port: {}".format(self.info["port"]))
93
93
  log.info("Board: {}".format(self.info["board"]))
@@ -510,9 +510,15 @@ def _build(s):
510
510
 
511
511
 
512
512
  def _info(): # type:() -> dict[str, str]
513
+ try:
514
+ fam = sys.implementation[0] # type: ignore
515
+ except TypeError:
516
+ # testing on CPython 3.11
517
+ fam = sys.implementation.name
518
+
513
519
  info = OrderedDict(
514
520
  {
515
- "family": sys.implementation[0], # type: ignore
521
+ "family": fam,
516
522
  "version": "",
517
523
  "build": "",
518
524
  "ver": "",