Skip to content

Commit 7b9e96a

Browse files
committed
windows: account for already patched liblzma.vcxproj
3.9.13 upgraded to liblzma 5.2.5 and presumably the next 3.8 and 3.10 release will do so as well. So this rewriting is now optional.
1 parent 2a7b4b0 commit 7b9e96a

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

cpython-windows/build.py

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -899,17 +899,23 @@ def hack_project_files(
899899
# Our version of the xz sources is newer than what's in cpython-source-deps
900900
# and the xz sources changed the path to config.h. Hack the project file
901901
# accordingly.
902-
liblzma_path = pcbuild_path / "liblzma.vcxproj"
903-
static_replace_in_file(
904-
liblzma_path,
905-
rb"$(lzmaDir)windows;$(lzmaDir)src/liblzma/common;",
906-
rb"$(lzmaDir)windows\vs2017;$(lzmaDir)src/liblzma/common;",
907-
)
908-
static_replace_in_file(
909-
liblzma_path,
910-
rb'<ClInclude Include="$(lzmaDir)windows\config.h" />',
911-
rb'<ClInclude Include="$(lzmaDir)windows\vs2017\config.h" />',
912-
)
902+
#
903+
# ... but CPython finally upgraded liblzma in 2022, so newer CPython releases
904+
# already have this patch. So we're phasing it out.
905+
try:
906+
liblzma_path = pcbuild_path / "liblzma.vcxproj"
907+
static_replace_in_file(
908+
liblzma_path,
909+
rb"$(lzmaDir)windows;$(lzmaDir)src/liblzma/common;",
910+
rb"$(lzmaDir)windows\vs2019;$(lzmaDir)src/liblzma/common;",
911+
)
912+
static_replace_in_file(
913+
liblzma_path,
914+
rb'<ClInclude Include="$(lzmaDir)windows\config.h" />',
915+
rb'<ClInclude Include="$(lzmaDir)windows\vs2019\config.h" />',
916+
)
917+
except NoSearchStringError:
918+
pass
913919

914920
# Our logic for rewriting extension projects gets confused by _sqlite.vcxproj not
915921
# having a `<PreprocessorDefinitions>` line in 3.10+. So adjust that.

0 commit comments

Comments
 (0)