kaldifeat / update-cuda-html.py
csukuangfj's picture
add missing files
96b8a02
raw
history blame
2.13 kB
#!/usr/bin/env python3
import os
import re
from pathlib import Path
from util import generate_url, get_all_files
def get_doc_dir():
kaldifeat_dir = os.getenv("KALDIFEAT_DIR")
if kaldifeat_dir is None:
raise ValueError("Please set the environment variable KALDIFEAT_DIR")
return Path(kaldifeat_dir) / "doc"
class Wheel:
def __init__(self, full_name: str, url: str):
"""
Args:
full_name:
Example: kaldifeat-1.23.4.dev20230224+cuda10.1.torch1.6.0-cp36-cp36m-linux_x86_64.whl
"""
self.full_name = full_name
pattern = r"kaldifeat-(\d)\.(\d)+((\.)(\d))?\.dev(\d{8})\+cuda(\d+)\.(\d+)\.torch(\d\.\d+\.\d)-cp(\d+)"
m = re.search(pattern, full_name)
self.kaldifeat_major = int(m.group(1))
self.kaldifeat_minor = int(m.group(2))
self.kaldifeat_patch = int(m.group(5)) if m.group(5) else 0
self.kaldifeat_date = int(m.group(6))
self.cuda_major_version = int(m.group(7))
self.cuda_minor_version = int(m.group(8))
self.torch_version = m.group(9)
self.py_version = int(m.group(10))
self.url = url
def sort_by_wheel(x: Wheel):
torch_major, torch_minor, torch_patch = x.torch_version.split(".")
torch_major = int(torch_major)
torch_minor = int(torch_minor)
torch_patch = int(torch_patch)
return (
x.kaldifeat_major,
x.kaldifeat_minor,
x.kaldifeat_patch,
x.kaldifeat_date,
torch_major,
torch_minor,
torch_patch,
x.cuda_major_version,
x.cuda_minor_version,
x.py_version,
)
def main():
wheels = get_all_files("ubuntu-cuda", suffix="*.whl")
urls = generate_url(wheels)
wheels = []
for url in urls:
full_name = url.rsplit("/", maxsplit=1)[1]
wheels.append(Wheel(full_name, url))
wheels.sort(reverse=True, key=sort_by_wheel)
d = get_doc_dir()
with open(d / "source/cuda.html", "w") as f:
for w in wheels:
f.write(f'<a href="{w.url}">{w.full_name}</a><br/>\n')
if __name__ == "__main__":
main()