Skip to content

Commit b3fe613

Browse files
committed
unix: validate Python versions that can be built
Not all targets support building all Python versions. Let's annotate this in the YAML config and validate at run-time so we fail faster on invalid configurations.
1 parent bd11c6a commit b3fe613

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

cpython-unix/build-main.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from pythonbuild.downloads import DOWNLOADS
1414
from pythonbuild.utils import (
1515
compress_python_archive,
16+
get_target_settings,
1617
release_tag_from_git,
1718
supported_targets,
1819
)
@@ -94,6 +95,15 @@ def main():
9495

9596
target_triple = args.target_triple
9697

98+
settings = get_target_settings(TARGETS_CONFIG, target_triple)
99+
100+
if args.python not in settings["pythons_supported"]:
101+
print(
102+
"%s only supports following Pythons: %s"
103+
% (target_triple, ", ".join(settings["pythons_supported"]))
104+
)
105+
return 1
106+
97107
musl = "musl" in target_triple
98108

99109
env = dict(os.environ)

cpython-unix/targets.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
# Defines the Python sys.platform value where this configuration
55
# can be built from.
66
#
7+
# pythons_supported
8+
# Python versions we support building.
9+
#
710
# needs_toolchain
811
# Whether this build requires the presence of a custom compiled toolchain.
912
# If not defined, it is assumed the toolchain is present in the build
@@ -49,6 +52,8 @@
4952
aarch64-apple-darwin:
5053
host_platforms:
5154
- darwin
55+
pythons_supported:
56+
- 'cpython-3.9'
5257
needs_toolchain: true
5358
host_cc: clang
5459
target_cc: clang
@@ -78,6 +83,8 @@ aarch64-apple-darwin:
7883
aarch64-apple-ios:
7984
host_platforms:
8085
- darwin
86+
pythons_supported:
87+
- 'cpython-3.9'
8188
needs_toolchain: true
8289
apple_sdk_platform: iphoneos
8390
host_cc: clang
@@ -101,6 +108,8 @@ aarch64-apple-ios:
101108
aarch64-unknown-linux-gnu:
102109
host_platforms:
103110
- linux
111+
pythons_supported:
112+
- 'cpython-3.9'
104113
docker_image_suffix: .cross
105114
host_cc: /usr/bin/x86_64-linux-gnu-gcc
106115
target_cc: /usr/bin/aarch64-linux-gnu-gcc
@@ -129,6 +138,8 @@ aarch64-unknown-linux-gnu:
129138
arm64-apple-tvos:
130139
host_platforms:
131140
- darwin
141+
pythons_supported:
142+
- 'cpython-3.9'
132143
needs_toolchain: true
133144
apple_sdk_platform: appletvos
134145
host_cc: clang
@@ -151,6 +162,8 @@ arm64-apple-tvos:
151162
armv7-unknown-linux-gnueabi:
152163
host_platforms:
153164
- linux
165+
pythons_supported:
166+
- 'cpython-3.9'
154167
docker_image_suffix: .cross
155168
host_cc: /usr/bin/x86_64-linux-gnu-gcc
156169
target_cc: /usr/bin/arm-linux-gnueabi-gcc
@@ -179,6 +192,8 @@ armv7-unknown-linux-gnueabi:
179192
armv7-unknown-linux-gnueabihf:
180193
host_platforms:
181194
- linux
195+
pythons_supported:
196+
- 'cpython-3.9'
182197
docker_image_suffix: .cross
183198
host_cc: /usr/bin/x86_64-linux-gnu-gcc
184199
target_cc: /usr/bin/arm-linux-gnueabihf-gcc
@@ -207,6 +222,10 @@ armv7-unknown-linux-gnueabihf:
207222
i686-unknown-linux-gnu:
208223
host_platforms:
209224
- linux
225+
pythons_supported:
226+
- 'cpython-3.8'
227+
- 'cpython-3.9'
228+
- 'cpython-3.10'
210229
needs_toolchain: true
211230
host_cc: clang
212231
target_cc: clang
@@ -241,6 +260,8 @@ i686-unknown-linux-gnu:
241260
mips-unknown-linux-gnu:
242261
host_platforms:
243262
- linux
263+
pythons_supported:
264+
- 'cpython-3.9'
244265
docker_image_suffix: .cross
245266
host_cc: /usr/bin/x86_64-linux-gnu-gcc
246267
target_cc: /usr/bin/mips-linux-gnu-gcc
@@ -269,6 +290,8 @@ mips-unknown-linux-gnu:
269290
mipsel-unknown-linux-gnu:
270291
host_platforms:
271292
- linux
293+
pythons_supported:
294+
- 'cpython-3.9'
272295
docker_image_suffix: .cross
273296
host_cc: /usr/bin/x86_64-linux-gnu-gcc
274297
target_cc: /usr/bin/mipsel-linux-gnu-gcc
@@ -297,6 +320,8 @@ mipsel-unknown-linux-gnu:
297320
s390x-unknown-linux-gnu:
298321
host_platforms:
299322
- linux
323+
pythons_supported:
324+
- 'cpython-3.9'
300325
docker_image_suffix: .cross
301326
host_cc: /usr/bin/x86_64-linux-gnu-gcc
302327
target_cc: /usr/bin/s390x-linux-gnu-gcc
@@ -325,6 +350,8 @@ s390x-unknown-linux-gnu:
325350
thumb7k-apple-watchos:
326351
host_platforms:
327352
- darwin
353+
pythons_supported:
354+
- 'cpython-3.9'
328355
needs_toolchain: true
329356
apple_sdk_platform: watchos
330357
host_cc: clang
@@ -351,6 +378,9 @@ thumb7k-apple-watchos:
351378
x86_64-apple-darwin:
352379
host_platforms:
353380
- darwin
381+
pythons_supported:
382+
- 'cpython-3.8'
383+
- 'cpython-3.9'
354384
apple_sdk_platform: macosx
355385
host_cc: clang
356386
target_cc: clang
@@ -379,6 +409,8 @@ x86_64-apple-darwin:
379409
x86_64-apple-ios:
380410
host_platforms:
381411
- darwin
412+
pythons_supported:
413+
- 'cpython-3.9'
382414
needs_toolchain: true
383415
apple_sdk_platform: iphonesimulator
384416
host_cc: clang
@@ -402,6 +434,8 @@ x86_64-apple-ios:
402434
x86_64-apple-tvos:
403435
host_platforms:
404436
- darwin
437+
pythons_supported:
438+
- 'cpython-3.9'
405439
needs_toolchain: true
406440
apple_sdk_platform: appletvsimulator
407441
host_cc: clang
@@ -423,6 +457,8 @@ x86_64-apple-tvos:
423457
x86_64-apple-watchos:
424458
host_platforms:
425459
- darwin
460+
pythons_supported:
461+
- 'cpython-3.9'
426462
needs_toolchain: true
427463
apple_sdk_platform: watchsimulator
428464
host_cc: clang
@@ -445,6 +481,10 @@ x86_64-apple-watchos:
445481
x86_64-unknown-linux-gnu:
446482
host_platforms:
447483
- linux
484+
pythons_supported:
485+
- 'cpython-3.8'
486+
- 'cpython-3.9'
487+
- 'cpython-3.10'
448488
needs_toolchain: true
449489
host_cc: clang
450490
target_cc: clang
@@ -474,6 +514,10 @@ x86_64-unknown-linux-gnu:
474514
x86_64-unknown-linux-musl:
475515
host_platforms:
476516
- linux
517+
pythons_supported:
518+
- 'cpython-3.8'
519+
- 'cpython-3.9'
520+
- 'cpython-3.10'
477521
needs_toolchain: true
478522
host_cc: clang
479523
target_cc: musl-clang

0 commit comments

Comments
 (0)