Skip to content

Commit 5286109

Browse files
committed
windows: ignore missing extensions when converting to static
This unbusts static builds on <3.9.
1 parent af4460e commit 5286109

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

cpython-windows/build.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,11 @@ def make_project_static_library(source_path: pathlib.Path, project: str):
410410
def convert_to_static_library(source_path: pathlib.Path, extension: str, entry: dict):
411411
"""Converts an extension to a static library."""
412412

413+
proj_path = source_path / "PCbuild" / ("%s.vcxproj" % extension)
414+
415+
if not proj_path.exists() and entry.get("ignore_missing"):
416+
return False
417+
413418
# Make the extension's project emit a static library so we can link
414419
# against libpython.
415420
make_project_static_library(source_path, extension)
@@ -418,8 +423,6 @@ def convert_to_static_library(source_path: pathlib.Path, extension: str, entry:
418423
for project in entry.get("static_depends", []):
419424
make_project_static_library(source_path, project)
420425

421-
proj_path = source_path / "PCbuild" / ("%s.vcxproj" % extension)
422-
423426
copy_link_to_lib(proj_path)
424427

425428
lines = []
@@ -626,6 +629,8 @@ def convert_to_static_library(source_path: pathlib.Path, extension: str, entry:
626629
with pcbuild_sln_path.open("w", encoding="utf8") as fh:
627630
fh.write("\n".join(lines))
628631

632+
return True
633+
629634

630635
def copy_link_to_lib(p: pathlib.Path):
631636
"""Copy the contents of a <Link> section to a <Lib> section."""
@@ -911,8 +916,8 @@ def hack_project_files(
911916

912917
init_fn = entry.get("init", "PyInit_%s" % extension)
913918

914-
add_to_config_c(cpython_source_path, extension, init_fn)
915-
convert_to_static_library(cpython_source_path, extension, entry)
919+
if convert_to_static_library(cpython_source_path, extension, entry):
920+
add_to_config_c(cpython_source_path, extension, init_fn)
916921

917922
# pythoncore.vcxproj produces libpython. Typically pythonXY.dll. We change
918923
# it to produce a static library.

0 commit comments

Comments
 (0)