micropython-stubber 1.13.6__py3-none-any.whl → 1.13.8__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 (33) hide show
  1. {micropython_stubber-1.13.6.dist-info → micropython_stubber-1.13.8.dist-info}/METADATA +1 -1
  2. {micropython_stubber-1.13.6.dist-info → micropython_stubber-1.13.8.dist-info}/RECORD +32 -32
  3. stubber/__init__.py +3 -2
  4. stubber/basicgit.py +10 -7
  5. stubber/board/createstubs.py +4 -3
  6. stubber/board/createstubs_db.py +5 -4
  7. stubber/board/createstubs_db_min.py +33 -33
  8. stubber/board/createstubs_db_mpy.mpy +0 -0
  9. stubber/board/createstubs_info.py +906 -0
  10. stubber/board/createstubs_lvgl.py +5 -4
  11. stubber/board/createstubs_lvgl_min.py +41 -41
  12. stubber/board/createstubs_lvgl_mpy.mpy +0 -0
  13. stubber/board/createstubs_mem.py +5 -4
  14. stubber/board/createstubs_mem_min.py +48 -48
  15. stubber/board/createstubs_mem_mpy.mpy +0 -0
  16. stubber/board/createstubs_min.py +41 -41
  17. stubber/board/createstubs_mpy.mpy +0 -0
  18. stubber/codemod/board.py +1 -1
  19. stubber/commands/cli.py +1 -1
  20. stubber/commands/switch_cmd.py +8 -1
  21. stubber/data/micropython_tags.csv +1 -1
  22. stubber/get_cpython.py +3 -1
  23. stubber/publish/enums.py +8 -0
  24. stubber/publish/merge_docstubs.py +5 -3
  25. stubber/publish/publish.py +5 -3
  26. stubber/publish/stubpacker.py +7 -7
  27. stubber/rst/lookup.py +1 -1
  28. stubber/utils/manifest.py +1 -1
  29. stubber/utils/repos.py +22 -9
  30. stubber/utils/my_version.py +0 -15
  31. {micropython_stubber-1.13.6.dist-info → micropython_stubber-1.13.8.dist-info}/LICENSE +0 -0
  32. {micropython_stubber-1.13.6.dist-info → micropython_stubber-1.13.8.dist-info}/WHEEL +0 -0
  33. {micropython_stubber-1.13.6.dist-info → micropython_stubber-1.13.8.dist-info}/entry_points.txt +0 -0
@@ -20,12 +20,12 @@ Y='tuple'
20
20
  X='micropython'
21
21
  W=open
22
22
  V=repr
23
- T=KeyError
24
- S=IndexError
25
- R=dir
26
- Q=ImportError
27
- P=True
28
- O='_'
23
+ T='_'
24
+ S=KeyError
25
+ R=IndexError
26
+ Q=dir
27
+ P=ImportError
28
+ O=True
29
29
  N='family'
30
30
  M=len
31
31
  L='.'
@@ -41,10 +41,10 @@ B=''
41
41
  import gc as C,sys,uos as os
42
42
  from ujson import dumps as c
43
43
  try:from machine import reset
44
- except Q:pass
44
+ except P:pass
45
45
  try:from collections import OrderedDict as d
46
- except Q:from ucollections import OrderedDict as d
47
- __version__='v1.13.4'
46
+ except P:from ucollections import OrderedDict as d
47
+ __version__='v1.13.8'
48
48
  x=2
49
49
  y=2
50
50
  z=[L,'/lib','/sd/lib','/flash/lib','lib']
@@ -68,21 +68,21 @@ class Stubber:
68
68
  except F:J('error creating stub folder {}'.format(path))
69
69
  A.problematic=['upip','upysh','webrepl_setup','http_client','http_client_ssl','http_server','http_server_ssl'];A.excluded=['webrepl','_webrepl','port_diag','example_sub_led.py','example_pub_button.py'];A.modules=[]
70
70
  def get_obj_attributes(L,item_instance):
71
- H=item_instance;A=[];J=[]
72
- for D in R(H):
73
- if D.startswith(O):continue
71
+ H=item_instance;D=[];J=[]
72
+ for A in Q(H):
73
+ if A.startswith(T)and not A in L.modules:continue
74
74
  try:
75
- E=getattr(H,D)
75
+ E=getattr(H,A)
76
76
  try:F=V(type(E)).split("'")[1]
77
- except S:F=B
77
+ except R:F=B
78
78
  if F in{n,o,p,q,Y,Z,a}:G=1
79
79
  elif F in{r,s}:G=2
80
80
  elif F in'class':G=3
81
81
  else:G=4
82
- A.append((D,V(E),V(type(E)),E,G))
83
- except I as K:J.append("Couldn't get attribute '{}' from object '{}', Err: {}".format(D,H,K))
82
+ D.append((A,V(E),V(type(E)),E,G))
83
+ except I as K:J.append("Couldn't get attribute '{}' from object '{}', Err: {}".format(A,H,K))
84
84
  except MemoryError as K:sleep(1);reset()
85
- A=k([A for A in A if not A[0].startswith(O)],key=lambda x:x[4]);C.collect();return A,J
85
+ D=k([A for A in D if not A[0].startswith('__')],key=lambda x:x[4]);C.collect();return D,J
86
86
  def add_modules(A,modules):A.modules=k(set(A.modules)|set(modules))
87
87
  def create_all_stubs(A):
88
88
  C.collect()
@@ -97,27 +97,27 @@ class Stubber:
97
97
  C.collect();return D
98
98
  def create_module_stub(I,module_name,file_name=E):
99
99
  D=file_name;A=module_name
100
- if D is E:K=A.replace(L,O)+'.py';D=I.path+G+K
100
+ if D is E:K=A.replace(L,T)+'.py';D=I.path+G+K
101
101
  else:K=D.split(G)[-1]
102
102
  if G in A:A=A.replace(G,L)
103
103
  M=E
104
- try:M=__import__(A,E,E,'*');R=C.mem_free();J('Stub module: {:<25} to file: {:<70} mem:{:>5}'.format(A,K,R))
105
- except Q:return H
104
+ try:M=__import__(A,E,E,'*');Q=C.mem_free();J('Stub module: {:<25} to file: {:<70} mem:{:>5}'.format(A,K,Q))
105
+ except P:return H
106
106
  e(D)
107
- with W(D,'w')as N:S='"""\nModule: \'{0}\' on {1}\n"""\n# MCU: {2}\n# Stubber: {3}\n'.format(A,I._fwid,I.info,__version__);N.write(S);N.write('from typing import Any\n\n');I.write_object_stub(N,M,A,B)
107
+ with W(D,'w')as N:R='"""\nModule: \'{0}\' on {1}\n"""\n# MCU: {2}\n# Stubber: {3}\n'.format(A,I._fwid,I.info,__version__);N.write(R);N.write('from typing import Any\n\n');I.write_object_stub(N,M,A,B)
108
108
  I._report.append('{{"module": "{}", "file": "{}"}}'.format(A,D.replace('\\',G)))
109
109
  if A not in{'os',t,u,'gc'}:
110
110
  try:del M
111
- except (F,T):pass
111
+ except (F,S):pass
112
112
  try:del sys.modules[A]
113
- except T:pass
114
- C.collect();return P
113
+ except S:pass
114
+ C.collect();return O
115
115
  def write_object_stub(L,fp,object_expr,obj_name,indent,in_class=0):
116
116
  d='{0}{1} = {2} # type: {3}\n';c='bound_method';b='Any';Q=in_class;P=object_expr;O='Exception';H=fp;D=indent;C.collect()
117
117
  if P in L.problematic:return
118
118
  R,N=L.get_obj_attributes(P)
119
119
  if N:J(N)
120
- for (E,K,G,S,f) in R:
120
+ for (E,K,G,T,f) in R:
121
121
  if E in['classmethod','staticmethod','BaseException',O]:continue
122
122
  if E[0].isdigit():continue
123
123
  if G=="<class 'type'>"and M(D)<=y*4:
@@ -125,7 +125,7 @@ class Stubber:
125
125
  if V:U=O
126
126
  A='\n{}class {}({}):\n'.format(D,E,U)
127
127
  if V:A+=D+' ...\n';H.write(A);return
128
- H.write(A);L.write_object_stub(H,S,'{0}.{1}'.format(obj_name,E),D+' ',Q+1);A=D+' def __init__(self, *argv, **kwargs) -> None:\n';A+=D+' ...\n\n';H.write(A)
128
+ H.write(A);L.write_object_stub(H,T,'{0}.{1}'.format(obj_name,E),D+' ',Q+1);A=D+' def __init__(self, *argv, **kwargs) -> None:\n';A+=D+' ...\n\n';H.write(A)
129
129
  elif s in G or r in G:
130
130
  W=b;X=B
131
131
  if Q>0:X='self, '
@@ -143,12 +143,12 @@ class Stubber:
143
143
  H.write(A)
144
144
  else:H.write("# all other, type = '{0}'\n".format(G));H.write(D+E+' # type: Any\n')
145
145
  del R;del N
146
- try:del E,K,G,S
147
- except (F,T,l):pass
146
+ try:del E,K,G,T
147
+ except (F,S,l):pass
148
148
  @property
149
149
  def flat_fwid(self):
150
150
  A=self._fwid;B=' .()/\\:$'
151
- for C in B:A=A.replace(C,O)
151
+ for C in B:A=A.replace(C,T)
152
152
  return A
153
153
  def clean(B,path=E):
154
154
  if path is E:path=B.path
@@ -165,7 +165,7 @@ class Stubber:
165
165
  J('Created stubs for {} modules on board {}\nPath: {}'.format(M(A._report),A._fwid,A.path));E=v.format(A.path,filename);C.collect()
166
166
  try:
167
167
  with W(E,'w')as B:
168
- A.write_json_header(B);D=P
168
+ A.write_json_header(B);D=O
169
169
  for G in A._report:A.write_json_node(B,G,D);D=H
170
170
  A.write_json_end(B)
171
171
  I=A._start_free-C.mem_free()
@@ -196,8 +196,8 @@ def _info():
196
196
  i='ev3-pybricks';h='pycopy';e='GENERIC';c='arch';a='cpu';Z='ver';V='with';G='mpy';F='build';A=d({N:sys.implementation.name,D:B,F:B,Z:B,m:'stm32'if sys.platform.startswith(w)else sys.platform,K:e,a:B,G:B,c:B})
197
197
  try:A[D]=L.join([str(A)for A in sys.implementation.version])
198
198
  except I:pass
199
- try:W=sys.implementation._machine if'_machine'in R(sys.implementation)else os.uname().machine;A[K]=W.strip();A[a]=W.split(V)[1].strip();A[G]=sys.implementation._mpy if'_mpy'in R(sys.implementation)else sys.implementation.mpy if G in R(sys.implementation)else B
200
- except (I,S):pass
199
+ try:W=sys.implementation._machine if'_machine'in Q(sys.implementation)else os.uname().machine;A[K]=W.strip();A[a]=W.split(V)[1].strip();A[G]=sys.implementation._mpy if'_mpy'in Q(sys.implementation)else sys.implementation.mpy if G in Q(sys.implementation)else B
200
+ except (I,R):pass
201
201
  C.collect()
202
202
  for J in [A+'/board_info.csv'for A in z]:
203
203
  if g(J):
@@ -207,26 +207,26 @@ def _info():
207
207
  H=H.split(V)[0].strip()
208
208
  if f(A,H,J):break
209
209
  A[K]=e
210
- A[K]=A[K].replace(' ',O);C.collect()
210
+ A[K]=A[K].replace(' ',T);C.collect()
211
211
  try:
212
212
  A[F]=U(os.uname()[3])
213
213
  if not A[F]:A[F]=U(os.uname()[2])
214
214
  if not A[F]and';'in sys.version:A[F]=U(sys.version.split(';')[1])
215
- except (I,S):pass
215
+ except (I,R):pass
216
216
  if A[F]and M(A[F])>5:A[F]=B
217
217
  if A[D]==B and sys.platform not in('unix','win32'):
218
218
  try:j=os.uname();A[D]=j.release
219
- except (S,I,TypeError):pass
219
+ except (R,I,TypeError):pass
220
220
  for (k,l,n) in [(h,h,'const'),(b,b,'FAT'),(i,'pybricks.hubs','EV3Brick')]:
221
221
  try:o=__import__(l,E,E,n);A[N]=k;del o;break
222
- except (Q,T):pass
222
+ except (P,S):pass
223
223
  if A[N]==i:A['release']='2.0.0'
224
224
  if A[N]==X:
225
225
  if A[D]and A[D].endswith('.0')and A[D]>='1.10.0'and A[D]<='1.19.9':A[D]=A[D][:-2]
226
226
  if G in A and A[G]:
227
- P=int(A[G]);Y=[E,'x86','x64','armv6','armv6m','armv7m','armv7em','armv7emsp','armv7emdp','xtensa','xtensawin'][P>>10]
227
+ O=int(A[G]);Y=[E,'x86','x64','armv6','armv6m','armv7m','armv7em','armv7emsp','armv7emdp','xtensa','xtensawin'][O>>10]
228
228
  if Y:A[c]=Y
229
- A[G]='v{}.{}'.format(P&255,P>>8&3)
229
+ A[G]='v{}.{}'.format(O&255,O>>8&3)
230
230
  A[Z]=f"v{A[D]}-{A[F]}"if A[F]else f"v{A[D]}";return A
231
231
  def f(info,board_descr,filename):
232
232
  with W(filename,'r')as B:
@@ -234,7 +234,7 @@ def f(info,board_descr,filename):
234
234
  A=B.readline()
235
235
  if not A:break
236
236
  C,D=A.split(',')[0].strip(),A.split(',')[1].strip()
237
- if C==board_descr:info[K]=D;return P
237
+ if C==board_descr:info[K]=D;return O
238
238
  return H
239
239
  def get_root():
240
240
  try:A=os.getcwd()
@@ -246,7 +246,7 @@ def get_root():
246
246
  return B
247
247
  def g(filename):
248
248
  try:
249
- if os.stat(filename)[0]>>14:return P
249
+ if os.stat(filename)[0]>>14:return O
250
250
  return H
251
251
  except F:return H
252
252
  def h():sys.exit(1)
@@ -260,7 +260,7 @@ def read_path():
260
260
  return path
261
261
  def i():
262
262
  try:A=bytes('abc',encoding='utf8');B=i.__module__;return H
263
- except (j,I):return P
263
+ except (j,I):return O
264
264
  def main():stubber=Stubber(path=read_path());stubber.clean();stubber.modules=['WM8960','_OTA','_boot_fat','_coap','_flash_control_OTA','_main_pybytes','_mqtt','_mqtt_core','_msg_handl','_onewire','_periodical_pin','_pybytes','_pybytes_ca','_pybytes_config','_pybytes_config_reader','_pybytes_connection','_pybytes_constants','_pybytes_debug','_pybytes_library','_pybytes_machine_learning','_pybytes_main','_pybytes_protocol','_pybytes_pyconfig','_pybytes_pymesh_config','_rp2','_terminal','_thread','_uasyncio','_urequest','adcfft','aioble/__init__','aioble/central','aioble/client','aioble/core','aioble/device','aioble/l2cap','aioble/peripheral','aioble/security','aioble/server','ak8963','apa102','apa106','array','binascii','bluetooth','breakout_as7262','breakout_bh1745','breakout_bme280','breakout_bme68x','breakout_bmp280','breakout_dotmatrix','breakout_encoder','breakout_icp10125','breakout_ioexpander','breakout_ltr559','breakout_matrix11x7','breakout_mics6814','breakout_msa301','breakout_paa5100','breakout_pmw3901','breakout_potentiometer','breakout_rgbmatrix5x5','breakout_rtc','breakout_scd41','breakout_sgp30','breakout_trackball','breakout_vl53l5cx','btree','cmath','collections','crypto','cryptolib','curl','dht','display','display_driver_utils','ds18x20','encoder','errno','esp','esp32','espidf','flashbdev','framebuf','freesans20','fs_driver','functools','galactic','gc','gfx_pack','gsm','hashlib','heapq','hub75','ili9341','ili9XXX','imagetools','inisetup','interstate75','io','jpegdec','json','lcd160cr','lodepng',u,'lsm6dsox','lv_colors','lv_utils','lvgl','lwip','machine','math','microWebSocket','microWebSrv','microWebTemplate',X,'mip','motor','mpu6500','mpu9250','neopixel','network','ntptime','onewire','os','pcf85063a','picoexplorer','picographics','picokeypad','picoscroll','picounicorn','picowireless','pimoroni','pimoroni_bus','pimoroni_i2c','plasma','platform',w,b,'pye','qrcode','queue','random','requests','rp2','rtch','samd','select','servo','socket','ssd1306','ssh','ssl','stm','struct',t,'time','tpcalib','uarray','uasyncio/__init__','uasyncio/core','uasyncio/event','uasyncio/funcs','uasyncio/lock','uasyncio/stream','uasyncio/tasks','ubinascii','ubluetooth','ucollections','ucrypto','ucryptolib','uctypes','uerrno','uftpd','uhashlib','uheapq','uio','ujson','ulab','ulab/approx','ulab/compare','ulab/fft','ulab/filter','ulab/linalg','ulab/numerical','ulab/poly','ulab/user','ulab/vector','umachine','umqtt/__init__','umqtt/robust','umqtt/simple','uos','uplatform','uqueue','urandom','ure','urequests','urllib/urequest','uselect','usocket','ussl','ustruct','usys','utelnetserver','utime','utimeq','uwebsocket','uzlib',D,'websocket','websocket_helper','wipy','writer','xpt2046','ymodem','zephyr','zlib'];C.collect();stubber.create_all_stubs();stubber.report()
265
265
  if __name__=='__main__'or i():
266
266
  try:logging.basicConfig(level=logging.INFO)
Binary file
stubber/codemod/board.py CHANGED
@@ -15,7 +15,7 @@ from packaging.version import Version
15
15
  from stubber.codemod._partials import Partial
16
16
  from stubber.codemod.modify_list import ListChangeSet, ModifyListElements
17
17
  from stubber.cst_transformer import update_module_docstr
18
- from stubber.utils.my_version import __version__
18
+ from stubber import __version__
19
19
 
20
20
  # matches on `stubber = Stubber()`
21
21
  _STUBBER_MATCHER = m.Assign(
stubber/commands/cli.py CHANGED
@@ -5,7 +5,7 @@ import sys
5
5
 
6
6
  import click
7
7
  from loguru import logger as log
8
- from stubber.utils.my_version import __version__
8
+ from stubber import __version__
9
9
 
10
10
 
11
11
  @click.group(chain=True)
@@ -2,10 +2,12 @@
2
2
  switch to a specific version of the micropython repos
3
3
  """
4
4
 
5
+
5
6
  from pathlib import Path
6
7
  from typing import Optional, Union
7
8
 
8
9
  import click
10
+
9
11
  import stubber.basicgit as git
10
12
  from stubber.utils.config import CONFIG
11
13
  from stubber.utils.repos import fetch_repos, repo_paths
@@ -18,7 +20,12 @@ from .cli import stubber_cli
18
20
 
19
21
 
20
22
  # get version list from Git tags in the repo that is provided on the command line
21
- VERSION_LIST = git.get_tags("micropython/micropython", minver="v1.9.3") + ["latest"]
23
+
24
+ try:
25
+ VERSION_LIST = git.get_tags("micropython/micropython", minver="v1.9.3") + ["latest"]
26
+ except Exception:
27
+ # offline fallback
28
+ VERSION_LIST = ["v1.91.1", "v1.20.0", "latest"]
22
29
 
23
30
 
24
31
  @stubber_cli.command(name="switch")
@@ -12,4 +12,4 @@ version, mpy_date, lib_date, lib_commit_hash,
12
12
  "refs/tags/v1.18", "Jan 16 2022", "Nov 11 2021", "cdd260f0792d04a1ded99171b4c7a2582b7856b4", "aioble/multitests: Add multitest for shutdown handlers."
13
13
  "refs/tags/v1.19", "Jun 16 2022", "Jun 16 2022", "db4c739863e49fc874bdaae8aa8c316c7ed4276a", "unittest: Version 0.9.0"
14
14
  "refs/tags/v1.19.1","Jun 16 2022", "Jun 16 2022", "db4c739863e49fc874bdaae8aa8c316c7ed4276a", "unittest: Version 0.9.0"
15
- "refs/tags/v1.20.0","Apr 26 2023", "Apr 11 2023", "c113611765278b2fc8dcf8b2f2c3513b35a69b39", "aioble: Fix descriptor flag handling"
15
+
stubber/get_cpython.py CHANGED
@@ -14,7 +14,9 @@ from typing import Optional, Union
14
14
 
15
15
  from loguru import logger as log
16
16
 
17
- from . import __version__, utils
17
+ from . import __version__
18
+
19
+ from . import utils
18
20
  from .utils.config import CONFIG
19
21
 
20
22
  # # log = logging.getLogger(__name__)
stubber/publish/enums.py CHANGED
@@ -14,6 +14,14 @@ class StubSource(str, Enum):
14
14
  MERGED = "Merged stubs"
15
15
  "stubs built by merging the information from doc-stubs and firmware-stubs"
16
16
 
17
+ def __str__(self):
18
+ # Always force string values
19
+ return self.value
20
+
21
+ def __repr__(self):
22
+ # Always force string values
23
+ return self.value
24
+
17
25
 
18
26
  ALL_TYPES = ["combo", "doc", "core", "firmware"]
19
27
  COMBO_STUBS = ALL_TYPES[0]
@@ -30,7 +30,7 @@ def board_folder_name(fw: Dict, *, version: Optional[str] = None):
30
30
  base = get_base(fw, version=version)
31
31
  folder_name = f"{base}-{fw['port']}" if fw["board"] in GENERIC else f"{base}-{fw['port']}-{fw['board']}"
32
32
  # do not force name to lowercase
33
- folder_name = folder_name.replace("-generic_", "-") # @GENERIC Prefix
33
+ folder_name = folder_name.replace("-generic_", "-").replace("-GENERIC_", "-") # remove GENERIC Prefix
34
34
  return folder_name
35
35
 
36
36
 
@@ -86,7 +86,9 @@ def merge_all_docstubs(
86
86
  if candidate["version"] == "latest":
87
87
  # for the latest we do a bit more effort to get something 'good enough'
88
88
  # try to get the board_path from the last released version as the basis
89
- board_path = CONFIG.stub_path / board_folder_name(candidate, version=clean_version(CONFIG.stable_version, flat=True))
89
+ board_path = CONFIG.stub_path / board_folder_name(
90
+ candidate, version=clean_version(CONFIG.stable_version, flat=True)
91
+ )
90
92
  # check again
91
93
  if board_path.exists():
92
94
  log.info(f"using {board_path.name} as the basis for {merged_path.name}")
@@ -101,7 +103,7 @@ def merge_all_docstubs(
101
103
  log.info(f"Merge docstubs for {merged_path.name} {candidate['version']}")
102
104
  result = copy_and_merge_docstubs(board_path, merged_path, doc_path)
103
105
  # Add methods from docstubs to the firmware stubs that do not exist in the firmware stubs
104
- add_machine_pin_call(merged_path, candidate['version'])
106
+ add_machine_pin_call(merged_path, candidate["version"])
105
107
  if result:
106
108
  merged += 1
107
109
  log.info(f"merged {merged} of {len(candidates)} candidates")
@@ -4,14 +4,14 @@ prepare a set of stub files for publishing to PyPi
4
4
  !!Note: anything excluded in .gitignore is not packaged by poetry
5
5
  """
6
6
  from typing import Any, Dict, List, Union
7
+
7
8
  from loguru import logger as log
8
9
 
9
10
  from stubber.publish.candidates import board_candidates, filter_list
10
11
  from stubber.publish.database import get_database
11
12
  from stubber.publish.enums import COMBO_STUBS
12
- from stubber.publish.package import get_package
13
+ from stubber.publish.package import GENERIC_U, get_package
13
14
  from stubber.utils.config import CONFIG
14
- from stubber.publish.package import GENERIC_U
15
15
 
16
16
 
17
17
  def build_multiple(
@@ -74,7 +74,9 @@ def publish_multiple(
74
74
  return results
75
75
 
76
76
 
77
- def build_worklist(family: str, versions: List[str], ports: Union[List[str], str], boards: Union[List[str], str]):
77
+ def build_worklist(
78
+ family: str, versions: Union[List[str], str], ports: Union[List[str], str], boards: Union[List[str], str]
79
+ ):
78
80
  """Build a worklist of packages to build or publish, and filter to only the requested ports and boards"""
79
81
  if isinstance(versions, str):
80
82
  versions = [versions]
@@ -148,7 +148,6 @@ class StubPackage:
148
148
  with open(_toml, "rb") as f:
149
149
  pyproject = tomllib.load(f)
150
150
  pyproject["tool"]["poetry"]["version"] = version
151
-
152
151
  # update the version in the toml file
153
152
  with open(_toml, "wb") as output:
154
153
  tomli_w.dump(pyproject, output)
@@ -174,13 +173,15 @@ class StubPackage:
174
173
  else:
175
174
  raise ValueError("cannot determine next version number micropython")
176
175
 
177
- def get_next_package_version(self, prod: bool = False) -> str:
176
+ def get_next_package_version(self, prod: bool = False, rc=False) -> str:
178
177
  """Get the next version for the package."""
179
178
  base = Version(self.pkg_version)
180
179
  if pypi_versions := get_pypi_versions(self.package_name, production=prod, base=base):
180
+ # get the latest version from pypi
181
181
  self.pkg_version = str(pypi_versions[-1])
182
- # no puvblished package found , so we start at base version then bump 1 post release
183
- self.pkg_version = Version(self.pkg_version).base_version
182
+ else:
183
+ # no published package found , so we start at base version then bump 1 post release
184
+ self.pkg_version = Version(self.pkg_version).base_version
184
185
  return self.bump()
185
186
 
186
187
  # -----------------------------------------------
@@ -666,8 +667,7 @@ class StubPackage:
666
667
  ok = self.update_package()
667
668
  self.status["version"] = self.pkg_version
668
669
  if not ok:
669
- log.warning(f"{self.package_name}: skipping as build failed")
670
- self.status["error"] = "Build failed"
670
+ log.info(f"{self.package_name}: skip - Could not update package")
671
671
  return False
672
672
  # If there are changes to the package, then publish it
673
673
  if self.is_changed():
@@ -691,7 +691,7 @@ class StubPackage:
691
691
  self.status["result"] = "Build OK"
692
692
  else:
693
693
  log.warning(f"{self.package_name}: skipping as build failed")
694
- self.status["error"] = "Build failed"
694
+ self.status["error"] = "Poetry build failed"
695
695
  return False
696
696
  return True
697
697
 
stubber/rst/lookup.py CHANGED
@@ -101,7 +101,7 @@ LOOKUP_LIST = {
101
101
  "machine.UART.irq": ("Any", 0.95), # no IRQ type defined
102
102
  "math.isnan": ("bool", 0.95),
103
103
  "micropython.opt_level": ("Any", 0.95), # Not clear in docstring
104
- "micropython.const": ("int", 0.95), # const is always an int
104
+ "micropython.const": ("Union[int, bytes, str, Tuple]", 0.95), # since 1.19 can also be string , bytes or tuple
105
105
  "pyb.hard_reset": ("NoReturn", 0.95), # never returns
106
106
  "pyb.I2C.recv": ("bytes", 0.95), # complex in docstring
107
107
  "pyb.SPI.recv": ("bytes", 0.95), # complex in docstring
stubber/utils/manifest.py CHANGED
@@ -5,7 +5,7 @@ import os
5
5
  from pathlib import Path
6
6
  from typing import Optional
7
7
 
8
- from .my_version import __version__
8
+ from .. import __version__
9
9
  from .versions import clean_version
10
10
 
11
11
  # # log = logging.getLogger(__name__)
stubber/utils/repos.py CHANGED
@@ -8,9 +8,10 @@ from collections import defaultdict
8
8
  from pathlib import Path
9
9
  from typing import Tuple
10
10
 
11
- import stubber.basicgit as git
12
11
  from loguru import logger as log
12
+ from packaging.version import Version
13
13
 
14
+ import stubber.basicgit as git
14
15
  from stubber.utils.config import CONFIG
15
16
 
16
17
  # # log = logging.getLogger(__name__)
@@ -43,13 +44,11 @@ def switch(tag: str, *, mpy_path: Path, mpy_lib_path: Path):
43
44
 
44
45
  def read_micropython_lib_commits(filename: str = "data/micropython_tags.csv"):
45
46
  """
46
- Read a csv with the micropython version and matchin micropython-lib commit-hashes
47
+ Read a csv with the micropython version and matching micropython-lib commit-hashes
47
48
  these can be used to make sure that the correct micropython-lib version is checked out.
48
49
 
49
50
  filename is relative to the 'stubber' package
50
51
 
51
- TODO: it would be nice if micropython-lib had matching commit-tags
52
-
53
52
  git for-each-ref --sort=creatordate --format '%(refname) %(creatordate)' refs/tags
54
53
  """
55
54
  data = pkgutil.get_data("stubber", filename)
@@ -63,7 +62,9 @@ def read_micropython_lib_commits(filename: str = "data/micropython_tags.csv"):
63
62
  reader = csv.DictReader(ntf.file, skipinitialspace=True) # dialect="excel",
64
63
  rows = list(reader)
65
64
  # create a dict version --> commit_hash
66
- version_commit = {row["version"].split("/")[-1]: row["lib_commit_hash"] for row in rows if row["version"].startswith("refs/tags/")}
65
+ version_commit = {
66
+ row["version"].split("/")[-1]: row["lib_commit_hash"] for row in rows if row["version"].startswith("refs/tags/")
67
+ }
67
68
  # add default
68
69
  version_commit = defaultdict(lambda: "master", version_commit)
69
70
  return version_commit
@@ -72,12 +73,24 @@ def read_micropython_lib_commits(filename: str = "data/micropython_tags.csv"):
72
73
  def match_lib_with_mpy(version_tag: str, lib_path: Path):
73
74
  micropython_lib_commits = read_micropython_lib_commits()
74
75
  # Make sure that the correct micropython-lib release is checked out
75
- log.info(f"Matching repo's: Micropython {version_tag} needs micropython-lib:{micropython_lib_commits[version_tag]}")
76
- return git.checkout_commit(micropython_lib_commits[version_tag], lib_path)
76
+ # check if micropython-lib has matching tags
77
+ if Version(version_tag) >= Version("v1.20.0"):
78
+ # TODO:if version is v1.12.0 or newer
79
+ # then use submodules to checkout the correct version of micropython-lib
80
+ # git submodule update lib/micropython-lib
81
+ # or use the new git tags to checkout the correct version of micropython-lib
82
+ # else
83
+ # clean the submodules for just to be sure
84
+ # git submodule foreach --recursive git clean -xfd
85
+ # use the micropython_tags.csv to find the correct commit hash
86
+ return git.checkout_tag(version_tag, lib_path)
87
+ else:
88
+ log.info(f"Matching repo's: Micropython {version_tag} needs micropython-lib:{micropython_lib_commits[version_tag]}")
89
+ return git.checkout_commit(micropython_lib_commits[version_tag], lib_path)
77
90
 
78
91
 
79
92
  def fetch_repos(tag: str, mpy_path: Path, mpy_lib_path: Path):
80
- """Fetch updates , then switch to the provided tag"""
93
+ """Fetch updates, then switch to the provided tag"""
81
94
  log.info("fetch updates")
82
95
  git.fetch(mpy_path)
83
96
  git.fetch(mpy_lib_path)
@@ -96,7 +109,7 @@ def fetch_repos(tag: str, mpy_path: Path, mpy_lib_path: Path):
96
109
  git.checkout_tag(repo=mpy_path, tag=tag)
97
110
  result = match_lib_with_mpy(version_tag=tag, lib_path=mpy_lib_path)
98
111
 
99
- log.info(f"{mpy_lib_path} {git.get_local_tag(mpy_path)}")
112
+ log.info(f"{mpy_path} {git.get_local_tag(mpy_path)}")
100
113
  log.info(f"{mpy_lib_path} {git.get_local_tag(mpy_lib_path)}")
101
114
  return result
102
115
 
@@ -1,15 +0,0 @@
1
- """
2
- find the version of this package
3
- """
4
-
5
- try:
6
- import importlib.metadata as importlib_metadata
7
- except ModuleNotFoundError: # pragma: no cover
8
- import importlib_metadata # type: ignore
9
-
10
- __version__ = "0.0.0"
11
- try:
12
- # todo: use __name__
13
- __version__ = importlib_metadata.version("micropython-stubber")
14
- except Exception: # pragma: no cover
15
- __version__ = "0.0.0"