1
+ import contextlib
2
+ import json
1
3
import pathlib
2
4
import shutil
3
- from datetime import datetime
5
+ import subprocess
6
+ from datetime import datetime , timezone
4
7
5
8
PYTHON_BUILD_DIR = pathlib .Path (__file__ ).parent
6
9
WHEEL_DIR = PYTHON_BUILD_DIR / "wheels"
@@ -19,6 +22,33 @@ def package_name(wheel_file: pathlib.Path) -> str:
19
22
return wheel_file .name .split ("-" )[0 ].replace ("_" , "-" )
20
23
21
24
25
+ # Get some extra context about the build
26
+ ts = datetime .now (timezone .utc ).isoformat ()
27
+ context_info : dict = {
28
+ "timestamp" : ts ,
29
+ }
30
+ with contextlib .suppress (Exception ):
31
+ branch_info = subprocess .check_output (
32
+ ["git" , "branch" , "--show-current" ], text = True
33
+ )
34
+ context_info ["branch" ] = branch_info .strip ()
35
+ with contextlib .suppress (Exception ):
36
+ commit_info = subprocess .check_output (
37
+ ["git" , "log" , "-1" , "--pretty=%H%n%B" ], text = True
38
+ )
39
+ commit_hash , commit_msg = commit_info .strip ().split ("\n " , 1 )
40
+ context_info ["commit" ] = {
41
+ "hash" : commit_hash ,
42
+ "message" : commit_msg .strip (),
43
+ }
44
+ with contextlib .suppress (Exception ):
45
+ pr_info = subprocess .check_output (
46
+ ["gh" , "pr" , "view" , "--json" , "title,number,url" ], text = True
47
+ )
48
+ pr_info = json .loads (pr_info )
49
+ context_info ["pr" ] = pr_info
50
+
51
+
22
52
newline = "\n "
23
53
(SITE_OUTPUT_DIR / "index.html" ).write_text (
24
54
f"""
@@ -36,8 +66,11 @@ def package_name(wheel_file: pathlib.Path) -> str:
36
66
<p>
37
67
These prebuilt wheel files can be used to install our Python packages as of a specific commit.
38
68
</p>
39
- <p>Built at { datetime .now ().strftime ("%Y-%m-%d %H:%M:%S" )} .</p>
40
69
70
+ <h2>Build context</h2>
71
+ <pre id="context-info">{ json .dumps (context_info , indent = 2 )} </pre>
72
+
73
+ <h2>Usage</h2>
41
74
<p>
42
75
Current base URL: <span class="base-url">unknown</span>
43
76
</p>
@@ -57,7 +90,7 @@ def package_name(wheel_file: pathlib.Path) -> str:
57
90
<tr>
58
91
<td><code>{ package_name (wheel_file )} </code></td>
59
92
<td>{ wheel_file .stat ().st_size / 1024 / 1024 :.3f} MB</td>
60
- <td><code>pip install '{ package_name (wheel_file )} @ <span class="base-url"><base-url></span>/artifacts/wheels/{ wheel_file .name } '</code></td>
93
+ <td><code>uv pip install '{ package_name (wheel_file )} @ <span class="base-url"><base-url></span>/artifacts/wheels/{ wheel_file .name } '</code></td>
61
94
</tr>
62
95
'''
63
96
for wheel_file in sorted (WHEEL_DIR .glob ("*.whl" ))
0 commit comments