Skip to content

Commit 56e9d7a

Browse files
Adding implicit pypi failover for all packages for non variants
1 parent 3004567 commit 56e9d7a

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

index.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ maintainers = [
77
registry = "https://pypi.anaconda.org/mgorny/simple/"
88
packages = [
99
"blas-lapack-variant-provider",
10-
# "numpy",
10+
"numpy",
1111
"openmp-variant-provider",
1212
"provider-variant-aarch64",
1313
"provider-variant-x86-64",

src/build.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from __future__ import annotations
22

3+
import contextlib
34
import datetime
45
import hashlib
56
import json
@@ -16,6 +17,7 @@
1617
import jsonschema
1718
import requests
1819
from bs4 import BeautifulSoup
20+
from packaging.version import Version
1921

2022
BUILD_DIR = Path("build")
2123
BUILD_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

Comments
 (0)