3
3
# License, v. 2.0. If a copy of the MPL was not distributed with this
4
4
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
5
5
6
- import argparse
7
- import datetime
8
6
import os
9
7
import pathlib
10
8
import subprocess
14
12
15
13
ROOT = pathlib .Path (os .path .abspath (__file__ )).parent
16
14
BUILD = ROOT / "build"
17
- DIST = ROOT / "dist"
18
15
VENV = BUILD / "venv.linux"
19
16
PIP = VENV / "bin" / "pip"
20
17
PYTHON = VENV / "bin" / "python"
23
20
24
21
25
22
def bootstrap ():
26
- parser = argparse .ArgumentParser ()
27
- parser .add_argument ("--debug" , action = "store_true" )
28
- parser .add_argument ("--libressl" , action = "store_true" )
29
- parser .add_argument ("--musl" , action = "store_true" )
30
- parser .add_argument ("--optimized" , action = "store_true" )
31
- parser .add_argument (
32
- "--python" , default = "cpython-3.7" , help = "name of Python to build"
33
- )
34
-
35
- args = parser .parse_args ()
36
-
37
23
BUILD .mkdir (exist_ok = True )
38
- DIST .mkdir (exist_ok = True )
39
24
40
25
venv .create (VENV , with_pip = True )
41
26
@@ -45,57 +30,22 @@ def bootstrap():
45
30
os .environ ["PATH" ] = "%s:%s" % (str (VENV / "bin" ), os .environ ["PATH" ])
46
31
os .environ ["PYTHONPATH" ] = str (ROOT )
47
32
48
- if args .debug :
49
- os .environ ["PYBUILD_DEBUG" ] = "1"
50
- if args .libressl :
51
- os .environ ["PYBUILD_LIBRESSL" ] = "1"
52
- if args .musl :
53
- os .environ ["PYBUILD_MUSL" ] = "1"
54
- if args .optimized :
55
- os .environ ["PYBUILD_OPTIMIZED" ] = "1"
56
- os .environ ["PYBUILD_PYTHON" ] = args .python
57
- os .environ ["PYBUILD_UNIX_PLATFORM" ] = "linux64"
33
+ args = [str (PYTHON ), __file__ , * sys .argv [1 :]]
58
34
59
- subprocess .run ([ str ( PYTHON ), __file__ ] , check = True )
35
+ subprocess .run (args , check = True )
60
36
61
37
62
38
def run ():
63
- from pythonbuild .downloads import DOWNLOADS
64
- from pythonbuild .utils import compress_python_archive
65
-
66
- now = datetime .datetime .utcnow ()
67
-
68
39
env = dict (os .environ )
69
40
env ["PYTHONUNBUFFERED" ] = "1"
70
41
71
- entry = DOWNLOADS [os .environ ["PYBUILD_PYTHON" ]]
72
- env ["PYBUILD_PYTHON_VERSION" ] = entry ["version" ]
73
- env ["PYBUILD_PYTHON_MAJOR_VERSION" ] = "." .join (entry ["version" ].split ("." )[0 :2 ])
74
-
75
- subprocess .run (["make" ], cwd = str (MAKE_DIR ), env = env , check = True )
76
-
77
- basename = "cpython-%s-linux64" % entry ["version" ]
78
- extra = ""
79
-
80
- if "PYBUILD_MUSL" in os .environ :
81
- basename += "-musl"
82
- extra = "-musl"
83
- if "PYBUILD_DEBUG" in os .environ :
84
- basename += "-debug"
85
- extra += "-debug"
86
- if "PYBUILD_OPTIMIZED" in os .environ :
87
- basename += "-pgo"
88
- extra = "-pgo"
89
-
90
- basename += ".tar"
91
-
92
- source_path = BUILD / basename
93
- compress_python_archive (
94
- source_path ,
95
- DIST ,
96
- "cpython-%s-linux64%s-%s"
97
- % (entry ["version" ], extra , now .strftime ("%Y%m%dT%H%M" )),
98
- )
42
+ args = [
43
+ str (PYTHON ),
44
+ "build-main.py" ,
45
+ * sys .argv [1 :],
46
+ ]
47
+
48
+ subprocess .run (args , cwd = str (MAKE_DIR ), env = env , check = True )
99
49
100
50
101
51
if __name__ == "__main__" :
0 commit comments