|
1 | 1 | import hashlib |
2 | 2 | import pathlib |
3 | | -import re |
4 | 3 | import argparse |
5 | | -import os |
6 | 4 |
|
7 | 5 | parser = argparse.ArgumentParser() |
8 | 6 | parser.add_argument("--mode", type=str, default="nightly") |
9 | 7 | args = parser.parse_args() |
10 | 8 | base_url = "https://github.com/tile-ai/tilelang-nightly/releases/download" |
11 | | -pattern = re.compile( |
12 | | - r"tilelang-" |
13 | | - r"((\d+\.)+\d+(?:\.post\d+)?)" |
14 | | - r"\+cu(\d+)\." |
15 | | - r"git([a-z0-9]+)?" |
16 | | -) |
17 | 9 | base_path = "tilelang-whl/nightly" |
18 | 10 | vvver = " Nightly" |
19 | | -star = "*" |
20 | 11 |
|
21 | 12 | if args.mode != "nightly": |
22 | 13 | vvver = "" |
23 | 14 | base_path = "tilelang-whl" |
24 | 15 | base_url = "https://github.com/tile-ai/tilelang/releases/download" |
25 | | - star = "cu*" |
26 | | -if args.mode == "nightly": |
27 | | - with (pathlib.Path(base_path) / "index.html").open("w") as f: |
28 | | - f.write( |
29 | | - """<!DOCTYPE html> |
30 | | -<h1>TileLang Nightly Python Wheels</h1>\n""" |
31 | | - ) |
32 | | -for index_dir in pathlib.Path(base_path).glob(star): |
33 | | - if index_dir.is_dir(): |
34 | | - os.system(f"rm -rf {index_dir}") |
35 | | -dir_set = set() |
36 | | -cuda_versions = list(range(121, 129)) |
37 | | -for path in sorted(pathlib.Path("dist").glob("*.whl")): |
38 | | - with open(path, "rb") as f: |
39 | | - sha256 = hashlib.sha256(f.read()).hexdigest() |
40 | 16 |
|
41 | | - with open("version", "r") as f: |
42 | | - full_version = f.read() |
| 17 | +index_dir = pathlib.Path(base_path) |
| 18 | +index_dir.mkdir(parents=True, exist_ok=True) |
| 19 | + |
| 20 | +with (index_dir / "index.html").open("w") as f: |
| 21 | + f.write( |
| 22 | + f"""<!DOCTYPE html> |
| 23 | +<h1>TileLang{vvver} Python Wheels</h1>\n""" |
| 24 | + ) |
| 25 | + |
| 26 | +for path in sorted(pathlib.Path("dist").glob("*.whl")): |
| 27 | + with open(path, "rb") as f: |
| 28 | + sha256 = hashlib.sha256(f.read()).hexdigest() |
43 | 29 |
|
44 | | - for cuda_version in cuda_versions: |
45 | | - index_dir = pathlib.Path(f"{base_path}/cu{cuda_version}") |
46 | | - index_dir.mkdir(exist_ok=True) |
47 | | - ver = full_version.replace("+", "%2B") |
48 | | - if args.mode != "nightly": |
49 | | - ver = 'v' + ver |
50 | | - full_url = f"{base_url}/{ver}/{path.name}#sha256={sha256}" |
51 | | - if cuda_version not in dir_set: |
52 | | - with (index_dir / "index.html").open("w") as f: |
53 | | - f.write( |
54 | | - f"""<!DOCTYPE html> |
55 | | - <h1>TileLang{vvver} Python Wheels for CUDA {cuda_version}</h1>\n""" |
56 | | - ) |
57 | | - with (pathlib.Path(base_path) / "index.html").open("a+") as f: |
58 | | - f.write( |
59 | | - f'<a href="cu{cuda_version}/">cu{cuda_version}</a><br>' |
60 | | - ) |
61 | | - dir_set.add(cuda_version) |
62 | | - with (index_dir / "index.html").open("a") as f: |
63 | | - f.write(f'<a href="{full_url}">{path.name}</a><br>\n') |
64 | | - break |
| 30 | + with open("version", "r") as f: |
| 31 | + full_version = f.read() |
65 | 32 |
|
66 | | -dir_list = [] |
| 33 | + ver = full_version.replace("+", "%2B") |
| 34 | + if args.mode != "nightly": |
| 35 | + ver = 'v' + ver |
| 36 | + full_url = f"{base_url}/{ver}/{path.name}#sha256={sha256}" |
| 37 | + with (index_dir / "index.html").open("a") as f: |
| 38 | + f.write(f'<a href="{full_url}">{path.name}</a><br>\n') |
| 39 | + break |
67 | 40 |
|
68 | | -for index_dir in pathlib.Path("tilelang-whl").iterdir(): |
69 | | - if index_dir.is_dir(): |
70 | | - if index_dir.name[0] != '.': |
71 | | - dir_list.append(index_dir.name) |
72 | | -dir_list.sort() |
73 | | -with (pathlib.Path("tilelang-whl") / "index.html").open("w") as f: |
74 | | - f.write( |
75 | | - """<!DOCTYPE html> |
| 41 | +if args.mode == "nightly": |
| 42 | + dir_list = [] |
| 43 | + for d in pathlib.Path("tilelang-whl").iterdir(): |
| 44 | + if d.is_dir() and not d.name.startswith('.'): |
| 45 | + dir_list.append(d.name) |
| 46 | + dir_list.sort() |
| 47 | + with (pathlib.Path("tilelang-whl") / "index.html").open("w") as f: |
| 48 | + f.write( |
| 49 | + """<!DOCTYPE html> |
76 | 50 | <h1>TileLang Python Wheels</h1>\n""" |
77 | | - ) |
78 | | -for dir_name in dir_list: |
79 | | - with (pathlib.Path("tilelang-whl") / "index.html").open("a") as f: |
80 | | - f.write(f'<a href="{dir_name}/">{dir_name}</a><br>\n') |
| 51 | + ) |
| 52 | + for dir_name in dir_list: |
| 53 | + with (pathlib.Path("tilelang-whl") / "index.html").open("a") as f: |
| 54 | + f.write(f'<a href="{dir_name}/">{dir_name}</a><br>\n') |
0 commit comments