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