1313
1414
1515ROOT = pathlib .Path (os .path .abspath (__file__ )).parent
16- BUILD = ROOT / ' build'
17- DIST = ROOT / ' dist'
18- VENV = BUILD / ' venv'
19- PIP = VENV / ' bin' / ' pip'
20- PYTHON = VENV / ' bin' / ' python'
21- REQUIREMENTS = ROOT / ' requirements.txt'
22- MAKE_DIR = ROOT / ' cpython-unix'
16+ BUILD = ROOT / " build"
17+ DIST = ROOT / " dist"
18+ VENV = BUILD / " venv"
19+ PIP = VENV / " bin" / " pip"
20+ PYTHON = VENV / " bin" / " python"
21+ REQUIREMENTS = ROOT / " requirements.txt"
22+ MAKE_DIR = ROOT / " cpython-unix"
2323
2424
2525def bootstrap ():
2626 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 ('--python' ,
32- default = ' cpython-3.7' ,
33- help = 'name of Python to build' )
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+ )
3434
3535 args = parser .parse_args ()
3636
@@ -39,22 +39,21 @@ def bootstrap():
3939
4040 venv .create (VENV , with_pip = True )
4141
42- subprocess .run ([str (PIP ), 'install' , '-r' , str (REQUIREMENTS )],
43- check = True )
42+ subprocess .run ([str (PIP ), "install" , "-r" , str (REQUIREMENTS )], check = True )
4443
45- os .environ [' PYBUILD_BOOTSTRAPPED' ] = '1'
46- os .environ [' PATH' ] = ' %s:%s' % (str (VENV / ' bin' ), os .environ [' PATH' ])
47- os .environ [' PYTHONPATH' ] = str (ROOT )
44+ os .environ [" PYBUILD_BOOTSTRAPPED" ] = "1"
45+ os .environ [" PATH" ] = " %s:%s" % (str (VENV / " bin" ), os .environ [" PATH" ])
46+ os .environ [" PYTHONPATH" ] = str (ROOT )
4847
4948 if args .debug :
50- os .environ [' PYBUILD_DEBUG' ] = '1'
49+ os .environ [" PYBUILD_DEBUG" ] = "1"
5150 if args .libressl :
52- os .environ [' PYBUILD_LIBRESSL' ] = '1'
51+ os .environ [" PYBUILD_LIBRESSL" ] = "1"
5352 if args .musl :
54- os .environ [' PYBUILD_MUSL' ] = '1'
53+ os .environ [" PYBUILD_MUSL" ] = "1"
5554 if args .optimized :
56- os .environ [' PYBUILD_OPTIMIZED' ] = '1'
57- os .environ [' PYBUILD_PYTHON' ] = args .python
55+ os .environ [" PYBUILD_OPTIMIZED" ] = "1"
56+ os .environ [" PYBUILD_PYTHON" ] = args .python
5857
5958 subprocess .run ([str (PYTHON ), __file__ ], check = True )
6059
@@ -66,38 +65,40 @@ def run():
6665 now = datetime .datetime .utcnow ()
6766
6867 env = dict (os .environ )
69- env [' PYTHONUNBUFFERED' ] = '1'
68+ env [" PYTHONUNBUFFERED" ] = "1"
7069
71- entry = DOWNLOADS [os .environ [' PYBUILD_PYTHON' ]]
72- env [' PYBUILD_PYTHON_VERSION' ] = entry [' version' ]
70+ entry = DOWNLOADS [os .environ [" PYBUILD_PYTHON" ]]
71+ env [" PYBUILD_PYTHON_VERSION" ] = entry [" version" ]
7372
74- subprocess .run (['make' ],
75- cwd = str (MAKE_DIR ), env = env , check = True )
73+ subprocess .run (["make" ], cwd = str (MAKE_DIR ), env = env , check = True )
7674
77- basename = ' cpython-%s-linux64' % entry [' version' ]
78- extra = ''
75+ basename = " cpython-%s-linux64" % entry [" version" ]
76+ extra = ""
7977
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'
78+ if " PYBUILD_MUSL" in os .environ :
79+ basename += " -musl"
80+ extra = " -musl"
81+ if " PYBUILD_DEBUG" in os .environ :
82+ basename += " -debug"
83+ extra += " -debug"
84+ if " PYBUILD_OPTIMIZED" in os .environ :
85+ basename += " -pgo"
86+ extra = " -pgo"
8987
90- basename += ' .tar'
88+ basename += " .tar"
9189
9290 source_path = BUILD / basename
93- compress_python_archive (source_path , DIST , 'cpython-%s-linux64%s-%s' % (
94- entry ['version' ], extra ,
95- now .strftime ('%Y%m%dT%H%M' )))
91+ compress_python_archive (
92+ source_path ,
93+ DIST ,
94+ "cpython-%s-linux64%s-%s"
95+ % (entry ["version" ], extra , now .strftime ("%Y%m%dT%H%M" )),
96+ )
9697
9798
98- if __name__ == ' __main__' :
99+ if __name__ == " __main__" :
99100 try :
100- if ' PYBUILD_BOOTSTRAPPED' not in os .environ :
101+ if " PYBUILD_BOOTSTRAPPED" not in os .environ :
101102 bootstrap ()
102103 else :
103104 run ()
0 commit comments