@@ -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,10 +251,13 @@ 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 []:
256
- build_env .install_artifact_archive (BUILD , a , target_triple , optimizations )
258
+ build_env .install_artifact_archive (
259
+ BUILD , a , target_triple , optimizations , downloads = downloads
260
+ )
257
261
258
262
build_env .copy_file (archive )
259
263
build_env .copy_file (SUPPORT / ("build-%s.sh" % entry ))
@@ -275,9 +279,9 @@ def simple_build(
275
279
build_env .get_tools_archive (dest_archive , tools_path )
276
280
277
281
278
- def build_binutils (client , image , host_platform , downloads ):
282
+ def build_binutils (client , image , host_platform , * , downloads : Downloads ):
279
283
"""Build binutils in the Docker image."""
280
- archive = download_entry ("binutils" , DOWNLOADS_PATH , downloads )
284
+ archive = download_entry ("binutils" , DOWNLOADS_PATH , downloads = downloads )
281
285
282
286
with build_environment (client , image ) as build_env :
283
287
install_sccache (build_env )
@@ -295,13 +299,18 @@ def build_binutils(client, image, host_platform, downloads):
295
299
)
296
300
297
301
build_env .get_tools_archive (
298
- toolchain_archive_path ("binutils" , host_platform , downloads ), "host"
302
+ toolchain_archive_path (
303
+ "binutils" ,
304
+ host_platform ,
305
+ downloads = downloads ,
306
+ ),
307
+ "host" ,
299
308
)
300
309
301
310
302
- def materialize_clang (host_platform : str , target_triple : str , downloads ):
311
+ def materialize_clang (host_platform : str , target_triple : str , * , downloads : Downloads ):
303
312
entry = clang_toolchain (host_platform , target_triple )
304
- tar_zst = download_entry (entry , DOWNLOADS_PATH , downloads )
313
+ tar_zst = download_entry (entry , DOWNLOADS_PATH , downloads = downloads )
305
314
local_filename = "%s-%s-%s.tar" % (
306
315
entry ,
307
316
downloads [entry ]["version" ],
@@ -315,12 +324,24 @@ def materialize_clang(host_platform: str, target_triple: str, downloads):
315
324
dctx .copy_stream (ifh , ofh )
316
325
317
326
318
- def build_musl (client , image , host_platform : str , target_triple : str , downloads ):
319
- musl_archive = download_entry ("musl" , DOWNLOADS_PATH , downloads )
327
+ def build_musl (
328
+ client ,
329
+ image ,
330
+ host_platform : str ,
331
+ target_triple : str ,
332
+ * ,
333
+ downloads : Downloads ,
334
+ ):
335
+ musl_archive = download_entry ("musl" , DOWNLOADS_PATH , downloads = downloads )
320
336
321
337
with build_environment (client , image ) as build_env :
322
338
build_env .install_toolchain (
323
- BUILD , host_platform , target_triple , binutils = True , clang = True
339
+ BUILD ,
340
+ host_platform ,
341
+ target_triple ,
342
+ binutils = True ,
343
+ clang = True ,
344
+ downloads = downloads ,
324
345
)
325
346
build_env .copy_file (musl_archive )
326
347
build_env .copy_file (SUPPORT / "build-musl.sh" )
@@ -333,7 +354,12 @@ def build_musl(client, image, host_platform: str, target_triple: str, downloads)
333
354
build_env .run ("build-musl.sh" , environment = env )
334
355
335
356
build_env .get_tools_archive (
336
- toolchain_archive_path ("musl" , host_platform ), "host"
357
+ toolchain_archive_path (
358
+ "musl" ,
359
+ host_platform ,
360
+ downloads = downloads ,
361
+ ),
362
+ "host" ,
337
363
)
338
364
339
365
@@ -345,9 +371,10 @@ def build_libedit(
345
371
target_triple ,
346
372
optimizations ,
347
373
dest_archive ,
374
+ * ,
348
375
downloads : Downloads ,
349
376
):
350
- libedit_archive = download_entry ("libedit" , DOWNLOADS_PATH , downloads )
377
+ libedit_archive = download_entry ("libedit" , DOWNLOADS_PATH , downloads = downloads )
351
378
352
379
with build_environment (client , image ) as build_env :
353
380
if settings .get ("needs_toolchain" ):
@@ -358,10 +385,11 @@ def build_libedit(
358
385
binutils = install_binutils (host_platform ),
359
386
clang = True ,
360
387
musl = "musl" in target_triple ,
388
+ downloads = downloads ,
361
389
)
362
390
363
391
build_env .install_artifact_archive (
364
- BUILD , "ncurses" , target_triple , optimizations
392
+ BUILD , "ncurses" , target_triple , optimizations , downloads = downloads
365
393
)
366
394
build_env .copy_file (libedit_archive )
367
395
build_env .copy_file (SUPPORT / "build-libedit.sh" )
@@ -384,11 +412,12 @@ def build_tix(
384
412
target_triple ,
385
413
optimizations ,
386
414
dest_archive ,
415
+ * ,
387
416
downloads : Downloads ,
388
417
):
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 )
418
+ tcl_archive = download_entry ("tcl" , DOWNLOADS_PATH , downloads = downloads )
419
+ tk_archive = download_entry ("tk" , DOWNLOADS_PATH , downloads = downloads )
420
+ tix_archive = download_entry ("tix" , DOWNLOADS_PATH , downloads = downloads )
392
421
393
422
with build_environment (client , image ) as build_env :
394
423
if settings .get ("needs_toolchain" ):
@@ -399,14 +428,17 @@ def build_tix(
399
428
binutils = install_binutils (host_platform ),
400
429
clang = True ,
401
430
musl = "musl" in target_triple ,
431
+ downloads = downloads ,
402
432
)
403
433
404
434
depends = {"tcl" , "tk" }
405
435
if host_platform != "macos" :
406
436
depends |= {"libX11" , "xorgproto" }
407
437
408
438
for p in sorted (depends ):
409
- build_env .install_artifact_archive (BUILD , p , target_triple , optimizations )
439
+ build_env .install_artifact_archive (
440
+ BUILD , p , target_triple , optimizations , downloads = downloads
441
+ )
410
442
411
443
for p in (tcl_archive , tk_archive , tix_archive , SUPPORT / "build-tix.sh" ):
412
444
build_env .copy_file (p )
@@ -432,10 +464,11 @@ def build_cpython_host(
432
464
target_triple : str ,
433
465
optimizations : str ,
434
466
dest_archive ,
467
+ * ,
435
468
downloads : Downloads ,
436
469
):
437
470
"""Build binutils in the Docker image."""
438
- archive = download_entry (entry , DOWNLOADS_PATH , downloads )
471
+ archive = download_entry (entry , DOWNLOADS_PATH , downloads = downloads )
439
472
440
473
with build_environment (client , image ) as build_env :
441
474
python_version = downloads [entry ]["version" ]
@@ -446,6 +479,7 @@ def build_cpython_host(
446
479
target_triple ,
447
480
binutils = install_binutils (host_platform ),
448
481
clang = True ,
482
+ downloads = downloads ,
449
483
)
450
484
451
485
build_env .copy_file (archive )
@@ -463,7 +497,9 @@ def build_cpython_host(
463
497
"m4" ,
464
498
}
465
499
for p in sorted (packages ):
466
- build_env .install_artifact_archive (BUILD , p , target_triple , optimizations )
500
+ build_env .install_artifact_archive (
501
+ BUILD , p , target_triple , optimizations , downloads = downloads
502
+ )
467
503
468
504
env = {
469
505
"PYTHON_VERSION" : python_version ,
@@ -492,12 +528,13 @@ def build_cpython_host(
492
528
def python_build_info (
493
529
build_env ,
494
530
version ,
495
- platform ,
531
+ host_platform ,
496
532
target_triple ,
497
533
musl ,
498
534
optimizations ,
499
535
extensions ,
500
536
extra_metadata ,
537
+ * ,
501
538
downloads : Downloads ,
502
539
):
503
540
"""Obtain build metadata for the Python distribution."""
@@ -508,7 +545,7 @@ def python_build_info(
508
545
509
546
binary_suffix = ""
510
547
511
- if platform == "linux64" :
548
+ if host_platform == "linux64" :
512
549
bi ["core" ]["static_lib" ] = (
513
550
"install/lib/python{version}/config-{version}{binary_suffix}-x86_64-linux-gnu/libpython{version}{binary_suffix}.a" .format (
514
551
version = version , binary_suffix = binary_suffix
@@ -522,7 +559,7 @@ def python_build_info(
522
559
)
523
560
524
561
if optimizations in ("lto" , "pgo+lto" ):
525
- llvm_version = downloads [clang_toolchain (platform , target_triple )][
562
+ llvm_version = downloads [clang_toolchain (host_platform , target_triple )][
526
563
"version"
527
564
]
528
565
if "+" in llvm_version :
@@ -531,7 +568,7 @@ def python_build_info(
531
568
object_file_format = f"llvm-bitcode:%{ llvm_version } "
532
569
else :
533
570
object_file_format = "elf"
534
- elif platform == "macos" :
571
+ elif host_platform == "macos" :
535
572
bi ["core" ]["static_lib" ] = (
536
573
"install/lib/python{version}/config-{version}{binary_suffix}-darwin/libpython{version}{binary_suffix}.a" .format (
537
574
version = version , binary_suffix = binary_suffix
@@ -549,7 +586,7 @@ def python_build_info(
549
586
else :
550
587
object_file_format = "mach-o"
551
588
else :
552
- raise Exception ("unsupported platform: %s" % platform )
589
+ raise Exception ("unsupported platform: %s" % host_platform )
553
590
554
591
bi ["object_file_format" ] = object_file_format
555
592
@@ -564,9 +601,9 @@ def python_build_info(
564
601
if lib .startswith ("-l" ):
565
602
lib = lib [2 :]
566
603
567
- if platform == "linux64" and lib not in LINUX_ALLOW_SYSTEM_LIBRARIES :
604
+ if host_platform == "linux64" and lib not in LINUX_ALLOW_SYSTEM_LIBRARIES :
568
605
raise Exception ("unexpected library in LIBS (%s): %s" % (libs , lib ))
569
- elif platform == "macos" and lib not in MACOS_ALLOW_SYSTEM_LIBRARIES :
606
+ elif host_platform == "macos" and lib not in MACOS_ALLOW_SYSTEM_LIBRARIES :
570
607
raise Exception ("unexpected library in LIBS (%s): %s" % (libs , lib ))
571
608
572
609
log ("adding core system link library: %s" % lib )
@@ -681,7 +718,7 @@ def python_build_info(
681
718
extension_suffix = extra_metadata ["python_config_vars" ]["EXT_SUFFIX" ]
682
719
entry ["shared_lib" ] = "%s/%s%s" % (shared_dir , extension , extension_suffix )
683
720
684
- add_licenses_to_extension_entry (entry )
721
+ add_licenses_to_extension_entry (entry , downloads = downloads )
685
722
686
723
bi ["extensions" ].setdefault (extension , []).append (entry )
687
724
@@ -701,17 +738,18 @@ def build_cpython(
701
738
host_platform ,
702
739
target_triple ,
703
740
optimizations ,
704
- downloads : Downloads ,
705
741
dest_archive ,
706
742
version = None ,
707
743
python_source = None ,
744
+ * ,
745
+ downloads : Downloads ,
708
746
):
709
747
"""Build CPython in a Docker image'"""
710
748
entry_name = "cpython-%s" % version
711
749
entry = downloads [entry_name ]
712
750
if not python_source :
713
751
python_version = entry ["version" ]
714
- python_archive = download_entry (entry_name , DOWNLOADS_PATH , downloads )
752
+ python_archive = download_entry (entry_name , DOWNLOADS_PATH , downloads = downloads )
715
753
else :
716
754
python_version = os .environ ["PYBUILD_PYTHON_VERSION" ]
717
755
python_archive = DOWNLOADS_PATH / ("Python-%s.tar.xz" % python_version )
@@ -721,8 +759,10 @@ def build_cpython(
721
759
fh , python_source , path_prefix = "Python-%s" % python_version
722
760
)
723
761
724
- setuptools_archive = download_entry ("setuptools" , DOWNLOADS_PATH , downloads )
725
- pip_archive = download_entry ("pip" , DOWNLOADS_PATH , downloads )
762
+ setuptools_archive = download_entry (
763
+ "setuptools" , DOWNLOADS_PATH , downloads = downloads
764
+ )
765
+ pip_archive = download_entry ("pip" , DOWNLOADS_PATH , downloads = downloads )
726
766
727
767
ems = extension_modules_config (EXTENSION_MODULES )
728
768
@@ -746,6 +786,7 @@ def build_cpython(
746
786
binutils = install_binutils (host_platform ),
747
787
clang = True ,
748
788
musl = "musl" in target_triple ,
789
+ downloads = downloads ,
749
790
)
750
791
751
792
packages = target_needs (TARGETS_CONFIG , target_triple , python_version )
@@ -754,10 +795,16 @@ def build_cpython(
754
795
packages .discard ("musl" )
755
796
756
797
for p in sorted (packages ):
757
- build_env .install_artifact_archive (BUILD , p , target_triple , optimizations )
798
+ build_env .install_artifact_archive (
799
+ BUILD , p , target_triple , optimizations , downloads = downloads
800
+ )
758
801
759
802
build_env .install_toolchain_archive (
760
- BUILD , entry_name , host_platform , version = python_version
803
+ BUILD ,
804
+ entry_name ,
805
+ host_platform ,
806
+ version = python_version ,
807
+ downloads = downloads ,
761
808
)
762
809
763
810
for p in (
@@ -1008,9 +1055,9 @@ def main():
1008
1055
write_dockerfiles (SUPPORT , BUILD )
1009
1056
elif action == "makefiles" :
1010
1057
targets = get_targets (TARGETS_CONFIG )
1011
- write_triples_makefiles (targets , BUILD , SUPPORT )
1058
+ write_triples_makefiles (targets , BUILD , SUPPORT , downloads = downloads )
1012
1059
write_target_settings (targets , BUILD / "targets" )
1013
- write_package_versions (BUILD / "versions" )
1060
+ write_package_versions (BUILD / "versions" , downloads = downloads )
1014
1061
1015
1062
# Override the DOWNLOADS package entry for CPython for the local build
1016
1063
if python_source :
@@ -1056,9 +1103,9 @@ def main():
1056
1103
target_triple = target_triple ,
1057
1104
optimizations = optimizations ,
1058
1105
dest_archive = dest_archive ,
1059
- downloads = downloads ,
1060
1106
tools_path = "host" ,
1061
1107
extra_archives = ["m4" ],
1108
+ downloads = downloads ,
1062
1109
)
1063
1110
1064
1111
elif action == "libedit" :
@@ -1110,8 +1157,8 @@ def main():
1110
1157
target_triple = target_triple ,
1111
1158
optimizations = optimizations ,
1112
1159
dest_archive = dest_archive ,
1113
- downloads = downloads ,
1114
1160
tools_path = tools_path ,
1161
+ downloads = downloads ,
1115
1162
)
1116
1163
1117
1164
elif action == "libX11" :
@@ -1243,9 +1290,9 @@ def main():
1243
1290
target_triple = target_triple ,
1244
1291
optimizations = optimizations ,
1245
1292
dest_archive = dest_archive ,
1246
- downloads = downloads ,
1247
1293
version = action .split ("-" )[1 ],
1248
1294
python_source = python_source ,
1295
+ downloads = downloads ,
1249
1296
)
1250
1297
1251
1298
else :
0 commit comments