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 22"""Build pip using pinned build requirements."""
33
44import subprocess
5- import sys
65import tempfile
6+ import venv
7+ from os import PathLike
78from 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
821
922
1023def get_git_head_timestamp () -> str :
@@ -22,19 +35,11 @@ def get_git_head_timestamp() -> str:
2235
2336def main () -> None :
2437 with tempfile .TemporaryDirectory () as build_env :
38+ env_builder = EnvBuilder (with_pip = True )
39+ env_builder .create (build_env )
2540 subprocess .run (
2641 [
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 ,
3843 "-Im" ,
3944 "pip" ,
4045 "install" ,
@@ -48,7 +53,7 @@ def main() -> None:
4853 )
4954 subprocess .run (
5055 [
51- build_python ,
56+ env_builder . env_exec_cmd ,
5257 "-Im" ,
5358 "build" ,
5459 "--no-isolation" ,
You can’t perform that action at this time.
0 commit comments