Skip to content

Commit 274f549

Browse files
committed
global: run black on source code
1 parent 7e0d2ed commit 274f549

File tree

12 files changed

+2062
-1923
lines changed

12 files changed

+2062
-1923
lines changed

build-linux.py

Lines changed: 47 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,24 @@
1313

1414

1515
ROOT = 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

2525
def 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()

build-macos.py

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,18 @@
1313

1414

1515
ROOT = 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-macos'
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-macos"
2323

2424

2525
def bootstrap():
2626
parser = argparse.ArgumentParser()
27-
parser.add_argument('--optimized', action='store_true')
27+
parser.add_argument("--optimized", action="store_true")
2828

2929
args = parser.parse_args()
3030

@@ -33,15 +33,14 @@ def bootstrap():
3333

3434
venv.create(VENV, with_pip=True)
3535

36-
subprocess.run([str(PIP), 'install', '-r', str(REQUIREMENTS)],
37-
check=True)
36+
subprocess.run([str(PIP), "install", "-r", str(REQUIREMENTS)], check=True)
3837

39-
os.environ['PYBUILD_BOOTSTRAPPED'] = '1'
40-
os.environ['PATH'] = '%s:%s' % (str(VENV / 'bin'), os.environ['PATH'])
41-
os.environ['PYTHONPATH'] = str(ROOT)
38+
os.environ["PYBUILD_BOOTSTRAPPED"] = "1"
39+
os.environ["PATH"] = "%s:%s" % (str(VENV / "bin"), os.environ["PATH"])
40+
os.environ["PYTHONPATH"] = str(ROOT)
4241

4342
if args.optimized:
44-
os.environ['PYBUILD_OPTIMIZED'] = '1'
43+
os.environ["PYBUILD_OPTIMIZED"] = "1"
4544

4645
subprocess.run([str(PYTHON), __file__], check=True)
4746

@@ -53,30 +52,32 @@ def run():
5352
now = datetime.datetime.utcnow()
5453

5554
env = dict(os.environ)
56-
env['PYTHONUNBUFFERED'] = '1'
55+
env["PYTHONUNBUFFERED"] = "1"
5756

58-
subprocess.run(['make'],
59-
cwd=str(MAKE_DIR), env=env, check=True)
57+
subprocess.run(["make"], cwd=str(MAKE_DIR), env=env, check=True)
6058

61-
basename = 'cpython-macos'
62-
extra = ''
59+
basename = "cpython-macos"
60+
extra = ""
6361

64-
if 'PYBUILD_OPTIMIZED' in os.environ:
65-
basename += '-pgo'
66-
extra = '-pgo'
62+
if "PYBUILD_OPTIMIZED" in os.environ:
63+
basename += "-pgo"
64+
extra = "-pgo"
6765

68-
basename += '.tar'
66+
basename += ".tar"
6967

7068
source_path = BUILD / basename
7169

72-
compress_python_archive(source_path, DIST, 'cpython-%s-macos%s-%s' % (
73-
DOWNLOADS['cpython-3.7']['version'], extra,
74-
now.strftime('%Y%m%dT%H%M')))
70+
compress_python_archive(
71+
source_path,
72+
DIST,
73+
"cpython-%s-macos%s-%s"
74+
% (DOWNLOADS["cpython-3.7"]["version"], extra, now.strftime("%Y%m%dT%H%M")),
75+
)
7576

7677

77-
if __name__ == '__main__':
78+
if __name__ == "__main__":
7879
try:
79-
if 'PYBUILD_BOOTSTRAPPED' not in os.environ:
80+
if "PYBUILD_BOOTSTRAPPED" not in os.environ:
8081
bootstrap()
8182
else:
8283
run()

build-windows.py

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212

1313

1414
ROOT = pathlib.Path(os.path.abspath(__file__)).parent
15-
BUILD = ROOT / 'build'
16-
DIST = ROOT / 'dist'
17-
VENV = BUILD / 'venv'
18-
PIP = VENV / 'Scripts' / 'pip.exe'
19-
PYTHON = VENV / 'Scripts' / 'python.exe'
20-
REQUIREMENTS = ROOT / 'requirements.win.txt'
21-
WINDOWS_DIR = ROOT / 'cpython-windows'
15+
BUILD = ROOT / "build"
16+
DIST = ROOT / "dist"
17+
VENV = BUILD / "venv"
18+
PIP = VENV / "Scripts" / "pip.exe"
19+
PYTHON = VENV / "Scripts" / "python.exe"
20+
REQUIREMENTS = ROOT / "requirements.win.txt"
21+
WINDOWS_DIR = ROOT / "cpython-windows"
2222

2323

2424
def bootstrap():
@@ -27,12 +27,11 @@ def bootstrap():
2727

2828
venv.create(VENV, with_pip=True)
2929

30-
subprocess.run([str(PIP), 'install', '-r', str(REQUIREMENTS)],
31-
check=True)
30+
subprocess.run([str(PIP), "install", "-r", str(REQUIREMENTS)], check=True)
3231

33-
os.environ['PYBUILD_BOOTSTRAPPED'] = '1'
34-
os.environ['PATH'] = '%s;%s' % (str(VENV / 'bin'), os.environ['PATH'])
35-
os.environ['PYTHONPATH'] = str(ROOT)
32+
os.environ["PYBUILD_BOOTSTRAPPED"] = "1"
33+
os.environ["PATH"] = "%s;%s" % (str(VENV / "bin"), os.environ["PATH"])
34+
os.environ["PYTHONPATH"] = str(ROOT)
3635
subprocess.run([str(PYTHON), __file__], check=True)
3736

3837

@@ -43,23 +42,27 @@ def run():
4342
now = datetime.datetime.utcnow()
4443

4544
env = dict(os.environ)
46-
env['PYTHONUNBUFFERED'] = '1'
45+
env["PYTHONUNBUFFERED"] = "1"
4746

48-
arch = 'x86' if os.environ.get('Platform') == 'x86' else 'amd64'
47+
arch = "x86" if os.environ.get("Platform") == "x86" else "amd64"
4948

50-
subprocess.run([str(PYTHON), 'build.py'],
51-
cwd=str(WINDOWS_DIR), env=env, check=True,
52-
bufsize=0)
49+
subprocess.run(
50+
[str(PYTHON), "build.py"], cwd=str(WINDOWS_DIR), env=env, check=True, bufsize=0
51+
)
5352

54-
source_path = BUILD / ('cpython-windows-%s.tar' % arch)
53+
source_path = BUILD / ("cpython-windows-%s.tar" % arch)
5554

56-
compress_python_archive(source_path, DIST, 'cpython-%s-windows-%s-%s' % (
57-
DOWNLOADS['cpython-3.7']['version'], arch, now.strftime('%Y%m%dT%H%M')))
55+
compress_python_archive(
56+
source_path,
57+
DIST,
58+
"cpython-%s-windows-%s-%s"
59+
% (DOWNLOADS["cpython-3.7"]["version"], arch, now.strftime("%Y%m%dT%H%M")),
60+
)
5861

5962

60-
if __name__ == '__main__':
63+
if __name__ == "__main__":
6164
try:
62-
if 'PYBUILD_BOOTSTRAPPED' not in os.environ:
65+
if "PYBUILD_BOOTSTRAPPED" not in os.environ:
6366
bootstrap()
6467
else:
6568
run()

0 commit comments

Comments
 (0)