Skip to content

Commit f4f3f9b

Browse files
committed
Fix paths for ffi
1 parent f4cc860 commit f4f3f9b

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed

relenv/build/windows.py

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ def update_props(source: pathlib.Path, old: str, new: str) -> None:
7272
:param new: Replacement text
7373
:type new: str
7474
"""
75+
log.info("Patching props in %s: %s -> %s", source, old, new)
7576
patch_file(source / "PCbuild" / "python.props", old, new)
7677
patch_file(source / "PCbuild" / "get_externals.bat", old, new)
7778

@@ -190,6 +191,11 @@ def update_xz(dirs: Dirs, env: EnvMapping) -> None:
190191
target_dir.parent.mkdir(parents=True, exist_ok=True)
191192
if not target_dir.exists():
192193
update_props(dirs.source, r"xz-\d+\.\d+\.\d+\\?", f"xz-{version}")
194+
patch_file(
195+
dirs.source / "PCbuild" / "python.props",
196+
r"<lzmaDir.*>.*</lzmaDir>",
197+
f"<lzmaDir Condition=\"$(lzmaDir) == ''\">$(ExternalsDir)xz-{version}\\</lzmaDir>",
198+
)
193199
get_externals_source(externals_dir=dirs.source / "externals", url=url)
194200
# Starting with version v5.5.0, XZ-Utils removed the ability to compile
195201
# with MSBuild. We are bringing the config.h from the last version that
@@ -315,7 +321,24 @@ def update_openssl(dirs: Dirs, env: EnvMapping) -> None:
315321
update_props(
316322
dirs.source, r"openssl-bin-\d+\.\d+\.\d+[a-z]*\\?", f"openssl-bin-{version}"
317323
)
324+
patch_file(
325+
dirs.source / "PCbuild" / "python.props",
326+
r"<opensslIncludeDir.*>.*</opensslIncludeDir>",
327+
"<opensslIncludeDir Condition=\"$(opensslIncludeDir) == ''\">$(opensslDir)include</opensslIncludeDir>",
328+
)
329+
patch_file(
330+
dirs.source / "PCbuild" / "python.props",
331+
r"<opensslOutDir.*>.*</opensslOutDir>",
332+
"<opensslOutDir Condition=\"$(opensslOutDir) == ''\">$(opensslDir)bin\\$(ArchName)\\</opensslOutDir>",
333+
)
318334
get_externals_source(externals_dir=dirs.source / "externals", url=url)
335+
# Standardize directory layout (handle nested folders in tarball)
336+
extracted_dir = dirs.source / "externals" / f"openssl-{version}"
337+
if (extracted_dir / f"openssl-{version}").exists():
338+
temp_dir = dirs.source / "externals" / f"openssl-{version}-tmp"
339+
shutil.move(str(extracted_dir / f"openssl-{version}"), str(temp_dir))
340+
shutil.rmtree(str(extracted_dir))
341+
shutil.move(str(temp_dir), str(extracted_dir))
319342

320343
# Update externals.spdx.json with the correct version, url, and hash
321344
# This became a thing in 3.12
@@ -353,6 +376,13 @@ def update_bzip2(dirs: Dirs, env: EnvMapping) -> None:
353376
if not target_dir.exists():
354377
update_props(dirs.source, r"bzip2-\d+\.\d+\.\d+\\?", f"bzip2-{version}")
355378
get_externals_source(externals_dir=dirs.source / "externals", url=url)
379+
# Standardize directory layout (handle nested folders in tarball)
380+
extracted_dir = dirs.source / "externals" / f"bzip2-{version}"
381+
if (extracted_dir / f"bzip2-{version}").exists():
382+
temp_dir = dirs.source / "externals" / f"bzip2-{version}-tmp"
383+
shutil.move(str(extracted_dir / f"bzip2-{version}"), str(temp_dir))
384+
shutil.rmtree(str(extracted_dir))
385+
shutil.move(str(temp_dir), str(extracted_dir))
356386

357387
# Update externals.spdx.json
358388
if env["RELENV_PY_MAJOR_VERSION"] in ["3.12", "3.13", "3.14"]:
@@ -388,7 +418,36 @@ def update_libffi(dirs: Dirs, env: EnvMapping) -> None:
388418
target_dir.parent.mkdir(parents=True, exist_ok=True)
389419
if not target_dir.exists():
390420
update_props(dirs.source, r"libffi-\d+\.\d+\.\d+\\?", f"libffi-{version}")
421+
patch_file(
422+
dirs.source / "PCbuild" / "python.props",
423+
r"<libffiIncludeDir.*>.*</libffiIncludeDir>",
424+
"<libffiIncludeDir Condition=\"$(libffiIncludeDir) == ''\">$(libffiDir)include</libffiIncludeDir>",
425+
)
426+
patch_file(
427+
dirs.source / "PCbuild" / "python.props",
428+
r"<libffiOutDir.*>.*</libffiOutDir>",
429+
"<libffiOutDir Condition=\"$(libffiOutDir) == ''\">$(libffiDir)bin\\$(ArchName)\\</libffiOutDir>",
430+
)
431+
# Patch libffi.props to use the correct library names if necessary
432+
# libffi 3.4.x+ usually produces libffi-8.lib/dll, while 3.3.0 used libffi-7
433+
patch_file(
434+
dirs.source / "PCbuild" / "libffi.props",
435+
r"libffi-7.lib",
436+
r"libffi-8.lib",
437+
)
438+
patch_file(
439+
dirs.source / "PCbuild" / "libffi.props",
440+
r"libffi-7.dll",
441+
r"libffi-8.dll",
442+
)
391443
get_externals_source(externals_dir=dirs.source / "externals", url=url)
444+
# Standardize directory layout (handle nested folders in tarball)
445+
extracted_dir = dirs.source / "externals" / f"libffi-{version}"
446+
if (extracted_dir / f"libffi-{version}").exists():
447+
temp_dir = dirs.source / "externals" / f"libffi-{version}-tmp"
448+
shutil.move(str(extracted_dir / f"libffi-{version}"), str(temp_dir))
449+
shutil.rmtree(str(extracted_dir))
450+
shutil.move(str(temp_dir), str(extracted_dir))
392451

393452
# Update externals.spdx.json
394453
if env["RELENV_PY_MAJOR_VERSION"] in ["3.12", "3.13", "3.14"]:
@@ -425,6 +484,13 @@ def update_zlib(dirs: Dirs, env: EnvMapping) -> None:
425484
if not target_dir.exists():
426485
update_props(dirs.source, r"zlib-\d+\.\d+\.\d+\\?", f"zlib-{version}")
427486
get_externals_source(externals_dir=dirs.source / "externals", url=url)
487+
# Standardize directory layout (handle nested folders in tarball)
488+
extracted_dir = dirs.source / "externals" / f"zlib-{version}"
489+
if (extracted_dir / f"zlib-{version}").exists():
490+
temp_dir = dirs.source / "externals" / f"zlib-{version}-tmp"
491+
shutil.move(str(extracted_dir / f"zlib-{version}"), str(temp_dir))
492+
shutil.rmtree(str(extracted_dir))
493+
shutil.move(str(temp_dir), str(extracted_dir))
428494

429495
# Update externals.spdx.json
430496
if env["RELENV_PY_MAJOR_VERSION"] in ["3.12", "3.13", "3.14"]:
@@ -482,6 +548,7 @@ def build_python(env: EnvMapping, dirs: Dirs, logfp: IO[str]) -> None:
482548
plat = arch_to_plat[arch]
483549
cmd = [
484550
str(dirs.source / "PCbuild" / "build.bat"),
551+
"-e",
485552
"-p",
486553
plat,
487554
"--no-tkinter",

0 commit comments

Comments
 (0)