Skip to content

Commit 4fef73c

Browse files
committed
Refactor to make the 3.13 and 3.14+ branches more distinct.
1 parent 2de77fd commit 4fef73c

File tree

1 file changed

+190
-174
lines changed

1 file changed

+190
-174
lines changed

master/custom/factories.py

Lines changed: 190 additions & 174 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,200 +1045,216 @@ def __init__(self, source, **kwargs):
10451045

10461046
super().__init__(source, **kwargs)
10471047

1048-
def setup(self, parallel, branch, test_with_PTY=False, **kwargs):
1049-
if branch == "3.13":
1050-
out_of_tree_dir = "build_oot"
1051-
oot_dir_path = os.path.join("build", out_of_tree_dir)
1052-
oot_build_path = os.path.join(oot_dir_path, "build")
1053-
oot_host_path = os.path.join(oot_dir_path, "host")
1048+
def historical_setup(self, parallel, test_with_PTY=False):
1049+
out_of_tree_dir = "build_oot"
1050+
oot_dir_path = os.path.join("build", out_of_tree_dir)
1051+
oot_build_path = os.path.join(oot_dir_path, "build")
1052+
oot_host_path = os.path.join(oot_dir_path, "host")
10541053

1055-
# Create out of tree directory for "build", the platform we are
1056-
# currently running on
1057-
self.addStep(
1058-
ShellCommand(
1059-
name="mkdir build out-of-tree directory",
1060-
description="Create build out-of-tree directory",
1061-
command=["mkdir", "-p", oot_build_path],
1062-
warnOnFailure=True,
1063-
)
1054+
# Create out of tree directory for "build", the platform we are
1055+
# currently running on
1056+
self.addStep(
1057+
ShellCommand(
1058+
name="mkdir build out-of-tree directory",
1059+
description="Create build out-of-tree directory",
1060+
command=["mkdir", "-p", oot_build_path],
1061+
warnOnFailure=True,
10641062
)
1065-
# Create directory for "host", the platform we want to compile *for*
1066-
self.addStep(
1067-
ShellCommand(
1068-
name="mkdir host out-of-tree directory",
1069-
description="Create host out-of-tree directory",
1070-
command=["mkdir", "-p", oot_host_path],
1071-
warnOnFailure=True,
1072-
)
1063+
)
1064+
# Create directory for "host", the platform we want to compile *for*
1065+
self.addStep(
1066+
ShellCommand(
1067+
name="mkdir host out-of-tree directory",
1068+
description="Create host out-of-tree directory",
1069+
command=["mkdir", "-p", oot_host_path],
1070+
warnOnFailure=True,
10731071
)
1072+
)
10741073

1075-
# First, we build the "build" Python, which we need to cross compile
1076-
# the "host" Python
1077-
self.addStep(
1078-
Configure(
1079-
name="Configure build Python",
1080-
command=["../../configure"],
1081-
workdir=oot_build_path,
1082-
)
1074+
# First, we build the "build" Python, which we need to cross compile
1075+
# the "host" Python
1076+
self.addStep(
1077+
Configure(
1078+
name="Configure build Python",
1079+
command=["../../configure"],
1080+
workdir=oot_build_path,
10831081
)
1084-
if parallel:
1085-
compile = ["make", parallel]
1086-
else:
1087-
compile = ["make"]
1082+
)
1083+
if parallel:
1084+
compile = ["make", parallel]
1085+
else:
1086+
compile = ["make"]
10881087

1089-
self.addStep(
1090-
Compile(
1091-
name="Compile build Python", command=compile, workdir=oot_build_path
1092-
)
1088+
self.addStep(
1089+
Compile(
1090+
name="Compile build Python", command=compile, workdir=oot_build_path
10931091
)
1092+
)
10941093

1095-
# Ensure the host path is isolated from Homebrew et al, but includes
1096-
# the host helper binaries. Also add the configuration paths for
1097-
# library dependencies.
1098-
support_path = f"/Users/buildbot/support/iphonesimulator.{self.arch}"
1099-
compile_environ = dict(self.compile_environ)
1100-
compile_environ.update(
1101-
{
1102-
"PATH": os.pathsep.join(
1103-
[
1104-
# This is intentionally a relative path. Buildbot doesn't expose
1105-
# the absolute working directory where the build is running as
1106-
# something that can be expanded into an environment variable.
1107-
"../../iOS/Resources/bin",
1108-
"/usr/bin",
1109-
"/bin",
1110-
"/usr/sbin",
1111-
"/sbin",
1112-
"/Library/Apple/usr/bin",
1113-
]
1114-
),
1115-
"LIBLZMA_CFLAGS": f"-I{support_path}/xz/include",
1116-
"LIBLZMA_LIBS": f"-L{support_path}/xz/lib -llzma",
1117-
"BZIP2_CFLAGS": f"-I{support_path}/bzip2/include",
1118-
"BZIP2_LIBS": f"-L{support_path}/bzip2/lib -lbz2",
1119-
"LIBFFI_CFLAGS": f"-I{support_path}/libffi/include",
1120-
"LIBFFI_LIBS": f"-L{support_path}/libffi/lib -lffi",
1121-
}
1122-
)
1094+
# Ensure the host path is isolated from Homebrew et al, but includes
1095+
# the host helper binaries. Also add the configuration paths for
1096+
# library dependencies.
1097+
support_path = f"/Users/buildbot/support/iphonesimulator.{self.arch}"
1098+
compile_environ = dict(self.compile_environ)
1099+
compile_environ.update(
1100+
{
1101+
"PATH": os.pathsep.join(
1102+
[
1103+
# This is intentionally a relative path. Buildbot doesn't expose
1104+
# the absolute working directory where the build is running as
1105+
# something that can be expanded into an environment variable.
1106+
"../../iOS/Resources/bin",
1107+
"/usr/bin",
1108+
"/bin",
1109+
"/usr/sbin",
1110+
"/sbin",
1111+
"/Library/Apple/usr/bin",
1112+
]
1113+
),
1114+
"LIBLZMA_CFLAGS": f"-I{support_path}/xz/include",
1115+
"LIBLZMA_LIBS": f"-L{support_path}/xz/lib -llzma",
1116+
"BZIP2_CFLAGS": f"-I{support_path}/bzip2/include",
1117+
"BZIP2_LIBS": f"-L{support_path}/bzip2/lib -lbz2",
1118+
"LIBFFI_CFLAGS": f"-I{support_path}/libffi/include",
1119+
"LIBFFI_LIBS": f"-L{support_path}/libffi/lib -lffi",
1120+
}
1121+
)
11231122

1124-
# Now that we have a "build" architecture Python, we can use that
1125-
# to build a "host" (also known as the target we are cross compiling)
1126-
# Take a copy so that the class-level definition isn't tainted
1127-
configure_cmd = list(self.host_configure_cmd)
1128-
configure_cmd += self.configureFlags
1129-
configure_cmd += self.extra_configure_flags
1130-
configure_cmd += [
1131-
f"--with-openssl={support_path}/openssl",
1132-
f"--build={self.arch}-apple-darwin",
1133-
f"--host={self.host}",
1134-
"--with-build-python=../build/python.exe",
1135-
"--enable-framework",
1136-
]
1123+
# Now that we have a "build" architecture Python, we can use that
1124+
# to build a "host" (also known as the target we are cross compiling)
1125+
# Take a copy so that the class-level definition isn't tainted
1126+
configure_cmd = list(self.host_configure_cmd)
1127+
configure_cmd += self.configureFlags
1128+
configure_cmd += self.extra_configure_flags
1129+
configure_cmd += [
1130+
f"--with-openssl={support_path}/openssl",
1131+
f"--build={self.arch}-apple-darwin",
1132+
f"--host={self.host}",
1133+
"--with-build-python=../build/python.exe",
1134+
"--enable-framework",
1135+
]
11371136

1138-
self.addStep(
1139-
Configure(
1140-
name="Configure host Python",
1141-
command=configure_cmd,
1142-
env=compile_environ,
1143-
workdir=oot_host_path,
1144-
)
1137+
self.addStep(
1138+
Configure(
1139+
name="Configure host Python",
1140+
command=configure_cmd,
1141+
env=compile_environ,
1142+
workdir=oot_host_path,
11451143
)
1144+
)
11461145

1147-
if parallel:
1148-
compile = ["make", parallel, self.makeTarget]
1149-
install = ["make", parallel, "install"]
1150-
else:
1151-
compile = ["make", self.makeTarget]
1152-
install = ["make", "install"]
1146+
if parallel:
1147+
compile = ["make", parallel, self.makeTarget]
1148+
install = ["make", parallel, "install"]
1149+
else:
1150+
compile = ["make", self.makeTarget]
1151+
install = ["make", "install"]
11531152

1154-
self.addStep(
1155-
Compile(
1156-
name="Compile host Python",
1157-
command=compile,
1158-
env=compile_environ,
1159-
workdir=oot_host_path,
1160-
)
1153+
self.addStep(
1154+
Compile(
1155+
name="Compile host Python",
1156+
command=compile,
1157+
env=compile_environ,
1158+
workdir=oot_host_path,
11611159
)
1162-
self.addStep(
1163-
Compile(
1164-
name="Install host Python",
1165-
command=install,
1166-
env=compile_environ,
1167-
workdir=oot_host_path,
1168-
)
1160+
)
1161+
self.addStep(
1162+
Compile(
1163+
name="Install host Python",
1164+
command=install,
1165+
env=compile_environ,
1166+
workdir=oot_host_path,
11691167
)
1170-
self.addStep(
1171-
Test(
1172-
command=["make", "testios"],
1173-
timeout=step_timeout(self.test_timeout),
1174-
usePTY=test_with_PTY,
1175-
env=self.test_environ,
1176-
workdir=oot_host_path,
1177-
)
1168+
)
1169+
self.addStep(
1170+
Test(
1171+
command=["make", "testios"],
1172+
timeout=step_timeout(self.test_timeout),
1173+
usePTY=test_with_PTY,
1174+
env=self.test_environ,
1175+
workdir=oot_host_path,
11781176
)
1177+
)
11791178

1180-
self.addStep(
1181-
Clean(
1182-
name="Clean build Python",
1183-
workdir=oot_build_path,
1184-
)
1179+
self.addStep(
1180+
Clean(
1181+
name="Clean build Python",
1182+
workdir=oot_build_path,
11851183
)
1186-
self.addStep(
1187-
Clean(
1188-
name="Clean host Python",
1189-
workdir=oot_host_path,
1190-
)
1184+
)
1185+
self.addStep(
1186+
Clean(
1187+
name="Clean host Python",
1188+
workdir=oot_host_path,
11911189
)
1192-
else:
1193-
# Builds of Python 3.14+ can use the XCframework build script.
1194-
#
1195-
# The script moved to the Platforms folder in 3.15; the first command
1196-
# symlinks to the "new" location so that the 3.15+ build instructions
1197-
# will work as-is. This will fail on <= 3.13 PR branches.
1198-
build_environ = {
1199-
"CACHE_DIR": "/Users/buildbot/downloads",
1200-
}
1190+
)
12011191

1202-
self.addSteps(
1203-
[
1204-
ShellCommand(
1205-
name="Set up compatibility symlink",
1206-
command="[ -e Platforms/Apple ] || ln -s ../Apple Platforms/Apple",
1207-
),
1208-
Compile(
1209-
name="Configure and compile build Python",
1210-
command=["python3", "Platforms/Apple", "build", "iOS", "build"],
1211-
env=build_environ,
1212-
),
1213-
Compile(
1214-
name="Configure and compile host Pythons",
1215-
command=["python3", "Platforms/Apple", "build", "iOS", "hosts"],
1216-
env=build_environ,
1217-
),
1218-
Compile(
1219-
name="Package XCframework",
1220-
command=["python3", "Platforms/Apple", "package", "iOS"],
1221-
env=build_environ,
1222-
),
1223-
Test(
1224-
name="Run test suite",
1225-
command=[
1226-
"python3",
1227-
"Platforms/Apple",
1228-
"test",
1229-
"iOS",
1230-
"--slow-ci",
1231-
],
1232-
env=build_environ,
1233-
timeout=step_timeout(self.test_timeout),
1234-
),
1235-
Clean(
1236-
name="Clean the builds",
1237-
command=["python3", "Platforms/Apple", "clean", "iOS"],
1238-
env=build_environ,
1239-
),
1240-
]
1241-
)
1192+
def current_setup(self):
1193+
build_environ = {
1194+
"CACHE_DIR": "/Users/buildbot/downloads",
1195+
}
1196+
1197+
self.addSteps(
1198+
[
1199+
# This symlink is needed to support Python 3.14 builds - it makes the
1200+
# top level Apple folder appear in the new Platforms/Apple location.
1201+
# It will fail on 3.13 PR branches because the top level Apple folder
1202+
# doesn't exist. This step can be removed when 3.14 is no longer
1203+
# supported.
1204+
ShellCommand(
1205+
name="Set up compatibility symlink",
1206+
command="[ -e Platforms/Apple ] || ln -s ../Apple Platforms/Apple",
1207+
),
1208+
# Build the full iOS XCframework, including a multi-arch simulator slice.
1209+
Compile(
1210+
name="Configure and compile build Python",
1211+
command=["python3", "Platforms/Apple", "build", "iOS", "build"],
1212+
env=build_environ,
1213+
),
1214+
Compile(
1215+
name="Configure and compile host Pythons",
1216+
command=["python3", "Platforms/Apple", "build", "iOS", "hosts"],
1217+
env=build_environ,
1218+
),
1219+
Compile(
1220+
name="Package XCframework",
1221+
command=["python3", "Platforms/Apple", "package", "iOS"],
1222+
env=build_environ,
1223+
),
1224+
Test(
1225+
name="Run test suite",
1226+
command=[
1227+
"python3",
1228+
"Platforms/Apple",
1229+
"test",
1230+
"iOS",
1231+
"--slow-ci",
1232+
],
1233+
env=build_environ,
1234+
timeout=step_timeout(self.test_timeout),
1235+
),
1236+
Clean(
1237+
name="Clean the builds",
1238+
command=["python3", "Platforms/Apple", "clean", "iOS"],
1239+
env=build_environ,
1240+
),
1241+
]
1242+
)
1243+
1244+
def setup(self, parallel, branch, test_with_PTY=False, **kwargs):
1245+
# Builds on Python 3.13 use a direct set of calls to make. Python 3.14
1246+
# introduced a simpler XCframework build script; Python 3.15 moved that
1247+
# script to the Platforms folder.
1248+
#
1249+
# The `Platforms/Apple` location can be used for 3.14 builds with a
1250+
# symlink, but 3.13 builds have to used the build process.
1251+
#
1252+
# The symlink approach will fail for Python 3.13 *PR* builds, because
1253+
# there's no way to identify the base branch for a PR.
1254+
if branch == "3.13":
1255+
self.historical_setup(parallel, test_with_PTY=test_with_PTY)
1256+
else:
1257+
self.current_setup()
12421258

12431259

12441260
class IOSARM64SimulatorBuild(_IOSSimulatorBuild):

0 commit comments

Comments
 (0)