@@ -70,6 +70,40 @@ def compute_sha256(file_path: pathlib.Path) -> str:
70
70
return hashlib .sha256 (f .read ()).hexdigest ()
71
71
72
72
73
+ def generate_directory_index (directory : pathlib .Path ):
74
+ """Generate index.html for a directory listing its subdirectories."""
75
+ # Get all subdirectories
76
+ subdirs = sorted ([d for d in directory .iterdir () if d .is_dir ()])
77
+
78
+ if not subdirs :
79
+ return
80
+
81
+ index_file = directory / "index.html"
82
+
83
+ # Generate HTML for directory listing
84
+ with index_file .open ("w" ) as f :
85
+ f .write ("<!DOCTYPE html>\n " )
86
+ f .write ("<html>\n " )
87
+ f .write (f"<head><title>Index of { directory .name or 'root' } </title></head>\n " )
88
+ f .write ("<body>\n " )
89
+ f .write (f"<h1>Index of { directory .name or 'root' } </h1>\n " )
90
+
91
+ for subdir in subdirs :
92
+ f .write (f'<a href="{ subdir .name } /">{ subdir .name } /</a><br>\n ' )
93
+
94
+ f .write ("</body>\n " )
95
+ f .write ("</html>\n " )
96
+
97
+
98
+ def update_parent_indices (leaf_dir : pathlib .Path , root_dir : pathlib .Path ):
99
+ """Recursively update index.html for all parent directories."""
100
+ current = leaf_dir .parent
101
+
102
+ while current >= root_dir and current != current .parent :
103
+ generate_directory_index (current )
104
+ current = current .parent
105
+
106
+
73
107
def update_index (
74
108
dist_dir : str = "dist" ,
75
109
output_dir : str = "whl" ,
@@ -85,7 +119,7 @@ def update_index(
85
119
output_dir: Output directory for index files
86
120
base_url: Base URL for wheel downloads
87
121
release_tag: GitHub release tag (e.g., 'nightly' or 'v0.3.1')
88
- nightly: If True, update index to whl/nightly subdirectory
122
+ nightly: If True, update index to whl/nightly subdirectory for nightly releases
89
123
"""
90
124
dist_path = pathlib .Path (dist_dir )
91
125
if not dist_path .exists ():
@@ -99,6 +133,9 @@ def update_index(
99
133
100
134
print (f"Found { len (wheels )} wheel file(s)" )
101
135
136
+ # Track all directories that need parent index updates
137
+ created_dirs = set ()
138
+
102
139
for wheel_path in wheels :
103
140
print (f"\n Processing: { wheel_path .name } " )
104
141
@@ -128,6 +165,7 @@ def update_index(
128
165
index_dir = base_output / package
129
166
130
167
index_dir .mkdir (parents = True , exist_ok = True )
168
+ created_dirs .add (index_dir )
131
169
132
170
# Construct download URL
133
171
tag = release_tag or f"v{ info ['version' ].split ('+' )[0 ].split ('.dev' )[0 ]} "
@@ -171,6 +209,13 @@ def update_index(
171
209
print (f" 🎮 CUDA: cu{ cuda } " )
172
210
print (f" 📍 URL: { download_url } " )
173
211
212
+ # Update parent directory indices
213
+ print ("\n 📂 Updating parent directory indices..." )
214
+ root_output = pathlib .Path (output_dir )
215
+ for leaf_dir in created_dirs :
216
+ update_parent_indices (leaf_dir , root_output )
217
+ print (" ✅ Parent indices updated" )
218
+
174
219
175
220
def main ():
176
221
parser = argparse .ArgumentParser (
0 commit comments