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