Skip to content

Commit 780dab5

Browse files
committed
Use the latest tcl/tk for 3.14
1 parent 48d1c17 commit 780dab5

File tree

2 files changed

+40
-6
lines changed

2 files changed

+40
-6
lines changed

cpython-windows/build.py

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,7 @@ def hack_props(
345345
td: pathlib.Path,
346346
pcbuild_path: pathlib.Path,
347347
arch: str,
348+
python_version: str,
348349
):
349350
# TODO can we pass props into msbuild.exe?
350351

@@ -355,9 +356,14 @@ def hack_props(
355356
sqlite_version = DOWNLOADS["sqlite"]["version"]
356357
xz_version = DOWNLOADS["xz"]["version"]
357358
zlib_version = DOWNLOADS["zlib"]["version"]
358-
tcltk_commit = DOWNLOADS["tk-windows-bin-8612"]["git_commit"]
359+
359360
mpdecimal_version = DOWNLOADS["mpdecimal"]["version"]
360361

362+
if meets_python_minimum_version(python_version, "3.14"):
363+
tcltk_commit = DOWNLOADS["tk-windows-bin"]["git_commit"]
364+
else:
365+
tcltk_commit = DOWNLOADS["tk-windows-bin-8612"]["git_commit"]
366+
361367
sqlite_path = td / ("sqlite-autoconf-%s" % sqlite_version)
362368
bzip2_path = td / ("bzip2-%s" % bzip2_version)
363369
libffi_path = td / "libffi"
@@ -487,6 +493,7 @@ def hack_project_files(
487493
td,
488494
pcbuild_path,
489495
build_directory,
496+
python_version,
490497
)
491498

492499
# Our SQLite directory is named weirdly. This throws off version detection
@@ -1128,6 +1135,10 @@ def find_additional_dependencies(project: pathlib.Path):
11281135
if name == "openssl":
11291136
name = openssl_entry
11301137

1138+
# On 3.14+, we use the latest tcl/tk version
1139+
if ext == "_tkinter" and python_majmin == "314":
1140+
name = name.replace("-8612", "")
1141+
11311142
download_entry = DOWNLOADS[name]
11321143

11331144
# This will raise if no license metadata defined. This is
@@ -1197,9 +1208,6 @@ def build_cpython(
11971208

11981209
bzip2_archive = download_entry("bzip2", BUILD)
11991210
sqlite_archive = download_entry("sqlite", BUILD)
1200-
tk_bin_archive = download_entry(
1201-
"tk-windows-bin-8612", BUILD, local_name="tk-windows-bin.tar.gz"
1202-
)
12031211
xz_archive = download_entry("xz", BUILD)
12041212
zlib_archive = download_entry("zlib", BUILD)
12051213

@@ -1211,6 +1219,17 @@ def build_cpython(
12111219
setuptools_wheel = download_entry("setuptools", BUILD)
12121220
pip_wheel = download_entry("pip", BUILD)
12131221

1222+
# On CPython 3.14+, we use the latest tcl/tk version which has additional runtime
1223+
# dependencies, so we are conservative and use the old version elsewhere.
1224+
if meets_python_minimum_version(python_version, "3.14"):
1225+
tk_bin_archive = download_entry(
1226+
"tk-windows-bin", BUILD, local_name="tk-windows-bin.tar.gz"
1227+
)
1228+
else:
1229+
tk_bin_archive = download_entry(
1230+
"tk-windows-bin-8612", BUILD, local_name="tk-windows-bin.tar.gz"
1231+
)
1232+
12141233
# CPython 3.13+ no longer uses a bundled `mpdecimal` version so we build it
12151234
if meets_python_minimum_version(python_version, "3.13"):
12161235
mpdecimal_archive = download_entry("mpdecimal", BUILD)

src/validation.rs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@ const PE_ALLOWED_LIBRARIES: &[&str] = &[
137137
"tk86t.dll",
138138
];
139139

140+
const PE_ALLOWED_LIBRARIES_314: &[&str] = &["msvcrt.dll"];
141+
140142
static GLIBC_MAX_VERSION_BY_TRIPLE: Lazy<HashMap<&'static str, version_compare::Version<'static>>> =
141143
Lazy::new(|| {
142144
let mut versions = HashMap::new();
@@ -1331,6 +1333,7 @@ fn validate_macho<Mach: MachHeader<Endian = Endianness>>(
13311333

13321334
fn validate_pe<'data, Pe: ImageNtHeaders>(
13331335
context: &mut ValidationContext,
1336+
python_major_minor: &str,
13341337
path: &Path,
13351338
pe: &PeFile<'data, Pe, &'data [u8]>,
13361339
) -> Result<()> {
@@ -1346,6 +1349,18 @@ fn validate_pe<'data, Pe: ImageNtHeaders>(
13461349
let lib = import_table.name(descriptor.name.get(object::LittleEndian))?;
13471350
let lib = String::from_utf8(lib.to_vec())?;
13481351

1352+
match python_major_minor {
1353+
"3.9" | "3.10" | "3.11" | "3.12" | "3.13" => {}
1354+
"3.14" => {
1355+
if PE_ALLOWED_LIBRARIES_314.contains(&lib.as_str()) {
1356+
continue;
1357+
}
1358+
}
1359+
_ => {
1360+
panic!("unhandled Python version: {}", python_major_minor);
1361+
}
1362+
}
1363+
13491364
if !PE_ALLOWED_LIBRARIES.contains(&lib.as_str()) {
13501365
context
13511366
.errors
@@ -1451,11 +1466,11 @@ fn validate_possible_object_file(
14511466
}
14521467
FileKind::Pe32 => {
14531468
let file = PeFile32::parse(data)?;
1454-
validate_pe(&mut context, path, &file)?;
1469+
validate_pe(&mut context, python_major_minor, path, &file)?;
14551470
}
14561471
FileKind::Pe64 => {
14571472
let file = PeFile64::parse(data)?;
1458-
validate_pe(&mut context, path, &file)?;
1473+
validate_pe(&mut context, python_major_minor, path, &file)?;
14591474
}
14601475
_ => {}
14611476
}

0 commit comments

Comments
 (0)