44The windows build process.
55"""
66import glob
7- import shutil
8- import sys
7+ import logging
98import os
109import pathlib
10+ import shutil
11+ import sys
1112import tarfile
12- import logging
1313from .common import (
14- runcmd ,
15- create_archive ,
16- MODULE_DIR ,
1714 builds ,
15+ create_archive ,
16+ download_url ,
17+ extract_archive ,
1818 install_runtime ,
19+ MODULE_DIR ,
1920 patch_file ,
21+ runcmd ,
2022 update_ensurepip ,
2123)
2224from ..common import arches , WIN32
@@ -44,7 +46,7 @@ def populate_env(env, dirs):
4446 env ["MSBUILDDISABLENODEREUSE" ] = "1"
4547
4648
47- def override_dependency (source , old , new ):
49+ def update_props (source , old , new ):
4850 """
4951 Overwrite a dependency string for Windows PCBuild.
5052
@@ -56,7 +58,30 @@ def override_dependency(source, old, new):
5658 :type new: str
5759 """
5860 patch_file (source / "PCbuild" / "python.props" , old , new )
59- patch_file (source / "PCbuild" / "get_externals.bat" , old , new )
61+
62+
63+ def get_externals_source (dirs , url ):
64+ """
65+ Download external source code dependency.
66+
67+ Download source code and extract to the "externals" directory in the root of
68+ the python source. Only works with a tarball
69+ """
70+ externals_dir = dirs .source / "externals"
71+ externals_dir .mkdir (parents = True , exist_ok = True )
72+ local_file = download_url (url , externals_dir )
73+ extract_archive (local_file , externals_dir )
74+ os .path .unlink (local_file )
75+
76+
77+ def get_externals_bin (url ):
78+ """
79+ Download external binary dependency.
80+
81+ Download binaries to the "externals" directory in the root of the python
82+ source.
83+ """
84+ pass
6085
6186
6287def build_python (env , dirs , logfp ):
@@ -71,17 +96,30 @@ def build_python(env, dirs, logfp):
7196 :type logfp: file
7297 """
7398 # Override default versions
74- if env ["RELENV_PY_MAJOR_VERSION" ] in [
75- "3.10" ,
76- "3.11" ,
77- ]:
78- override_dependency (dirs .source , r"sqlite-\d+.\d+.\d+.\d+" , "sqlite-3.50.4.0" )
79- override_dependency (dirs .source , r"xz-\d+.\d+.\d+" , "xz-5.6.2" )
80- # We don't have a way to pass --organization to build.bat, so we need to
81- # patch it
82- old = r'.*get_externals\.bat"'
83- new = 'get_externals.bat --organization saltstack"'
84- patch_file (dirs .source / "PCbuild" / "build.bat" , old = old , new = new )
99+ # SQLITE
100+ if env ["RELENV_PY_MAJOR_VERSION" ] in ["3.10" , "3.11" , "3.12" ]:
101+ 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 (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 (extracted_dir , target_dir )
109+
110+ # XZ-Utils
111+ 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 (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 (url = url )
85123
86124 arch_to_plat = {
87125 "amd64" : "x64" ,
0 commit comments