@@ -247,9 +247,15 @@ def in_build(f, dest="", new_name=None, no_lib=False):
247247 if ns .include_freethreaded :
248248 yield from in_build ("venvlaunchert.exe" , "Lib/venv/scripts/nt/" )
249249 yield from in_build ("venvwlaunchert.exe" , "Lib/venv/scripts/nt/" )
250- else :
250+ elif ( VER_MAJOR , VER_MINOR ) > ( 3 , 12 ) :
251251 yield from in_build ("venvlauncher.exe" , "Lib/venv/scripts/nt/" )
252252 yield from in_build ("venvwlauncher.exe" , "Lib/venv/scripts/nt/" )
253+ else :
254+ # Older versions of venv expected the scripts to be named 'python'
255+ # and they were renamed at this stage. We need to replicate that
256+ # when packaging older versions.
257+ yield from in_build ("venvlauncher.exe" , "Lib/venv/scripts/nt/" , "python" )
258+ yield from in_build ("venvwlauncher.exe" , "Lib/venv/scripts/nt/" , "pythonw" )
253259
254260 if ns .include_tools :
255261
@@ -652,22 +658,24 @@ def main():
652658 ns .doc_build = (Path .cwd () / ns .doc_build ).resolve ()
653659 if ns .include_cat and not ns .include_cat .is_absolute ():
654660 ns .include_cat = (Path .cwd () / ns .include_cat ).resolve ()
655- if not ns .arch :
656- # TODO: Calculate arch from files in ns.build instead
657- if sys .winver .endswith ("-arm64" ):
658- ns .arch = "arm64"
659- elif sys .winver .endswith ("-32" ):
660- ns .arch = "win32"
661- else :
662- ns .arch = "amd64"
663-
664661 if ns .zip and not ns .zip .is_absolute ():
665662 ns .zip = (Path .cwd () / ns .zip ).resolve ()
666663 if ns .catalog and not ns .catalog .is_absolute ():
667664 ns .catalog = (Path .cwd () / ns .catalog ).resolve ()
668665
669666 configure_logger (ns )
670667
668+ if not ns .arch :
669+ from .support .arch import calculate_from_build_dir
670+ ns .arch = calculate_from_build_dir (ns .build )
671+
672+ expect = f"{ VER_MAJOR } .{ VER_MINOR } .{ VER_MICRO } { VER_SUFFIX } "
673+ actual = check_patchlevel_version (ns .source )
674+ if actual and actual != expect :
675+ log_error (f"Inferred version { expect } does not match { actual } from patchlevel.h. "
676+ "You should set %PYTHONINCLUDE% or %PYTHON_HEXVERSION% before launching." )
677+ return 5
678+
671679 log_info (
672680 """OPTIONS
673681Source: {ns.source}
0 commit comments