11from __future__ import annotations
22
3+ import contextlib
34import datetime
45import hashlib
56import json
1617import jsonschema
1718import requests
1819from bs4 import BeautifulSoup
20+ from packaging .version import Version
1921
2022BUILD_DIR = Path ("build" )
2123BUILD_DATE = datetime .datetime .now (tz = ZoneInfo ("America/New_York" )).strftime (
@@ -83,9 +85,7 @@ def version(self) -> str:
8385
8486 @classmethod
8587 def from_file (cls , fp : Path ) -> VariantJson :
86- return VariantJson (
87- name = fp .name , link = fp .name , checksum = sha256sum (fp )
88- )
88+ return VariantJson (name = fp .name , link = fp .name , checksum = sha256sum (fp ))
8989
9090
9191@dataclass (frozen = True )
@@ -218,6 +218,12 @@ def generate_project_index(pkg_config: PkgConfig) -> None:
218218
219219 artifacts = fetch_links (safe_urljoin (pkg_config .registry , pkg_config .name + "/" ))
220220
221+ # Also add the packages published on PyPI
222+ with contextlib .suppress (requests .exceptions .HTTPError ):
223+ artifacts .extend (
224+ fetch_links (safe_urljoin ("https://pypi.org/simple" , pkg_config .name + "/" ))
225+ )
226+
221227 variants_json_files = sorted (
222228 [artifact for artifact in artifacts if isinstance (artifact , VariantJson )],
223229 key = lambda x : x .name ,
@@ -257,13 +263,14 @@ def augment_wheel_variant(artifact: VariantWheel) -> VariantWheel:
257263 ),
258264 )
259265
260- wheel_variant_files = sorted (
266+ wheel_files = sorted (
261267 [
262268 augment_wheel_variant (artifact )
263269 for artifact in artifacts
264270 if isinstance (artifact , VariantWheel )
265271 ],
266- key = lambda x : x .name ,
272+ key = lambda x : (Version (x .name .split ("-" , maxsplit = 2 )[1 ]), x .name ),
273+ reverse = True ,
267274 )
268275
269276 # Render template
@@ -274,9 +281,10 @@ def augment_wheel_variant(artifact: VariantWheel) -> VariantWheel:
274281 VariantJson .from_file (fp )
275282 for fp in (BUILD_DIR / pkg_config .name ).glob ("*.json" )
276283 ],
277- key = lambda vf : vf .name ,
284+ key = lambda vf : (Version (vf .name .split ("-" , maxsplit = 2 )[1 ]), vf .name ),
285+ reverse = True ,
278286 ),
279- wheel_variant_files = wheel_variant_files ,
287+ wheel_variant_files = wheel_files ,
280288 build_date = BUILD_DATE ,
281289 )
282290
0 commit comments