-
-
Notifications
You must be signed in to change notification settings - Fork 59
/
Copy pathfactories.py
1310 lines (1106 loc) · 43.3 KB
/
factories.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import os.path
from buildbot.process import factory
from buildbot.steps.shell import (
Configure,
Compile,
ShellCommand,
SetPropertyFromCommand,
)
from buildbot.plugins import util
from . import (MAIN_BRANCH_VERSION, MAIN_BRANCH_NAME,
JUNIT_FILENAME)
from .steps import (
Test,
Clean,
Install,
LockInstall,
Uninstall,
UploadTestResults,
)
# This (default) timeout is for each individual test file.
# It is a bit more than the default faulthandler timeout in regrtest.py
# (the latter isn't easily changed under Windows).
TEST_TIMEOUT = 20 * 60 # 20 minutes
# Refleak timeout (-R 3:3) for each individual test file.
REFLEAK_TIMEOUT = 45 * 60 # 45 minutes
def step_timeout(timeout):
# timeout is the regrtest timeout in seconds. If a test runs longer than
# the timeout, it should be killed by faulthandler. Give 10 minutes to
# faulthandler to kill the process. Tests should always be shorter than the
# buildbot step timeout, unless faulthandler fails to kill the process.
return timeout + 10 * 60
class BaseBuild(factory.BuildFactory):
factory_tags = []
test_timeout = TEST_TIMEOUT
def __init__(self, source, *, extra_tags=[], **kwargs):
super().__init__([source])
self.setup(**kwargs)
self.tags = self.factory_tags + extra_tags
##############################################################################
############################### UNIX BUILDS ################################
##############################################################################
def has_option(option, test_options):
# return True for option='-j' and test_options=['-uall', '-j2']
return option in ' '.join(test_options)
class UnixBuild(BaseBuild):
configureFlags = ["--with-pydebug"]
compile_environ = {}
interpreterFlags = ""
testFlags = ["-j2"]
makeTarget = "all"
test_environ = {}
build_out_of_tree = False
def setup(self, parallel, branch, test_with_PTY=False, **kwargs):
out_of_tree_dir = "build_oot"
# Adjust the timeout for this worker
self.test_timeout *= kwargs.get("timeout_factor", 1)
# In 3.9 and 3.10, test_asyncio wasn't split out, and refleaks tests
# need more time.
if branch in ("3.9", "3.10") and has_option("-R", self.testFlags):
self.test_timeout *= 2
if self.build_out_of_tree:
self.addStep(
ShellCommand(
name="mkdir out-of-tree directory",
description="Create out-of-tree directory",
command=["mkdir", "-p", out_of_tree_dir],
warnOnFailure=True,
)
)
if self.build_out_of_tree:
configure_cmd = "../configure"
oot_kwargs = {'workdir': os.path.join("build", out_of_tree_dir)}
else:
configure_cmd = "./configure"
oot_kwargs = {}
configure_cmd = [configure_cmd, "--prefix", "$(PWD)/target"]
configure_cmd += self.configureFlags
self.addStep(
Configure(command=configure_cmd, **oot_kwargs)
)
compile = ["make", self.makeTarget]
testopts = list(self.testFlags)
if not has_option("-R", self.testFlags):
testopts.extend(("--junit-xml", JUNIT_FILENAME))
if parallel:
compile = ["make", parallel, self.makeTarget]
testopts.append(parallel)
if not has_option("-j", testopts):
testopts.append("-j2")
test = [
"make",
"buildbottest",
"TESTOPTS=" + " ".join(testopts) + " ${BUILDBOT_TESTOPTS}",
f"TESTPYTHONOPTS={self.interpreterFlags}",
f"TESTTIMEOUT={self.test_timeout}",
]
self.addStep(Compile(command=compile,
env=self.compile_environ,
**oot_kwargs))
self.addStep(
ShellCommand(
name="pythoninfo",
description="pythoninfo",
command=["make", "pythoninfo"],
warnOnFailure=True,
env=self.test_environ,
**oot_kwargs
)
)
self.addStep(Test(
command=test,
timeout=step_timeout(self.test_timeout),
usePTY=test_with_PTY,
env=self.test_environ,
**oot_kwargs
))
if branch not in ("3",) and not has_option("-R", self.testFlags):
filename = JUNIT_FILENAME
if self.build_out_of_tree:
filename = os.path.join(out_of_tree_dir, filename)
self.addStep(UploadTestResults(branch, filename=filename))
self.addStep(Clean(**oot_kwargs))
class UnixPerfBuild(UnixBuild):
buildersuffix = ".perfbuild"
configureFlags = ["CFLAGS=-fno-omit-frame-pointer -mno-omit-leaf-frame-pointer"]
class UnixTraceRefsBuild(UnixBuild):
def setup(self, parallel, branch, test_with_PTY=False, **kwargs):
self.configureFlags = ["--with-pydebug", "--with-trace-refs"]
return super().setup(parallel, branch, test_with_PTY=test_with_PTY, **kwargs)
class UnixVintageParserBuild(UnixBuild):
buildersuffix = ".oldparser" # to get unique directory names on master
test_environ = {'PYTHONOLDPARSER': 'old'}
class UnixRefleakBuild(UnixBuild):
buildersuffix = ".refleak"
testFlags = ["-R", "3:3", "-u-cpu"]
test_timeout = REFLEAK_TIMEOUT
factory_tags = ["refleak"]
class UnixNoGilBuild(UnixBuild):
buildersuffix = ".nogil"
configureFlags = ["--with-pydebug", "--disable-gil"]
factory_tags = ["nogil"]
# 2024-04-11: Free-threading can still be slower than regular build in some
# code paths, so tolerate longer timeout.
test_timeout = int(TEST_TIMEOUT * 1.5)
class UnixNoGilRefleakBuild(UnixBuild):
buildersuffix = ".refleak.nogil"
configureFlags = ["--with-pydebug", "--disable-gil"]
testFlags = ["-R", "3:3", "-u-cpu"]
test_timeout = REFLEAK_TIMEOUT
factory_tags = ["nogil", "refleak"]
class UnixInstalledBuild(BaseBuild):
buildersuffix = ".installed"
configureFlags = []
interpreterFlags = ["-Wdefault", "-bb", "-E"]
defaultTestOpts = ["-rwW", "-uall", "-j2"]
makeTarget = "all"
installTarget = "install"
factory_tags = ["installed"]
def setup(self, parallel, branch, test_with_PTY=False, **kwargs):
if branch == MAIN_BRANCH_NAME:
branch = MAIN_BRANCH_VERSION
elif branch == "custom":
branch = "3"
installed_python = f"./target/bin/python{branch}"
self.addStep(
Configure(
command=["./configure", "--prefix", "$(PWD)/target"]
+ self.configureFlags
)
)
compile = ["make", self.makeTarget]
install = ["make", self.installTarget]
testopts = list(self.defaultTestOpts)
testopts.append(f"--timeout={self.test_timeout}")
if parallel:
compile = ["make", parallel, self.makeTarget]
install = ["make", parallel, self.installTarget]
testopts.append(parallel)
test = [installed_python,
*self.interpreterFlags,
"-m", "test",
*testopts]
self.addStep(Compile(command=compile))
self.addStep(Install(command=install))
self.addStep(LockInstall())
self.addStep(
ShellCommand(
name="pythoninfo",
description="pythoninfo",
command=[installed_python, "-m", "test.pythoninfo"],
warnOnFailure=True,
)
)
self.addStep(Test(
command=test,
timeout=step_timeout(self.test_timeout),
usePTY=test_with_PTY,
))
self.addStep(Uninstall())
self.addStep(Clean())
class UnixAsanBuild(UnixBuild):
buildersuffix = ".asan"
configureFlags = ["--without-pymalloc", "--with-address-sanitizer"]
factory_tags = ["asan", "sanitizer"]
# See https://bugs.python.org/issue42985 for more context on why
# SIGSEGV is ignored on purpose.
compile_environ = {'ASAN_OPTIONS': 'detect_leaks=0:allocator_may_return_null=1:handle_segv=0'}
test_environ = {'ASAN_OPTIONS': 'detect_leaks=0:allocator_may_return_null=1:handle_segv=0'}
class UnixAsanDebugBuild(UnixAsanBuild):
buildersuffix = ".asan_debug"
configureFlags = UnixAsanBuild.configureFlags + ["--with-pydebug"]
class UnixAsanNoGilBuild(UnixAsanBuild):
buildersuffix = ".asan.nogil"
configureFlags = UnixAsanBuild.configureFlags + ["--disable-gil"]
factory_tags = UnixAsanBuild.factory_tags + ["nogil"]
class UnixBuildWithoutDocStrings(UnixBuild):
configureFlags = ["--with-pydebug", "--without-doc-strings"]
class UnixBigmemBuild(UnixBuild):
buildersuffix = ".bigmem"
testFlags = [
"-M60g", "-j4", "-uall,extralargefile",
"--prioritize=test_bigmem,test_lzma,test_bz2,test_re,test_array"
]
test_timeout = TEST_TIMEOUT * 4
factory_tags = ["bigmem"]
class AIXBuild(UnixBuild):
configureFlags = [
"--with-pydebug",
"--with-openssl=/opt/aixtools",
]
class AIXBuildWithXLC(UnixBuild):
buildersuffix = ".xlc"
configureFlags = [
"--with-pydebug",
"--with-openssl=/opt/aixtools",
"CC=xlc_r",
"LD=xlc_r",
]
factory_tags = ["xlc"]
class NonDebugUnixBuild(UnixBuild):
buildersuffix = ".nondebug"
# Enable assertions regardless. Some children will override this,
# that is fine.
configureFlags = ["CFLAGS=-UNDEBUG"]
factory_tags = ["nondebug"]
class PGOUnixBuild(NonDebugUnixBuild):
buildersuffix = ".pgo"
configureFlags = ["--enable-optimizations"]
factory_tags = ["pgo"]
def setup(self, parallel, branch, *args, **kwargs):
# Only Python >3.10 has --with-readline=edit
if branch != '3.9':
# Use libedit instead of libreadline on this buildbot for
# some libedit Linux compilation coverage.
self.configureFlags = self.configureFlags + ["--with-readline=edit"]
return super().setup(parallel, branch, *args, **kwargs)
class ClangUnixBuild(UnixBuild):
buildersuffix = ".clang"
configureFlags = [
"CC=clang",
"LD=clang",
"--with-pydebug",
]
factory_tags = ["clang"]
class ClangUbsanLinuxBuild(UnixBuild):
buildersuffix = ".clang-ubsan"
configureFlags = [
"CC=clang",
"LD=clang",
"CFLAGS=-fno-sanitize-recover",
"--with-undefined-behavior-sanitizer",
]
factory_tags = ["clang", "ubsan", "sanitizer"]
class ClangUbsanFunctionLinuxBuild(UnixBuild):
buildersuffix = ".clang-ubsan-function"
configureFlags = [
"CC=clang",
"LD=clang",
"CFLAGS=-fsanitize=undefined -fno-sanitize=function -fsanitize-recover",
"--with-undefined-behavior-sanitizer",
]
factory_tags = ["clang", "ubsan", "sanitizer"]
class ClangUnixInstalledBuild(UnixInstalledBuild):
buildersuffix = ".clang-installed"
configureFlags = [
"CC=clang",
"LD=clang",
]
factory_tags = ["clang", "installed"]
class SharedUnixBuild(UnixBuild):
configureFlags = ["--with-pydebug", "--enable-shared"]
factory_tags = ["shared"]
# faulthandler uses a timeout 5 minutes smaller: it should be enough for the
# slowest test.
SLOW_TIMEOUT = 40 * 60
# These use a longer timeout for very slow buildbots.
class SlowNonDebugUnixBuild(NonDebugUnixBuild):
test_timeout = SLOW_TIMEOUT
testFlags = [*NonDebugUnixBuild.testFlags, "-u-cpu"]
class SlowUnixInstalledBuild(UnixInstalledBuild):
test_timeout = SLOW_TIMEOUT
class LTONonDebugUnixBuild(NonDebugUnixBuild):
buildersuffix = ".lto"
configureFlags = [
"--with-lto",
]
factory_tags = ["lto", "nondebug"]
class LTOPGONonDebugBuild(NonDebugUnixBuild):
buildersuffix = ".lto-pgo"
configureFlags = [
"--with-lto",
"--enable-optimizations",
]
factory_tags = ["lto", "pgo", "nondebug"]
class ClangLTOPGONonDebugBuild(NonDebugUnixBuild):
buildersuffix = ".clang.lto-pgo"
configureFlags = [
"CC=clang",
"LD=clang",
"--with-lto",
"--enable-optimizations",
]
factory_tags = ["lto", "pgo", "nondebug", "clang"]
class RHEL8Build(UnixBuild):
# Build Python on 64-bit RHEL8.
configureFlags = [
"--with-pydebug",
"--with-platlibdir=lib64",
"--enable-ipv6",
"--enable-shared",
"--with-computed-gotos=yes",
"--with-dbmliborder=gdbm:ndbm:bdb",
# FIXME: enable these flags
# "--with-system-expat",
# "--with-system-ffi",
"--enable-loadable-sqlite-extensions",
"--with-ssl-default-suites=openssl",
"--without-static-libpython",
"--with-lto",
# Not all workers have dtrace installed
# "--with-dtrace",
# Not all workers have Valgrind headers installed
# "--with-valgrind",
]
# Building Python out of tree: similar to what the specfile does, but
# buildbot uses a single subdirectory, and the specfile uses two
# sub-directories.
#
# On Fedora/RHEL specfile, the following directories are used:
# /builddir/build/BUILD/Python-3.11: source code
# /builddir/build/BUILD/Python-3.11/build/optimized: configure, make, tests
build_out_of_tree = True
class CentOS9Build(RHEL8Build):
# Build on 64-bit CentOS Stream 9.
# For now, it's the same as RHEL8, but later it may get different
# options.
pass
class FedoraStableBuild(RHEL8Build):
# Build Python on 64-bit Fedora Stable.
#
# Try to be as close as possible to the Fedora specfile used to build
# the RPM package:
# https://src.fedoraproject.org/rpms/python3.11/blob/rawhide/f/python3.11.spec
configureFlags = RHEL8Build.configureFlags + [
# Options specific to Fedora
# FIXME: enable this flag
# "--with-system-libmpdec",
# Don't make a buildbot fail when pip/setuptools is updated in Python,
# whereas the buildbot uses older versions.
# "--with-wheel-pkg-dir=/usr/share/python-wheels/",
]
class FedoraRawhideBuild(FedoraStableBuild):
# Build on 64-bit Fedora Rawhide.
# For now, it's the same than Fedora Stable, but later it may get different
# options.
pass
class FedoraRawhideFreedthreadingBuild(FedoraRawhideBuild):
# Build on 64-bit Fedora Rawhide.
buildersuffix = ".nogil"
configureFlags = FedoraRawhideBuild.configureFlags + [
"--disable-gil",
]
factory_tags = ["nogil"]
class RHEL8NoBuiltinHashesUnixBuildExceptBlake2(RHEL8Build):
# Build on 64-bit RHEL8 using: --with-builtin-hashlib-hashes=blake2
buildersuffix = ".no-builtin-hashes-except-blake2"
configureFlags = RHEL8Build.configureFlags + [
"--with-builtin-hashlib-hashes=blake2"
]
factory_tags = ["no-builtin-hashes-except-blake2"]
class RHEL8NoBuiltinHashesUnixBuild(RHEL8Build):
# Build on 64-bit RHEL8 using: --without-builtin-hashlib-hashes
buildersuffix = ".no-builtin-hashes"
configureFlags = RHEL8Build.configureFlags + [
"--without-builtin-hashlib-hashes"
]
factory_tags = ["no-builtin-hashes"]
class CentOS9NoBuiltinHashesUnixBuildExceptBlake2(CentOS9Build):
# Build on 64-bit CentOS Stream 9 using: --with-builtin-hashlib-hashes=blake2
buildersuffix = ".no-builtin-hashes-except-blake2"
configureFlags = CentOS9Build.configureFlags + [
"--with-builtin-hashlib-hashes=blake2"
]
factory_tags = ["no-builtin-hashes-except-blake2"]
class CentOS9NoBuiltinHashesUnixBuild(CentOS9Build):
# Build on 64-bit CentOS Stream 9 using: --without-builtin-hashlib-hashes
buildersuffix = ".no-builtin-hashes"
configureFlags = CentOS9Build.configureFlags + [
"--without-builtin-hashlib-hashes"
]
factory_tags = ["no-builtin-hashes"]
##############################################################################
############################ MACOS BUILDS ##################################
##############################################################################
class MacOSArmWithBrewBuild(UnixBuild):
buildersuffix = ".macos-with-brew"
configureFlags = UnixBuild.configureFlags + [
"--with-openssl=/opt/homebrew/opt/openssl@3",
"CPPFLAGS=-I/opt/homebrew/include",
"LDFLAGS=-L/opt/homebrew/lib",
"PKG_CONFIG_PATH=/opt/homebrew/opt/tcl-tk@8/lib/pkgconfig",
]
# These tests are known to crash on M1 macs (see bpo-45289).
testFlags = [*UnixBuild.testFlags,
"-x", "test_dbm", "test_dbm_ndbm", "test_shelve"]
class MacOSArmWithBrewNoGilBuild(UnixNoGilBuild):
buildersuffix = ".macos-with-brew.nogil"
configureFlags = [
*UnixNoGilBuild.configureFlags,
"--with-openssl=/opt/homebrew/opt/openssl@3",
"CPPFLAGS=-I/opt/homebrew/include",
"LDFLAGS=-L/opt/homebrew/lib",
"PKG_CONFIG_PATH=/opt/homebrew/opt/tcl-tk@8/lib/pkgconfig",
]
class MacOSArmWithBrewRefleakBuild(UnixRefleakBuild):
buildersuffix = ".macos-with-brew.refleak"
configureFlags = [
*UnixRefleakBuild.configureFlags,
"--with-openssl=/opt/homebrew/opt/openssl@3",
"CPPFLAGS=-I/opt/homebrew/include",
"LDFLAGS=-L/opt/homebrew/lib",
"PKG_CONFIG_PATH=/opt/homebrew/opt/tcl-tk@8/lib/pkgconfig",
]
class MacOSArmWithBrewNoGilRefleakBuild(UnixNoGilRefleakBuild):
buildersuffix = ".macos-with-brew.refleak.nogil"
configureFlags = [
*UnixNoGilRefleakBuild.configureFlags,
"--with-openssl=/opt/homebrew/opt/openssl@3",
"CPPFLAGS=-I/opt/homebrew/include",
"LDFLAGS=-L/opt/homebrew/lib",
"PKG_CONFIG_PATH=/opt/homebrew/opt/tcl-tk@8/lib/pkgconfig",
]
class MacOSAsanNoGilBuild(UnixAsanNoGilBuild):
buildersuffix = ".macos-with-brew.asan.nogil"
configureFlags = UnixAsanNoGilBuild.configureFlags + [
"--with-openssl=/opt/homebrew/opt/openssl@3",
"CPPFLAGS=-I/opt/homebrew/include",
"LDFLAGS=-L/opt/homebrew/lib",
"PKG_CONFIG_PATH=/opt/homebrew/opt/tcl-tk@8/lib/pkgconfig",
]
asan_options = 'detect_leaks=0:allocator_may_return_null=1:handle_segv=0'
compile_environ = {'ASAN_OPTIONS': asan_options}
test_environ = {
'ASAN_OPTIONS': asan_options,
# Note: Need to set `MallocNanoZone=0` environment variable to workaround a macOS issue.
# This was needed to workaround an issue with this builder that manifested as failures in 3 tests:
# test_cmd_line, test_posix, test_subprocess
# These failures seem to be related to the occurrence of this warning:
# python.exe(74602,0x7ff84626a700) malloc: nano zone abandoned due to inability to reserve vm space.
# It is unclear why (or if) it's *directly* causing the test failures, but setting `MallocNanoZone=0`
# disables this optimization (and fixes the tests), which appears to be interfering with ASAN. See also:
# https://stackoverflow.com/questions/64126942/malloc-nano-zone-abandoned-due-to-inability-to-preallocate-reserved-vm-space
# https://github.com/python/buildmaster-config/issues/450 (and attached PR)
'MallocNanoZone': '0',
}
##############################################################################
############################ WINDOWS BUILDS ################################
##############################################################################
class BaseWindowsBuild(BaseBuild):
build_command = [r"Tools\buildbot\build.bat"]
test_command = [r"Tools\buildbot\test.bat"]
clean_command = [r"Tools\buildbot\clean.bat"]
python_command = [r"python.bat"]
buildFlags = ["-p", "Win32"]
testFlags = ["-p", "Win32", "-j2"]
cleanFlags = []
factory_tags = ["win32"]
def setup(self, parallel, branch, **kwargs):
build_command = self.build_command + self.buildFlags
test_command = [*self.test_command, *self.testFlags]
if not has_option("-R", self.testFlags):
test_command.extend((r"--junit-xml", JUNIT_FILENAME))
clean_command = self.clean_command + self.cleanFlags
if parallel:
test_command.append(parallel)
self.addStep(Compile(command=build_command))
self.addStep(
ShellCommand(
name="pythoninfo",
description="pythoninfo",
command=self.python_command + ["-m", "test.pythoninfo"],
warnOnFailure=True,
)
)
test_command.extend(("--timeout", str(self.test_timeout)))
self.addStep(Test(
command=test_command,
timeout=step_timeout(self.test_timeout),
))
if branch not in ("3",) and not has_option("-R", self.testFlags):
self.addStep(UploadTestResults(branch))
self.addStep(Clean(command=clean_command))
class WindowsBuild(BaseWindowsBuild):
buildersuffix = '.x32'
class WindowsRefleakBuild(BaseWindowsBuild):
buildersuffix = ".x32.refleak"
testFlags = ["-j2", "-R", "3:3", "-u-cpu"]
test_timeout = REFLEAK_TIMEOUT
factory_tags = ["win32", "refleak"]
class SlowWindowsBuild(WindowsBuild):
test_timeout = TEST_TIMEOUT * 2
testFlags = ["-j2", "-u-cpu", "-u-largefile"]
class Windows64Build(BaseWindowsBuild):
buildFlags = ["-p", "x64"]
testFlags = ["-p", "x64", "-j2"]
cleanFlags = ["-p", "x64"]
factory_tags = ["win64"]
class Windows64BigmemBuild(BaseWindowsBuild):
buildersuffix = ".bigmem"
buildFlags = ["-p", "x64"]
testFlags = [
"-p", "x64", "-M33g", "-uall,extralargefile",
"--prioritize=test_bigmem,test_lzma,test_bz2,test_array,test_hashlib,test_zlib"
]
test_timeout = TEST_TIMEOUT * 4
cleanFlags = ["-p", "x64"]
factory_tags = ["win64", "bigmem"]
class Windows64RefleakBuild(Windows64Build):
buildersuffix = ".refleak"
testFlags = ["-p", "x64", *WindowsRefleakBuild.testFlags]
test_timeout = REFLEAK_TIMEOUT
factory_tags = ["win64", "refleak"]
class Windows64ReleaseBuild(Windows64Build):
buildersuffix = ".nondebug"
buildFlags = Windows64Build.buildFlags + ["-c", "Release"]
testFlags = [*Windows64Build.testFlags, "+d"]
# keep default cleanFlags, both configurations get cleaned
factory_tags = ["win64", "nondebug"]
class Windows64PGOBuild(Windows64ReleaseBuild):
buildersuffix = ".pgo"
buildFlags = Windows64Build.buildFlags + ["--pgo"]
testFlags = [*Windows64Build.testFlags, "+d"]
factory_tags = ["win64", "nondebug", "pgo"]
class Windows64NoGilBuild(Windows64Build):
buildersuffix = '.x64.nogil'
buildFlags = Windows64Build.buildFlags + ["--disable-gil"]
testFlags = Windows64Build.testFlags + ["--disable-gil"]
factory_tags = ["win64", "nogil"]
class Windows64PGONoGilBuild(Windows64PGOBuild):
buildersuffix = '.nogil.pgo'
buildFlags = Windows64PGOBuild.buildFlags + ["--disable-gil"]
testFlags = Windows64PGOBuild.testFlags + ["--disable-gil"]
factory_tags = ["win64", "nogil", "nondebug", "pgo"]
class WindowsARM64Build(BaseWindowsBuild):
buildFlags = ["-p", "ARM64"]
testFlags = ["-p", "ARM64", "-j2"]
cleanFlags = ["-p", "ARM64"]
factory_tags = ["win-arm64"]
class WindowsARM64ReleaseBuild(WindowsARM64Build):
buildersuffix = ".nondebug"
buildFlags = WindowsARM64Build.buildFlags + ["-c", "Release"]
testFlags = [*WindowsARM64Build.testFlags, "+d"]
# keep default cleanFlags, both configurations get cleaned
factory_tags = ["win-arm64", "nondebug"]
##############################################################################
############################## WASI BUILDS #################################
##############################################################################
class UnixCrossBuild(UnixBuild):
extra_configure_flags = []
host_configure_cmd = ["../../configure"]
host = None
host_make_cmd = ["make"]
can_execute_python = True
def setup(self, parallel, branch, test_with_PTY=False, **kwargs):
assert self.host is not None, "Must set self.host on cross builds"
out_of_tree_dir = "build_oot"
oot_dir_path = os.path.join("build", out_of_tree_dir)
oot_build_path = os.path.join(oot_dir_path, "build")
oot_host_path = os.path.join(oot_dir_path, "host")
self.addStep(
SetPropertyFromCommand(
name="Gather build triple from worker",
description="Get the build triple config.guess",
command="./config.guess",
property="build_triple",
warnOnFailure=True,
)
)
# Create out of tree directory for "build", the platform we are
# currently running on
self.addStep(
ShellCommand(
name="mkdir build out-of-tree directory",
description="Create build out-of-tree directory",
command=["mkdir", "-p", oot_build_path],
warnOnFailure=True,
)
)
# Create directory for "host", the platform we want to compile *for*
self.addStep(
ShellCommand(
name="mkdir host out-of-tree directory",
description="Create host out-of-tree directory",
command=["mkdir", "-p", oot_host_path],
warnOnFailure=True,
)
)
# First, we build the "build" Python, which we need to cross compile
# the "host" Python
self.addStep(
Configure(
name="Configure build Python",
command=["../../configure"],
workdir=oot_build_path
)
)
if parallel:
compile = ["make", parallel]
else:
compile = ["make"]
self.addStep(
Compile(
name="Compile build Python",
command=compile,
workdir=oot_build_path
)
)
# Now that we have a "build" architecture Python, we can use that
# to build a "host" (also known as the target we are cross compiling)
# Take a copy so that the class-level definition isn't tainted
configure_cmd = list(self.host_configure_cmd)
configure_cmd += ["--prefix", "$(PWD)/target/host"]
configure_cmd += self.configureFlags + self.extra_configure_flags
configure_cmd += [util.Interpolate("--build=%(prop:build_triple)s")]
configure_cmd += [f"--host={self.host}"]
configure_cmd += ["--with-build-python=../build/python"]
self.addStep(
Configure(
name="Configure host Python",
command=configure_cmd,
env=self.compile_environ,
workdir=oot_host_path
)
)
testopts = list(self.testFlags)
if not has_option("-R", self.testFlags):
testopts.extend((" --junit-xml", JUNIT_FILENAME))
if parallel:
testopts.append(parallel)
if not has_option("-j", self.testFlags):
testopts.append("-j2")
test = [
"make",
"buildbottest",
"TESTOPTS=" + " ".join(testopts) + " ${BUILDBOT_TESTOPTS}",
f"TESTPYTHONOPTS={self.interpreterFlags}",
f"TESTTIMEOUT={self.test_timeout}",
]
if parallel:
compile = self.host_make_cmd + [parallel, self.makeTarget]
else:
compile = self.host_make_cmd + [self.makeTarget]
self.addStep(
Compile(
name="Compile host Python",
command=compile,
env=self.compile_environ,
workdir=oot_host_path,
)
)
if self.can_execute_python:
self.addStep(
ShellCommand(
name="pythoninfo",
description="pythoninfo",
command=["make", "pythoninfo"],
warnOnFailure=True,
env=self.test_environ,
workdir=oot_host_path,
)
)
self.addStep(Test(
command=test,
timeout=step_timeout(self.test_timeout),
usePTY=test_with_PTY,
env=self.test_environ,
workdir=oot_host_path,
))
if branch not in ("3",) and not has_option("-R", self.testFlags):
filename = os.path.join(oot_host_path, JUNIT_FILENAME)
self.addStep(UploadTestResults(branch, filename=filename))
self.addStep(
Clean(
name="Clean build Python",
workdir=oot_build_path,
)
)
self.addStep(
Clean(
name="Clean host Python",
workdir=oot_host_path,
)
)
# Deprecated since Python 3.13; can be dropped once `wasi.py` is in all versions.
class Wasm32WasiCrossBuild(UnixCrossBuild):
"""wasm32-wasi builder
* WASI SDK >= 16 must be installed to default path /opt/wasi-sdk
* wasmtime must be installed and on PATH
"""
buildersuffix = ".wasi.nondebug"
factory_tags = ["wasm", "wasi", "nondebug"]
extra_configure_flags = [
# debug builds exhaust the limited call stack on WASI
"--without-pydebug",
]
compile_environ = {
"CONFIG_SITE": "../../Tools/wasm/config.site-wasm32-wasi",
}
host = "wasm32-unknown-wasi"
host_configure_cmd = ["../../Tools/wasm/wasi-env", "../../configure"]
def setup(self, parallel, branch, test_with_PTY=False, **kwargs):
self.addStep(
ShellCommand(
name="Touch srcdir Modules/Setup.local",
description="Hack to work around wasmtime mapdir issue",
command=["touch", "Modules/Setup.local"],
haltOnFailure=True,
)
)
super().setup(parallel, branch, test_with_PTY=test_with_PTY, **kwargs)
class _Wasm32WasiPreview1Build(UnixBuild):
"""Build Python for wasm32-wasi using Tools/wasm/wasi.py."""
buildersuffix = ".wasi"
factory_tags = ["wasm", "wasi"]
# pydebug and append_suffix defined in subclasses.
def __init__(self, source, *, extra_tags=[], **kwargs):
if not self.pydebug:
extra_tags.append("nondebug")
self.buildersuffix += self.append_suffix
super().__init__(source, extra_tags=extra_tags, **kwargs)
def setup(self, parallel, branch, test_with_PTY=False, **kwargs):
wasi_py = "Tools/wasm/wasi.py"
host_triple = "wasm32-wasip1"
host_path = f"build/cross-build/{host_triple}"
# Build Python
build_configure = ["python3", wasi_py, "configure-build-python"]
if self.pydebug:
build_configure.extend(["--", "--with-pydebug"])
self.addStep(
Configure(
name="Configure build Python",
command=build_configure,
)
)
self.addStep(
Compile(
name="Compile build Python",
command=["python3", wasi_py, "make-build-python"],
)
)
# Host/WASI Python
self.addStep(
# Pydebug build automatically inferred from build Python.
Configure(
name="Configure host Python",
command=["python3", wasi_py, "configure-host"],
)
)
self.addStep(
Compile(
name="Compile host Python",
command=["python3", wasi_py, "make-host"],
)
)
self.addStep(
ShellCommand(
name="pythoninfo",
description="pythoninfo",
command=["make", "pythoninfo"],
warnOnFailure=True,
workdir=host_path,
)
)
# Copied from UnixBuild.
testopts = list(self.testFlags)
if not has_option("-R", self.testFlags):
testopts.extend(("--junit-xml", JUNIT_FILENAME))
if parallel:
testopts.append(parallel)
if not has_option("-j", testopts):
testopts.append("-j2")
test = [
"make",
"buildbottest",
"TESTOPTS=" + " ".join(testopts) + " ${BUILDBOT_TESTOPTS}",
f"TESTPYTHONOPTS={self.interpreterFlags}",
f"TESTTIMEOUT={self.test_timeout}",
]
self.addStep(
Test(
command=test,
timeout=step_timeout(self.test_timeout),
usePTY=test_with_PTY,
env=self.test_environ,
workdir=host_path,
)
)
if branch not in ("3",) and not has_option("-R", self.testFlags):
filename = os.path.join(host_path, JUNIT_FILENAME)
self.addStep(UploadTestResults(branch, filename=filename))
self.addStep(
Clean(
name="Clean the builds",
command=["python3", wasi_py, "clean"],
)
)
# Preventing this from running on versions older than 3.13 is managed in
# master.cfg.
class Wasm32WasiPreview1DebugBuild(_Wasm32WasiPreview1Build):
append_suffix = ".debug"
pydebug = True
testFlags = ["-u-cpu"]