Skip to content

Commit 77fe001

Browse files
committed
Toggle zlib to zlib-ng on 3.14+
1 parent d57fd69 commit 77fe001

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

cpython-windows/build.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -346,16 +346,18 @@ def hack_props(
346346
pcbuild_path: pathlib.Path,
347347
arch: str,
348348
python_version: str,
349+
zlib_entry: str
349350
):
350351
# TODO can we pass props into msbuild.exe?
351352

352353
# Our dependencies are in different directories from what CPython's
353354
# build system expects. Modify the config file appropriately.
354355

356+
355357
bzip2_version = DOWNLOADS["bzip2"]["version"]
356358
sqlite_version = DOWNLOADS["sqlite"]["version"]
357359
xz_version = DOWNLOADS["xz"]["version"]
358-
zlib_version = DOWNLOADS["zlib"]["version"]
360+
zlib_version = DOWNLOADS[zlib_entry]["version"]
359361

360362
mpdecimal_version = DOWNLOADS["mpdecimal"]["version"]
361363

@@ -369,7 +371,7 @@ def hack_props(
369371
libffi_path = td / "libffi"
370372
tcltk_path = td / ("cpython-bin-deps-%s" % tcltk_commit)
371373
xz_path = td / ("xz-%s" % xz_version)
372-
zlib_path = td / ("zlib-%s" % zlib_version)
374+
zlib_path = td / ("%s-%s" % (zlib_entry, zlib_version))
373375
mpdecimal_path = td / ("mpdecimal-%s" % mpdecimal_version)
374376

375377
openssl_root = td / "openssl" / arch
@@ -484,6 +486,7 @@ def hack_project_files(
484486
cpython_source_path: pathlib.Path,
485487
build_directory: str,
486488
python_version: str,
489+
zlib_entry: str
487490
):
488491
"""Hacks Visual Studio project files to work with our build."""
489492

@@ -494,6 +497,7 @@ def hack_project_files(
494497
pcbuild_path,
495498
build_directory,
496499
python_version,
500+
zlib_entry,
497501
)
498502

499503
# Our SQLite directory is named weirdly. This throws off version detection
@@ -913,6 +917,7 @@ def collect_python_build_artifacts(
913917
arch: str,
914918
config: str,
915919
openssl_entry: str,
920+
zlib_entry: str,
916921
freethreaded: bool,
917922
):
918923
"""Collect build artifacts from Python.
@@ -1142,6 +1147,9 @@ def find_additional_dependencies(project: pathlib.Path):
11421147
if name == "openssl":
11431148
name = openssl_entry
11441149

1150+
if name = "zlib":
1151+
name = zlib_entry
1152+
11451153
# On 3.14+, we use the latest tcl/tk version
11461154
if ext == "_tkinter" and python_majmin == "314":
11471155
name = name.replace("-8612", "")
@@ -1213,10 +1221,12 @@ def build_cpython(
12131221
# The python.props file keys off MSBUILD, so it needs to be set.
12141222
os.environ["MSBUILD"] = str(msbuild)
12151223

1224+
zlib_entry = "zlib-ng" if meets_python_minimum_version("3.14") else "zlib"
1225+
12161226
bzip2_archive = download_entry("bzip2", BUILD)
12171227
sqlite_archive = download_entry("sqlite", BUILD)
12181228
xz_archive = download_entry("xz", BUILD)
1219-
zlib_archive = download_entry("zlib", BUILD)
1229+
zlib_archive = download_entry(zlib_entry, BUILD)
12201230

12211231
python_archive = download_entry(python_entry_name, BUILD)
12221232
entry = DOWNLOADS[python_entry_name]
@@ -1328,6 +1338,7 @@ def build_cpython(
13281338
cpython_source_path,
13291339
build_directory,
13301340
python_version=python_version,
1341+
zlib_entry=zlib_entry,
13311342
)
13321343

13331344
if pgo:
@@ -1528,6 +1539,7 @@ def build_cpython(
15281539
build_directory,
15291540
artifact_config,
15301541
openssl_entry=openssl_entry,
1542+
zlib_entry=zlib_entry,
15311543
freethreaded=freethreaded,
15321544
)
15331545

pythonbuild/downloads.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,4 +446,13 @@
446446
"licenses": ["Zlib"],
447447
"license_file": "LICENSE.zlib.txt",
448448
},
449+
"zlib-ng": {
450+
"url": "https://github.com/python/cpython-source-deps/archive/refs/tags/zlib-ng-2.2.4.tar.gz",
451+
"size": 2415819,
452+
"sha256": "00bbd88709bc416cb96160ab61d3e1c8f76e106799af7328d0fe434dc7dd5004",
453+
"version": "2.2.4",
454+
"library_names": ["z"],
455+
"licenses": ["Zlib"],
456+
"license_file": "LICENSE.zlib-ng.txt",
457+
}
449458
}

0 commit comments

Comments
 (0)