From 7b9e96a6b423cf616f45e8f520bca677a6263ca3 Mon Sep 17 00:00:00 2001 From: Gregory Szorc Date: Thu, 26 May 2022 08:42:50 -0700 Subject: [PATCH] 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. --- cpython-windows/build.py | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/cpython-windows/build.py b/cpython-windows/build.py index 37f29579..1330df59 100644 --- a/cpython-windows/build.py +++ b/cpython-windows/build.py @@ -899,17 +899,23 @@ def hack_project_files( # Our version of the xz sources is newer than what's in cpython-source-deps # and the xz sources changed the path to config.h. Hack the project file # accordingly. - liblzma_path = pcbuild_path / "liblzma.vcxproj" - static_replace_in_file( - liblzma_path, - rb"$(lzmaDir)windows;$(lzmaDir)src/liblzma/common;", - rb"$(lzmaDir)windows\vs2017;$(lzmaDir)src/liblzma/common;", - ) - static_replace_in_file( - liblzma_path, - rb'', - rb'', - ) + # + # ... but CPython finally upgraded liblzma in 2022, so newer CPython releases + # already have this patch. So we're phasing it out. + try: + liblzma_path = pcbuild_path / "liblzma.vcxproj" + static_replace_in_file( + liblzma_path, + rb"$(lzmaDir)windows;$(lzmaDir)src/liblzma/common;", + rb"$(lzmaDir)windows\vs2019;$(lzmaDir)src/liblzma/common;", + ) + static_replace_in_file( + liblzma_path, + rb'', + rb'', + ) + except NoSearchStringError: + pass # Our logic for rewriting extension projects gets confused by _sqlite.vcxproj not # having a `` line in 3.10+. So adjust that.