gh-112984 Update Windows build and installer for free-threaded builds (GH-113129)

This commit is contained in:
Steve Dower 2024-01-17 21:52:23 +00:00 committed by GitHub
parent 78fcde039a
commit f56d132deb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
76 changed files with 1437 additions and 245 deletions

View file

@ -41,7 +41,7 @@ TCLTK_FILES_ONLY = FileNameSet("turtle.py")
VENV_DIRS_ONLY = FileNameSet("venv", "ensurepip")
EXCLUDE_FROM_PYDS = FileStemSet("python*", "pyshellext", "vcruntime*")
EXCLUDE_FROM_DLLS = FileStemSet("python*", "pyshellext", "vcruntime*")
EXCLUDE_FROM_LIB = FileNameSet("*.pyc", "__pycache__", "*.pickle")
EXCLUDE_FROM_PACKAGED_LIB = FileNameSet("readme.txt")
EXCLUDE_FROM_COMPILE = FileNameSet("badsyntax_*", "bad_*")
@ -126,9 +126,9 @@ def get_layout(ns):
n = new_name or n
src = ns.build / f
if ns.debug and src not in REQUIRED_DLLS:
if not src.stem.endswith("_d"):
if not "_d." in src.name:
src = src.parent / (src.stem + "_d" + src.suffix)
if not n.endswith("_d"):
if "_d." not in f:
n += "_d"
f = n + "." + x
yield dest + n + "." + x, src
@ -141,17 +141,45 @@ def get_layout(ns):
if lib.is_file():
yield "libs/" + n + ".lib", lib
source = "python.exe"
sourcew = "pythonw.exe"
alias = [
"python",
"python{}".format(VER_MAJOR) if ns.include_alias3 else "",
"python{}".format(VER_DOT) if ns.include_alias3x else "",
]
aliasw = [
"pythonw",
"pythonw{}".format(VER_MAJOR) if ns.include_alias3 else "",
"pythonw{}".format(VER_DOT) if ns.include_alias3x else "",
]
if ns.include_appxmanifest:
yield from in_build("python_uwp.exe", new_name="python{}".format(VER_DOT))
yield from in_build("pythonw_uwp.exe", new_name="pythonw{}".format(VER_DOT))
# For backwards compatibility, but we don't reference these ourselves.
yield from in_build("python_uwp.exe", new_name="python")
yield from in_build("pythonw_uwp.exe", new_name="pythonw")
else:
yield from in_build("python.exe", new_name="python")
yield from in_build("pythonw.exe", new_name="pythonw")
source = "python_uwp.exe"
sourcew = "pythonw_uwp.exe"
elif ns.include_freethreaded:
source = "python{}t.exe".format(VER_DOT)
sourcew = "pythonw{}t.exe".format(VER_DOT)
if not ns.include_alias:
alias = []
aliasw = []
alias.extend([
"python{}t".format(VER_DOT),
"python{}t".format(VER_MAJOR) if ns.include_alias3 else None,
])
aliasw.extend([
"pythonw{}t".format(VER_DOT),
"pythonw{}t".format(VER_MAJOR) if ns.include_alias3 else None,
])
yield from in_build(PYTHON_DLL_NAME)
for a in filter(None, alias):
yield from in_build(source, new_name=a)
for a in filter(None, aliasw):
yield from in_build(sourcew, new_name=a)
if ns.include_freethreaded:
yield from in_build(FREETHREADED_PYTHON_DLL_NAME)
else:
yield from in_build(PYTHON_DLL_NAME)
if ns.include_launchers and ns.include_appxmanifest:
if ns.include_pip:
@ -160,7 +188,10 @@ def get_layout(ns):
yield from in_build("pythonw_uwp.exe", new_name="idle{}".format(VER_DOT))
if ns.include_stable:
yield from in_build(PYTHON_STABLE_DLL_NAME)
if ns.include_freethreaded:
yield from in_build(FREETHREADED_PYTHON_STABLE_DLL_NAME)
else:
yield from in_build(PYTHON_STABLE_DLL_NAME)
found_any = False
for dest, src in rglob(ns.build, "vcruntime*.dll"):
@ -171,16 +202,28 @@ def get_layout(ns):
yield "LICENSE.txt", ns.build / "LICENSE.txt"
for dest, src in rglob(ns.build, ("*.pyd", "*.dll")):
if src.stem.endswith("_d") != bool(ns.debug) and src not in REQUIRED_DLLS:
continue
if src in EXCLUDE_FROM_PYDS:
continue
for dest, src in rglob(ns.build, "*.pyd"):
if ns.include_freethreaded:
if not src.match("*.cp*t-win*.pyd"):
continue
if bool(src.match("*_d.cp*.pyd")) != bool(ns.debug):
continue
else:
if src.match("*.cp*t-win*.pyd"):
continue
if bool(src.match("*_d.pyd")) != bool(ns.debug):
continue
if src in TEST_PYDS_ONLY and not ns.include_tests:
continue
if src in TCLTK_PYDS_ONLY and not ns.include_tcltk:
continue
yield from in_build(src.name, dest="" if ns.flat_dlls else "DLLs/")
for dest, src in rglob(ns.build, "*.dll"):
if src.stem.endswith("_d") != bool(ns.debug) and src not in REQUIRED_DLLS:
continue
if src in EXCLUDE_FROM_DLLS:
continue
yield from in_build(src.name, dest="" if ns.flat_dlls else "DLLs/")
if ns.zip_lib:
@ -191,8 +234,12 @@ def get_layout(ns):
yield "Lib/{}".format(dest), src
if ns.include_venv:
yield from in_build("venvlauncher.exe", "Lib/venv/scripts/nt/", "python")
yield from in_build("venvwlauncher.exe", "Lib/venv/scripts/nt/", "pythonw")
if ns.include_freethreaded:
yield from in_build("venvlaunchert.exe", "Lib/venv/scripts/nt/")
yield from in_build("venvwlaunchert.exe", "Lib/venv/scripts/nt/")
else:
yield from in_build("venvlauncher.exe", "Lib/venv/scripts/nt/")
yield from in_build("venvwlauncher.exe", "Lib/venv/scripts/nt/")
if ns.include_tools:
@ -208,7 +255,6 @@ def get_layout(ns):
yield PYTHON_PTH_NAME, ns.temp / PYTHON_PTH_NAME
if ns.include_dev:
for dest, src in rglob(ns.source / "Include", "**/*.h"):
yield "include/{}".format(dest), src
yield "include/pyconfig.h", ns.build / "pyconfig.h"
@ -552,7 +598,6 @@ def main():
ns.source = ns.source or (Path(__file__).resolve().parent.parent.parent)
ns.build = ns.build or Path(sys.executable).parent
ns.temp = ns.temp or Path(tempfile.mkdtemp())
ns.doc_build = ns.doc_build or (ns.source / "Doc" / "build")
if not ns.source.is_absolute():
ns.source = (Path.cwd() / ns.source).resolve()
@ -565,7 +610,12 @@ def main():
if ns.include_cat and not ns.include_cat.is_absolute():
ns.include_cat = (Path.cwd() / ns.include_cat).resolve()
if not ns.arch:
ns.arch = "amd64" if sys.maxsize > 2 ** 32 else "win32"
if sys.winver.endswith("-arm64"):
ns.arch = "arm64"
elif sys.winver.endswith("-32"):
ns.arch = "win32"
else:
ns.arch = "amd64"
if ns.copy and not ns.copy.is_absolute():
ns.copy = (Path.cwd() / ns.copy).resolve()
@ -574,6 +624,14 @@ def main():
if ns.catalog and not ns.catalog.is_absolute():
ns.catalog = (Path.cwd() / ns.catalog).resolve()
if not ns.temp:
# Put temp on a Dev Drive for speed if we're copying to one.
# If not, the regular temp dir will have to do.
if ns.copy and getattr(os.path, "isdevdrive", lambda d: False)(ns.copy):
ns.temp = ns.copy.with_name(ns.copy.name + "_temp")
else:
ns.temp = Path(tempfile.mkdtemp())
configure_logger(ns)
log_info(
@ -602,6 +660,12 @@ Catalog: {ns.catalog}""",
log_warning("Assuming --include-tcltk to support --include-idle")
ns.include_tcltk = True
if not (ns.include_alias or ns.include_alias3 or ns.include_alias3x):
if ns.include_freethreaded:
ns.include_alias3x = True
else:
ns.include_alias = True
try:
generate_source_files(ns)
files = list(get_layout(ns))