@@ -214,16 +214,16 @@ def add_target_env(env, build_platform, target_triple, build_env):
214
214
env ["EXTRA_TARGET_LDFLAGS" ] = " " .join (extra_target_ldflags )
215
215
216
216
217
- def toolchain_archive_path (package_name , host_platform , downloads ):
217
+ def toolchain_archive_path (package_name , host_platform , * , downloads : Downloads ):
218
218
entry = downloads [package_name ]
219
219
220
220
basename = "%s-%s-%s.tar" % (package_name , entry ["version" ], host_platform )
221
221
222
222
return BUILD / basename
223
223
224
224
225
- def install_binutils (platform ):
226
- return platform != "macos"
225
+ def install_binutils (host_platform ):
226
+ return host_platform != "macos"
227
227
228
228
229
229
def simple_build (
@@ -234,12 +234,13 @@ def simple_build(
234
234
host_platform ,
235
235
target_triple ,
236
236
optimizations ,
237
- downloads : Downloads ,
238
237
dest_archive ,
239
238
extra_archives = None ,
240
239
tools_path = "deps" ,
240
+ * ,
241
+ downloads : Downloads ,
241
242
):
242
- archive = download_entry (entry , DOWNLOADS_PATH , downloads )
243
+ archive = download_entry (entry , DOWNLOADS_PATH , downloads = downloads )
243
244
244
245
with build_environment (client , image ) as build_env :
245
246
if settings .get ("needs_toolchain" ):
@@ -250,6 +251,7 @@ def simple_build(
250
251
binutils = install_binutils (host_platform ),
251
252
clang = True ,
252
253
musl = "musl" in target_triple ,
254
+ downloads = downloads ,
253
255
)
254
256
255
257
for a in extra_archives or []:
@@ -275,9 +277,9 @@ def simple_build(
275
277
build_env .get_tools_archive (dest_archive , tools_path )
276
278
277
279
278
- def build_binutils (client , image , host_platform , downloads ):
280
+ def build_binutils (client , image , host_platform , * , downloads : Downloads ):
279
281
"""Build binutils in the Docker image."""
280
- archive = download_entry ("binutils" , DOWNLOADS_PATH , downloads )
282
+ archive = download_entry ("binutils" , DOWNLOADS_PATH , downloads = downloads )
281
283
282
284
with build_environment (client , image ) as build_env :
283
285
install_sccache (build_env )
@@ -295,13 +297,18 @@ def build_binutils(client, image, host_platform, downloads):
295
297
)
296
298
297
299
build_env .get_tools_archive (
298
- toolchain_archive_path ("binutils" , host_platform , downloads ), "host"
300
+ toolchain_archive_path (
301
+ "binutils" ,
302
+ host_platform ,
303
+ downloads = downloads ,
304
+ ),
305
+ "host" ,
299
306
)
300
307
301
308
302
- def materialize_clang (host_platform : str , target_triple : str , downloads ):
309
+ def materialize_clang (host_platform : str , target_triple : str , * , downloads : Downloads ):
303
310
entry = clang_toolchain (host_platform , target_triple )
304
- tar_zst = download_entry (entry , DOWNLOADS_PATH , downloads )
311
+ tar_zst = download_entry (entry , DOWNLOADS_PATH , downloads = downloads )
305
312
local_filename = "%s-%s-%s.tar" % (
306
313
entry ,
307
314
downloads [entry ]["version" ],
@@ -315,12 +322,24 @@ def materialize_clang(host_platform: str, target_triple: str, downloads):
315
322
dctx .copy_stream (ifh , ofh )
316
323
317
324
318
- def build_musl (client , image , host_platform : str , target_triple : str , downloads ):
319
- musl_archive = download_entry ("musl" , DOWNLOADS_PATH , downloads )
325
+ def build_musl (
326
+ client ,
327
+ image ,
328
+ host_platform : str ,
329
+ target_triple : str ,
330
+ * ,
331
+ downloads : Downloads ,
332
+ ):
333
+ musl_archive = download_entry ("musl" , DOWNLOADS_PATH , downloads = downloads )
320
334
321
335
with build_environment (client , image ) as build_env :
322
336
build_env .install_toolchain (
323
- BUILD , host_platform , target_triple , binutils = True , clang = True
337
+ BUILD ,
338
+ host_platform ,
339
+ target_triple ,
340
+ binutils = True ,
341
+ clang = True ,
342
+ downloads = downloads ,
324
343
)
325
344
build_env .copy_file (musl_archive )
326
345
build_env .copy_file (SUPPORT / "build-musl.sh" )
@@ -333,7 +352,12 @@ def build_musl(client, image, host_platform: str, target_triple: str, downloads)
333
352
build_env .run ("build-musl.sh" , environment = env )
334
353
335
354
build_env .get_tools_archive (
336
- toolchain_archive_path ("musl" , host_platform ), "host"
355
+ toolchain_archive_path (
356
+ "musl" ,
357
+ host_platform ,
358
+ downloads = downloads ,
359
+ ),
360
+ "host" ,
337
361
)
338
362
339
363
@@ -345,9 +369,10 @@ def build_libedit(
345
369
target_triple ,
346
370
optimizations ,
347
371
dest_archive ,
372
+ * ,
348
373
downloads : Downloads ,
349
374
):
350
- libedit_archive = download_entry ("libedit" , DOWNLOADS_PATH , downloads )
375
+ libedit_archive = download_entry ("libedit" , DOWNLOADS_PATH , downloads = downloads )
351
376
352
377
with build_environment (client , image ) as build_env :
353
378
if settings .get ("needs_toolchain" ):
@@ -358,6 +383,7 @@ def build_libedit(
358
383
binutils = install_binutils (host_platform ),
359
384
clang = True ,
360
385
musl = "musl" in target_triple ,
386
+ downloads = downloads ,
361
387
)
362
388
363
389
build_env .install_artifact_archive (
@@ -384,11 +410,12 @@ def build_tix(
384
410
target_triple ,
385
411
optimizations ,
386
412
dest_archive ,
413
+ * ,
387
414
downloads : Downloads ,
388
415
):
389
- tcl_archive = download_entry ("tcl" , DOWNLOADS_PATH , downloads )
390
- tk_archive = download_entry ("tk" , DOWNLOADS_PATH , downloads )
391
- tix_archive = download_entry ("tix" , DOWNLOADS_PATH , downloads )
416
+ tcl_archive = download_entry ("tcl" , DOWNLOADS_PATH , downloads = downloads )
417
+ tk_archive = download_entry ("tk" , DOWNLOADS_PATH , downloads = downloads )
418
+ tix_archive = download_entry ("tix" , DOWNLOADS_PATH , downloads = downloads )
392
419
393
420
with build_environment (client , image ) as build_env :
394
421
if settings .get ("needs_toolchain" ):
@@ -399,6 +426,7 @@ def build_tix(
399
426
binutils = install_binutils (host_platform ),
400
427
clang = True ,
401
428
musl = "musl" in target_triple ,
429
+ downloads = downloads ,
402
430
)
403
431
404
432
depends = {"tcl" , "tk" }
@@ -432,10 +460,11 @@ def build_cpython_host(
432
460
target_triple : str ,
433
461
optimizations : str ,
434
462
dest_archive ,
463
+ * ,
435
464
downloads : Downloads ,
436
465
):
437
466
"""Build binutils in the Docker image."""
438
- archive = download_entry (entry , DOWNLOADS_PATH , downloads )
467
+ archive = download_entry (entry , DOWNLOADS_PATH , downloads = downloads )
439
468
440
469
with build_environment (client , image ) as build_env :
441
470
python_version = downloads [entry ]["version" ]
@@ -446,6 +475,7 @@ def build_cpython_host(
446
475
target_triple ,
447
476
binutils = install_binutils (host_platform ),
448
477
clang = True ,
478
+ downloads = downloads ,
449
479
)
450
480
451
481
build_env .copy_file (archive )
@@ -492,12 +522,13 @@ def build_cpython_host(
492
522
def python_build_info (
493
523
build_env ,
494
524
version ,
495
- platform ,
525
+ host_platform ,
496
526
target_triple ,
497
527
musl ,
498
528
optimizations ,
499
529
extensions ,
500
530
extra_metadata ,
531
+ * ,
501
532
downloads : Downloads ,
502
533
):
503
534
"""Obtain build metadata for the Python distribution."""
@@ -508,7 +539,7 @@ def python_build_info(
508
539
509
540
binary_suffix = ""
510
541
511
- if platform == "linux64" :
542
+ if host_platform == "linux64" :
512
543
bi ["core" ]["static_lib" ] = (
513
544
"install/lib/python{version}/config-{version}{binary_suffix}-x86_64-linux-gnu/libpython{version}{binary_suffix}.a" .format (
514
545
version = version , binary_suffix = binary_suffix
@@ -522,7 +553,7 @@ def python_build_info(
522
553
)
523
554
524
555
if optimizations in ("lto" , "pgo+lto" ):
525
- llvm_version = downloads [clang_toolchain (platform , target_triple )][
556
+ llvm_version = downloads [clang_toolchain (host_platform , target_triple )][
526
557
"version"
527
558
]
528
559
if "+" in llvm_version :
@@ -531,7 +562,7 @@ def python_build_info(
531
562
object_file_format = f"llvm-bitcode:%{ llvm_version } "
532
563
else :
533
564
object_file_format = "elf"
534
- elif platform == "macos" :
565
+ elif host_platform == "macos" :
535
566
bi ["core" ]["static_lib" ] = (
536
567
"install/lib/python{version}/config-{version}{binary_suffix}-darwin/libpython{version}{binary_suffix}.a" .format (
537
568
version = version , binary_suffix = binary_suffix
@@ -549,7 +580,7 @@ def python_build_info(
549
580
else :
550
581
object_file_format = "mach-o"
551
582
else :
552
- raise Exception ("unsupported platform: %s" % platform )
583
+ raise Exception ("unsupported platform: %s" % host_platform )
553
584
554
585
bi ["object_file_format" ] = object_file_format
555
586
@@ -564,9 +595,9 @@ def python_build_info(
564
595
if lib .startswith ("-l" ):
565
596
lib = lib [2 :]
566
597
567
- if platform == "linux64" and lib not in LINUX_ALLOW_SYSTEM_LIBRARIES :
598
+ if host_platform == "linux64" and lib not in LINUX_ALLOW_SYSTEM_LIBRARIES :
568
599
raise Exception ("unexpected library in LIBS (%s): %s" % (libs , lib ))
569
- elif platform == "macos" and lib not in MACOS_ALLOW_SYSTEM_LIBRARIES :
600
+ elif host_platform == "macos" and lib not in MACOS_ALLOW_SYSTEM_LIBRARIES :
570
601
raise Exception ("unexpected library in LIBS (%s): %s" % (libs , lib ))
571
602
572
603
log ("adding core system link library: %s" % lib )
@@ -681,7 +712,7 @@ def python_build_info(
681
712
extension_suffix = extra_metadata ["python_config_vars" ]["EXT_SUFFIX" ]
682
713
entry ["shared_lib" ] = "%s/%s%s" % (shared_dir , extension , extension_suffix )
683
714
684
- add_licenses_to_extension_entry (entry )
715
+ add_licenses_to_extension_entry (entry , downloads = downloads )
685
716
686
717
bi ["extensions" ].setdefault (extension , []).append (entry )
687
718
@@ -701,17 +732,18 @@ def build_cpython(
701
732
host_platform ,
702
733
target_triple ,
703
734
optimizations ,
704
- downloads : Downloads ,
705
735
dest_archive ,
706
736
version = None ,
707
737
python_source = None ,
738
+ * ,
739
+ downloads : Downloads ,
708
740
):
709
741
"""Build CPython in a Docker image'"""
710
742
entry_name = "cpython-%s" % version
711
743
entry = downloads [entry_name ]
712
744
if not python_source :
713
745
python_version = entry ["version" ]
714
- python_archive = download_entry (entry_name , DOWNLOADS_PATH , downloads )
746
+ python_archive = download_entry (entry_name , DOWNLOADS_PATH , downloads = downloads )
715
747
else :
716
748
python_version = os .environ ["PYBUILD_PYTHON_VERSION" ]
717
749
python_archive = DOWNLOADS_PATH / ("Python-%s.tar.xz" % python_version )
@@ -721,8 +753,10 @@ def build_cpython(
721
753
fh , python_source , path_prefix = "Python-%s" % python_version
722
754
)
723
755
724
- setuptools_archive = download_entry ("setuptools" , DOWNLOADS_PATH , downloads )
725
- pip_archive = download_entry ("pip" , DOWNLOADS_PATH , downloads )
756
+ setuptools_archive = download_entry (
757
+ "setuptools" , DOWNLOADS_PATH , downloads = downloads
758
+ )
759
+ pip_archive = download_entry ("pip" , DOWNLOADS_PATH , downloads = downloads )
726
760
727
761
ems = extension_modules_config (EXTENSION_MODULES )
728
762
@@ -746,6 +780,7 @@ def build_cpython(
746
780
binutils = install_binutils (host_platform ),
747
781
clang = True ,
748
782
musl = "musl" in target_triple ,
783
+ downloads = downloads ,
749
784
)
750
785
751
786
packages = target_needs (TARGETS_CONFIG , target_triple , python_version )
@@ -1008,9 +1043,9 @@ def main():
1008
1043
write_dockerfiles (SUPPORT , BUILD )
1009
1044
elif action == "makefiles" :
1010
1045
targets = get_targets (TARGETS_CONFIG )
1011
- write_triples_makefiles (targets , BUILD , SUPPORT )
1046
+ write_triples_makefiles (targets , BUILD , SUPPORT , downloads = downloads )
1012
1047
write_target_settings (targets , BUILD / "targets" )
1013
- write_package_versions (BUILD / "versions" )
1048
+ write_package_versions (BUILD / "versions" , downloads = downloads )
1014
1049
1015
1050
# Override the DOWNLOADS package entry for CPython for the local build
1016
1051
if python_source :
@@ -1056,9 +1091,9 @@ def main():
1056
1091
target_triple = target_triple ,
1057
1092
optimizations = optimizations ,
1058
1093
dest_archive = dest_archive ,
1059
- downloads = downloads ,
1060
1094
tools_path = "host" ,
1061
1095
extra_archives = ["m4" ],
1096
+ downloads = downloads ,
1062
1097
)
1063
1098
1064
1099
elif action == "libedit" :
@@ -1110,8 +1145,8 @@ def main():
1110
1145
target_triple = target_triple ,
1111
1146
optimizations = optimizations ,
1112
1147
dest_archive = dest_archive ,
1113
- downloads = downloads ,
1114
1148
tools_path = tools_path ,
1149
+ downloads = downloads ,
1115
1150
)
1116
1151
1117
1152
elif action == "libX11" :
@@ -1243,9 +1278,9 @@ def main():
1243
1278
target_triple = target_triple ,
1244
1279
optimizations = optimizations ,
1245
1280
dest_archive = dest_archive ,
1246
- downloads = downloads ,
1247
1281
version = action .split ("-" )[1 ],
1248
1282
python_source = python_source ,
1283
+ downloads = downloads ,
1249
1284
)
1250
1285
1251
1286
else :
0 commit comments