File size: 1,573 Bytes
6afe7b3 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
#!/usr/bin/env python3
import os
import re
from pathlib import Path
from typing import List
BASE_URL = "https://huggingface.co./csukuangfj/sherpa-onnx-wheels/resolve/main/"
from dataclasses import dataclass
@dataclass
class Wheel:
major: int
minor: int
patch: int
python: str
os: str
def __init__(self, _s):
# sherpa_onnx-1.10.16-cp38-cp38-macosx_11_0_x86_64.whl
s = _s.split("/")[-1]
split = s.split("-")
self.major, self.minor, self.patch = list(map(int, split[1].split(".")))
self.python = int(split[2][2:])
self.os = split[4]
def sort_by_wheel(x):
x = Wheel(x)
return (x.major, x.minor, x.patch, x.python, x.os)
def get_all_files(d: str, suffix: str = ".whl") -> List[str]:
ss = []
for root, d, files in os.walk(d):
for f in files:
if f.endswith(suffix):
ss.append(os.path.join(root, f))
return list(map(lambda x: BASE_URL + x, ss))
def main():
wheel = get_all_files("cpu")
wheel = sorted(wheel, key=sort_by_wheel, reverse=True)
wheel_cn = []
for w in wheel:
w = w.replace("huggingface.co", "hf-mirror.com")
wheel_cn.append(w)
with open("cpu.html", "w") as f:
for w in wheel:
basename = w.split("/")[-1]
f.write(f'<a href="{w}">{basename}</a><br/>\n')
with open("cpu-cn.html", "w") as f:
for w in wheel_cn:
basename = w.split("/")[-1]
f.write(f'<a href="{w}">{basename}</a><br/>\n')
if __name__ == "__main__":
main()
|