@@ -23,6 +23,15 @@ def irm(url, method="GET", headers={}):
2323
2424NUGET_SOURCE = "https://api.nuget.org/v3/index.json"
2525
26+ # Earlier versions than this go into "legacy.json"
27+ CURRENT_VERSION = Version ("3.10" )
28+
29+ SKIP_OLD_PRERELEASE = True
30+
31+ # Indentation for output files
32+ INDENT = None
33+
34+
2635SCHEMA = {
2736 "python" : {
2837 "schema" : 1 ,
@@ -35,6 +44,7 @@ def irm(url, method="GET", headers={}):
3544 "$XYVERSIONNOPRE$-64" ,
3645 "$XVERSIONNOPRE$-64" ,
3746 "$XYVERSIONDEV$-64" ,
47+ "$XVERSIONDEV$-64" ,
3848 ],
3949 "run-for" : [
4050 {"tag" : "$FULLVERSION$-64" , "target" : "python.exe" },
@@ -80,7 +90,7 @@ def irm(url, method="GET", headers={}):
8090 "Icon" : "%PREFIX%python.exe" ,
8191 },
8292 {
83- "Name" : "Python $XYVERSION$ Documentation" ,
93+ "Name" : "Python $XYVERSION$ Online Documentation" ,
8494 "Icon" : r"%SystemRoot%\System32\SHELL32.dll" ,
8595 "IconIndex" : 13 ,
8696 "Target" : "https://docs.python.org/$XYVERSION$/" ,
@@ -108,6 +118,7 @@ def irm(url, method="GET", headers={}):
108118 "$XYVERSIONNOPRE$-32" ,
109119 "$XVERSIONNOPRE$-32" ,
110120 "$XYVERSIONDEV$-32" ,
121+ "$XVERSIONDEV$-32" ,
111122 ],
112123 "run-for" : [
113124 {"tag" : "$FULLVERSION$-32" , "target" : "python.exe" },
@@ -153,7 +164,7 @@ def irm(url, method="GET", headers={}):
153164 "Icon" : "%PREFIX%python.exe" ,
154165 },
155166 {
156- "Name" : "Python $XYVERSION$ Documentation" ,
167+ "Name" : "Python $XYVERSION$ Online Documentation" ,
157168 "Icon" : r"%SystemRoot%\System32\SHELL32.dll" ,
158169 "IconIndex" : 13 ,
159170 "Target" : "https://docs.python.org/$XYVERSION$/" ,
@@ -181,6 +192,7 @@ def irm(url, method="GET", headers={}):
181192 "$XYVERSIONNOPRE$-arm64" ,
182193 "$XVERSIONNOPRE$-arm64" ,
183194 "$XYVERSIONDEV$-arm64" ,
195+ "$XVERSIONDEV$-arm64" ,
184196 ],
185197 "run-for" : [
186198 {"tag" : "$FULLVERSION$-arm64" , "target" : "python.exe" },
@@ -226,7 +238,7 @@ def irm(url, method="GET", headers={}):
226238 "Icon" : "%PREFIX%python.exe" ,
227239 },
228240 {
229- "Name" : "Python $XYVERSION$ Documentation" ,
241+ "Name" : "Python $XYVERSION$ Online Documentation" ,
230242 "Icon" : r"%SystemRoot%\System32\SHELL32.dll" ,
231243 "IconIndex" : 13 ,
232244 "Target" : "https://docs.python.org/$XYVERSION$/" ,
@@ -254,6 +266,7 @@ def irm(url, method="GET", headers={}):
254266 "$XYVERSIONNOPRE$t-64" ,
255267 "$XVERSIONNOPRE$t-64" ,
256268 "$XYVERSIONDEV$t-64" ,
269+ "$XVERSIONDEV$t-64" ,
257270 ],
258271 "run-for" : [
259272 {"tag" : "$FULLVERSION$t-64" , "target" : "python$XYVERSION$t.exe" },
@@ -299,7 +312,7 @@ def irm(url, method="GET", headers={}):
299312 "Icon" : "%PREFIX%python.exe" ,
300313 },
301314 {
302- "Name" : "Python $XYVERSION$ Documentation" ,
315+ "Name" : "Python $XYVERSION$ Online Documentation" ,
303316 "Icon" : r"%SystemRoot%\System32\SHELL32.dll" ,
304317 "IconIndex" : 13 ,
305318 "Target" : "https://docs.python.org/$XYVERSION$/" ,
@@ -327,6 +340,7 @@ def irm(url, method="GET", headers={}):
327340 "$XYVERSIONNOPRE$t-32" ,
328341 "$XVERSIONNOPRE$t-32" ,
329342 "$XYVERSIONDEV$t-32" ,
343+ "$XVERSIONDEV$t-32" ,
330344 ],
331345 "run-for" : [
332346 {"tag" : "$FULLVERSION$t-32" , "target" : "python$XYVERSION$t.exe" },
@@ -372,7 +386,7 @@ def irm(url, method="GET", headers={}):
372386 "Icon" : "%PREFIX%python.exe" ,
373387 },
374388 {
375- "Name" : "Python $XYVERSION$ Documentation" ,
389+ "Name" : "Python $XYVERSION$ Online Documentation" ,
376390 "Icon" : r"%SystemRoot%\System32\SHELL32.dll" ,
377391 "IconIndex" : 13 ,
378392 "Target" : "https://docs.python.org/$XYVERSION$/" ,
@@ -400,6 +414,7 @@ def irm(url, method="GET", headers={}):
400414 "$XYVERSIONNOPRE$t-arm64" ,
401415 "$XVERSIONNOPRE$t-arm64" ,
402416 "$XYVERSIONDEV$t-arm64" ,
417+ "$XVERSIONDEV$t-arm64" ,
403418 ],
404419 "run-for" : [
405420 {"tag" : "$FULLVERSION$t-arm64" , "target" : "python$XYVERSION$t.exe" },
@@ -445,7 +460,7 @@ def irm(url, method="GET", headers={}):
445460 "Icon" : "%PREFIX%python.exe" ,
446461 },
447462 {
448- "Name" : "Python $XYVERSION$ Documentation" ,
463+ "Name" : "Python $XYVERSION$ Online Documentation" ,
449464 "Icon" : r"%SystemRoot%\System32\SHELL32.dll" ,
450465 "IconIndex" : 13 ,
451466 "Target" : "https://docs.python.org/$XYVERSION$/" ,
@@ -499,16 +514,15 @@ def dict_sub(d, subs):
499514INDEX_OLD = {"versions" : []}
500515INDEX_CURRENT = {"versions" : [], "next" : "" }
501516
502- # Earlier versions than this go into "legacy.json"
503- CURRENT_VERSION = Version ("3.12" )
504-
505517for name , schema in SCHEMA .items ():
506518 data = irm (f"{ BASE_URL } /{ name } /index.json" )
507519
508520 all_versions = sorted ((Version (ver ) for ver in data ["versions" ]), reverse = True )
509521
510522 last_v = None
511523 for v in all_versions :
524+ if v .is_prerelease and v < CURRENT_VERSION and SKIP_OLD_PRERELEASE :
525+ continue
512526 if v .is_prerelease and last_v and v .to_python_style (3 , False ) == last_v :
513527 continue
514528 subs = {
@@ -518,21 +532,25 @@ def dict_sub(d, subs):
518532 "XYVERSIONDEV" : (v .to_python_style (2 , False ) + "-dev" ) if v .is_prerelease else None ,
519533 "XVERSION" : v .to_python_style (1 , False ),
520534 "XVERSIONNOPRE" : None if v .is_prerelease else v .to_python_style (1 , False ),
535+ "XVERSIONDEV" : (v .to_python_style (1 , False ) + "-dev" ) if v .is_prerelease else None ,
521536 "PACKAGEURL" : f"{ BASE_URL } /{ name } /{ v } /{ name } .{ v } .nupkg" ,
522537 }
523538 index = INDEX_CURRENT if v >= CURRENT_VERSION else INDEX_OLD
524539 index ["versions" ].append (dict_sub (schema , subs ))
525540 last_v = subs ["FULLVERSION" ]
526541
527542
543+ INDEX_CURRENT ["versions" ].sort (key = lambda i : (Version (i ["sort-version" ]), i ["id" ]), reverse = True )
544+ INDEX_OLD ["versions" ].sort (key = lambda i : (Version (i ["sort-version" ]), i ["id" ]), reverse = True )
545+
528546for file in map (Path , sys .argv [1 :]):
529547 legacy_name = f"{ file .stem } -legacy.json"
530548 INDEX_CURRENT ["next" ] = legacy_name
531549 file .parent .mkdir (exist_ok = True , parents = True )
532550 with open (file , "w" , encoding = "utf-8" ) as f :
533- json .dump (INDEX_CURRENT , f , indent = 2 )
551+ json .dump (INDEX_CURRENT , f , indent = INDENT )
534552 with open (file .with_name (legacy_name ), "w" , encoding = "utf-8" ) as f :
535- json .dump (INDEX_OLD , f , indent = 2 )
553+ json .dump (INDEX_OLD , f , indent = INDENT )
536554
537555
538556if not sys .argv [1 :]:
0 commit comments