Skip to content

Commit 1d270e7

Browse files
committed
Factor out build script
also, set SOURCE_DATE_EPOCH, and use python -I
1 parent 21fbe62 commit 1d270e7

File tree

3 files changed

+64
-4
lines changed

3 files changed

+64
-4
lines changed

.github/workflows/release.yml

+1-4
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,7 @@ jobs:
1313
steps:
1414
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
1515
- name: Build a binary wheel and a source tarball
16-
run: |
17-
python3 -m venv build-env
18-
build-env/bin/python -m pip install --no-deps --only-binary :all: --require-hashes -r build-requirements.txt
19-
build-env/bin/python -m build --no-isolation
16+
run: ./build-project.py
2017
- name: Store the distribution packages
2118
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4
2219
with:

MANIFEST.in

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ include pyproject.toml
77

88
include build-requirements.in
99
include build-requirements.txt
10+
include build-project.py
1011

1112
include src/pip/_vendor/README.rst
1213
include src/pip/_vendor/vendor.txt

build-project.py

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#!/usr/bin/env python3
2+
"""Build pip using pinned build requirements."""
3+
4+
import subprocess
5+
import sys
6+
import tempfile
7+
from pathlib import Path
8+
9+
10+
def get_git_head_timestamp() -> str:
11+
return subprocess.run(
12+
[
13+
"git",
14+
"log",
15+
"-1",
16+
"--pretty=format:%ct",
17+
],
18+
text=True,
19+
stdout=subprocess.PIPE,
20+
).stdout.strip()
21+
22+
23+
def main() -> None:
24+
with tempfile.TemporaryDirectory() as build_env:
25+
subprocess.run(
26+
[
27+
sys.executable,
28+
"-m",
29+
"venv",
30+
build_env,
31+
],
32+
check=True,
33+
)
34+
build_python = Path(build_env) / "bin" / "python"
35+
subprocess.run(
36+
[
37+
build_python,
38+
"-Im",
39+
"pip",
40+
"install",
41+
"--no-deps",
42+
"--only-binary=:all:",
43+
"--require-hashes",
44+
"-r",
45+
Path(__file__).parent / "build-requirements.txt",
46+
],
47+
check=True,
48+
)
49+
subprocess.run(
50+
[
51+
build_python,
52+
"-Im",
53+
"build",
54+
"--no-isolation",
55+
],
56+
check=True,
57+
env={"SOURCE_DATE_EPOCH": get_git_head_timestamp()},
58+
)
59+
60+
61+
if __name__ == "__main__":
62+
main()

0 commit comments

Comments
 (0)