Skip to content

Commit d49911d

Browse files
committed
Use consistency exception type
1 parent 024f688 commit d49911d

File tree

1 file changed

+22
-9
lines changed

1 file changed

+22
-9
lines changed

cpython-windows/build.py

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -523,11 +523,14 @@ def hack_project_files(
523523

524524
# `--include-tcltk` is forced off on arm64, undo that
525525
# See https://github.com/python/cpython/pull/132650
526-
static_replace_in_file(
527-
cpython_source_path / "PC" / "layout" / "main.py",
528-
rb'if ns.arch in ("arm32", "arm64"):',
529-
rb'if ns.arch == "arm32":',
530-
)
526+
try:
527+
static_replace_in_file(
528+
cpython_source_path / "PC" / "layout" / "main.py",
529+
rb'if ns.arch in ("arm32", "arm64"):',
530+
rb'if ns.arch == "arm32":',
531+
)
532+
except NoSearchStringError:
533+
pass
531534

532535
# Our SQLite directory is named weirdly. This throws off version detection
533536
# in the project file. Replace the parsing logic with a static string.
@@ -1116,7 +1119,7 @@ def find_additional_dependencies(project: pathlib.Path):
11161119
elif arch == "arm64":
11171120
abi_platform = "win_arm64"
11181121
else:
1119-
raise ValueError("unhandled arch: %s" % arch)
1122+
raise Exception("unhandled architecture: %s" % arch)
11201123

11211124
if freethreaded:
11221125
abi_tag = ".cp%st-%s" % (python_majmin, abi_platform)
@@ -1216,7 +1219,7 @@ def find_additional_dependencies(project: pathlib.Path):
12161219

12171220
if name == "zlib":
12181221
name = zlib_entry
1219-
:
1222+
12201223
# On 3.14+ and aarch64, we use the latest tcl/tk version
12211224
if ext == "_tkinter" and (python_majmin == "314" or arch == "arm64"):
12221225
name = name.replace("-8612", "")
@@ -1308,7 +1311,11 @@ def build_cpython(
13081311
# runtime dependencies, so we are conservative and use the old version
13091312
# elsewhere. The old version isn't built for arm64, so we use the new
13101313
# version there too
1311-
tk_bin_entry = "tk-windows-bin" if meets_python_minimum_version(python_version, "3.14") or arch == "arm64" else "tk-windows-bin-8612"
1314+
tk_bin_entry = (
1315+
"tk-windows-bin"
1316+
if meets_python_minimum_version(python_version, "3.14") or arch == "arm64"
1317+
else "tk-windows-bin-8612"
1318+
)
13121319
tk_bin_archive = download_entry(
13131320
tk_bin_entry, BUILD, local_name="tk-windows-bin.tar.gz"
13141321
)
@@ -1396,7 +1403,13 @@ def build_cpython(
13961403
# Delete the tk nmake helper, it's not needed and links msvc
13971404
tcltk_commit: str = DOWNLOADS[tk_bin_entry]["git_commit"]
13981405
tcltk_path = td / ("cpython-bin-deps-%s" % tcltk_commit)
1399-
(tcltk_path / build_directory / "lib" / "nmake" / "x86_64-w64-mingw32-nmakehlp.exe").unlink()
1406+
(
1407+
tcltk_path
1408+
/ build_directory
1409+
/ "lib"
1410+
/ "nmake"
1411+
/ "x86_64-w64-mingw32-nmakehlp.exe"
1412+
).unlink()
14001413

14011414
cpython_source_path = td / ("Python-%s" % python_version)
14021415
pcbuild_path = cpython_source_path / "PCbuild"

0 commit comments

Comments
 (0)