@@ -58,20 +58,24 @@ def update_props(source, old, new):
5858 :type new: str
5959 """
6060 patch_file (source / "PCbuild" / "python.props" , old , new )
61+ patch_file (source / "PCbuild" / "get_externals.bat" , old , new )
6162
6263
63- def get_externals_source (source_root , url ):
64+ def get_externals_source (externals_dir , url ):
6465 """
6566 Download external source code dependency.
6667
6768 Download source code and extract to the "externals" directory in the root of
6869 the python source. Only works with a tarball
6970 """
70- externals_dir = source_root / "externals"
71- externals_dir .mkdir (parents = True , exist_ok = True )
72- local_file = download_url (url , str (externals_dir ))
73- extract_archive (str (local_file ), str (externals_dir ))
74- os .path .unlink (str (local_file ))
71+ zips_dir = externals_dir / "zips"
72+ zips_dir .mkdir (parents = True , exist_ok = True )
73+ local_file = download_url (url = url , dest = str (zips_dir ))
74+ extract_archive (archive = str (local_file ), to_dir = str (externals_dir ))
75+ try :
76+ os .remove (local_file )
77+ except OSError :
78+ log .exception ("Failed to remove temporary file" )
7579
7680
7781def get_externals_bin (source_root , url ):
@@ -96,30 +100,39 @@ def build_python(env, dirs, logfp):
96100 :type logfp: file
97101 """
98102 # Override default versions
103+
104+ # Create externals directory
105+ externals_dir = dirs .source / "externals"
106+ externals_dir .mkdir (parents = True , exist_ok = True )
107+
99108 # SQLITE
100109 if env ["RELENV_PY_MAJOR_VERSION" ] in ["3.10" , "3.11" , "3.12" ]:
101110 version = "3.50.4.0"
102- update_props (dirs .source , r"sqlite-\d+.\d+.\d+.\d+" , "sqlite-{ver}" )
103- url = "https://sqlite.org/2025/sqlite-autoconf-3500400.tar.gz"
104- get_externals_source (dirs .source , url = url )
105- # we need to fix the name of the extracted directory
106- extracted_dir = dirs .source / "externals" / "sqlite-src-3500400"
107- target_dir = dirs .source / "externals" / f"sqlite-{ version } "
108- shutil .move (str (extracted_dir ), str (target_dir ))
111+ target_dir = externals_dir / f"sqlite-{ version } "
112+ if not target_dir .exists ():
113+ update_props (dirs .source , r"sqlite-\d+.\d+.\d+.\d+" , f"sqlite-{ version } " )
114+ url = "https://sqlite.org/2025/sqlite-autoconf-3500400.tar.gz"
115+ get_externals_source (externals_dir = externals_dir , url = url )
116+ # # we need to fix the name of the extracted directory
117+ extracted_dir = externals_dir / "sqlite-autoconf-3500400"
118+ shutil .move (str (extracted_dir ), str (target_dir ))
109119
110120 # XZ-Utils
111121 if env ["RELENV_PY_MAJOR_VERSION" ] in ["3.10" , "3.11" , "3.12" , "3.13" , "3.14" ]:
112- update_props (dirs .source , r"xz-\d+.\d+.\d+" , "xz-5.6.2" )
113- url = "https://github.com/tukaani-project/xz/releases/download/v5.6.2/xz-5.6.2.tar.xz"
114- get_externals_source (dirs .source , url = url )
115-
116- # zlib (3.14 uses zlib-ng)
117- if env ["RELENV_PY_MAJOR_VERSION" ] in ["3.10" , "3.11" , "3.12" , "3.13" ]:
118- # already in python.props with the correct version in all the above versions
119- # update_props(dirs.source, r"zlib-\d+.\d+.\d+", "zlib-1.3.1")
120- # but it still needs to be in "externals"
121- url = "https://zlib.net/zlib-1.3.1.tar.gz"
122- get_externals_source (dirs .source , url = url )
122+ version = "5.6.2"
123+ target_dir = externals_dir / f"xz-{ version } "
124+ if not target_dir .exists ():
125+ update_props (dirs .source , r"xz-\d+.\d+.\d+" , f"xz-{ version } " )
126+ url = f"https://github.com/tukaani-project/xz/releases/download/v{ version } /xz-{ version } .tar.xz"
127+ get_externals_source (externals_dir = externals_dir , url = url )
128+ # Starting with version v5.5.0, XZ-Utils removed the ability to compile
129+ # with MSBuild. We are bringing the config.h from the last version that
130+ # had it, 5.4.7
131+ config_file = target_dir / "windows" / "config.h"
132+ config_file = target_dir / "src" / "common" / "config.h"
133+ config_file_source = dirs .root / "_resources" / "xz" / "config.h"
134+ if not config_file .exists ():
135+ shutil .copy (str (config_file_source ), str (config_file ))
123136
124137 arch_to_plat = {
125138 "amd64" : "x64" ,
@@ -133,7 +146,6 @@ def build_python(env, dirs, logfp):
133146 "-p" ,
134147 plat ,
135148 "--no-tkinter" ,
136- "-e" ,
137149 ]
138150
139151 log .info ("Start PCbuild" )
0 commit comments