File tree Expand file tree Collapse file tree 1 file changed +18
-13
lines changed Expand file tree Collapse file tree 1 file changed +18
-13
lines changed Original file line number Diff line number Diff line change 2
2
"""Build pip using pinned build requirements."""
3
3
4
4
import subprocess
5
- import sys
6
5
import tempfile
6
+ import venv
7
+ from os import PathLike
7
8
from pathlib import Path
9
+ from types import SimpleNamespace
10
+
11
+
12
+ class EnvBuilder (venv .EnvBuilder ):
13
+ """A subclass of venv.EnvBuilder that exposes the python executable command."""
14
+
15
+ def ensure_directories (
16
+ self , env_dir : str | bytes | PathLike [str ] | PathLike [bytes ]
17
+ ) -> SimpleNamespace :
18
+ context = super ().ensure_directories (env_dir )
19
+ self .env_exec_cmd = context .env_exec_cmd
20
+ return context
8
21
9
22
10
23
def get_git_head_timestamp () -> str :
@@ -22,19 +35,11 @@ def get_git_head_timestamp() -> str:
22
35
23
36
def main () -> None :
24
37
with tempfile .TemporaryDirectory () as build_env :
38
+ env_builder = EnvBuilder (with_pip = True )
39
+ env_builder .create (build_env )
25
40
subprocess .run (
26
41
[
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 ,
42
+ env_builder .env_exec_cmd ,
38
43
"-Im" ,
39
44
"pip" ,
40
45
"install" ,
@@ -48,7 +53,7 @@ def main() -> None:
48
53
)
49
54
subprocess .run (
50
55
[
51
- build_python ,
56
+ env_builder . env_exec_cmd ,
52
57
"-Im" ,
53
58
"build" ,
54
59
"--no-isolation" ,
You can’t perform that action at this time.
0 commit comments