@@ -774,27 +774,31 @@ def hack_props(
774
774
for line in fh :
775
775
line = line .rstrip ()
776
776
777
- if b"<bz2Dir>" in line :
777
+ # The syntax of these lines changed in 3.10+. 3.10 backport commit
778
+ # 3139ea33ed84190e079d6ff4859baccdad778dae. Once we drop support for
779
+ # Python 3.9 we can pass these via properties instead of editing the
780
+ # properties file.
781
+ if b"<bz2Dir" in line :
778
782
line = b"<bz2Dir>%s\\ </bz2Dir>" % bzip2_path
779
783
780
- elif b"<libffiOutDir> " in line :
784
+ elif b"<libffiOutDir" in line :
781
785
line = b"<libffiOutDir>%s\\ </libffiOutDir>" % libffi_path
782
786
783
- elif b"<lzmaDir> " in line :
787
+ elif b"<lzmaDir" in line :
784
788
line = b"<lzmaDir>%s\\ </lzmaDir>" % xz_path
785
789
786
- elif b"<opensslIncludeDir> " in line :
790
+ elif b"<opensslIncludeDir" in line :
787
791
line = (
788
792
b"<opensslIncludeDir>%s</opensslIncludeDir>" % openssl_include_path
789
793
)
790
794
791
- elif b"<opensslOutDir> " in line :
795
+ elif b"<opensslOutDir" in line :
792
796
line = b"<opensslOutDir>%s\\ </opensslOutDir>" % openssl_libs_path
793
797
794
- elif b"<sqlite3Dir> " in line :
798
+ elif b"<sqlite3Dir" in line :
795
799
line = b"<sqlite3Dir>%s\\ </sqlite3Dir>" % sqlite_path
796
800
797
- elif b"<zlibDir> " in line :
801
+ elif b"<zlibDir" in line :
798
802
line = b"<zlibDir>%s\\ </zlibDir>" % zlib_path
799
803
800
804
lines .append (line )
@@ -804,11 +808,21 @@ def hack_props(
804
808
805
809
tcltkprops_path = pcbuild_path / "tcltk.props"
806
810
807
- static_replace_in_file (
808
- tcltkprops_path ,
809
- rb"<tcltkDir>$(ExternalsDir)tcltk-$(TclMajorVersion).$(TclMinorVersion).$(TclPatchLevel).$(TclRevision)\$(ArchName)\</tcltkDir>" ,
810
- rb"<tcltkDir>%s\$(ArchName)\</tcltkDir>" % tcltk_path ,
811
- )
811
+ # Later versions of 3.10 and 3.11 enabled support for defining paths via properties.
812
+ # See CPython commit 3139ea33ed84190e079d6ff4859baccdad778dae.
813
+ # Once we drop support for CPython 3.9 we can replace this with passing properties.
814
+ try :
815
+ static_replace_in_file (
816
+ tcltkprops_path ,
817
+ rb"""<tcltkDir Condition="$(tcltkDir) == ''">$(ExternalsDir)tcltk-$(TclVersion)\$(ArchName)\</tcltkDir>""" ,
818
+ rb"<tcltkDir>%s\$(ArchName)\</tcltkDir>" % tcltk_path ,
819
+ )
820
+ except NoSearchStringError :
821
+ static_replace_in_file (
822
+ tcltkprops_path ,
823
+ rb"<tcltkDir>$(ExternalsDir)tcltk-$(TclMajorVersion).$(TclMinorVersion).$(TclPatchLevel).$(TclRevision)\$(ArchName)\</tcltkDir>" ,
824
+ rb"<tcltkDir>%s\$(ArchName)\</tcltkDir>" % tcltk_path ,
825
+ )
812
826
813
827
# We want to statically link against OpenSSL. This requires using our own
814
828
# OpenSSL build. This requires some hacking of various files.
0 commit comments