|
|
|
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): |
|
|
|
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() |
|
|