@@ -230,7 +230,7 @@ def update_sqlite(dirs: Dirs, env: EnvMapping) -> None:
230230 sqliteversion = sqlite_info .get ("sqliteversion" , "3500400" )
231231 url = sqlite_info ["url" ].format (version = sqliteversion )
232232 sha256 = sqlite_info ["sha256" ]
233- ref_loc = f"cpe:2.3:a:sqlite:sqlite:{ version } :*:*:*:*:*:*:*"
233+ ref_loc = f"cpe:2.3:a:sqlite:sqlite:{ version } :*:*:*:*:*:*:*" # noqa: E231
234234
235235 target_dir = dirs .source / "externals" / f"sqlite-{ version } "
236236 update_props (dirs .source , r"sqlite-\d+(\.\d+)*" , f"sqlite-{ version } " )
@@ -268,7 +268,7 @@ def update_xz(dirs: Dirs, env: EnvMapping) -> None:
268268 version = xz_info ["version" ]
269269 url = xz_info ["url" ].format (version = version )
270270 sha256 = xz_info ["sha256" ]
271- ref_loc = f"cpe:2.3:a:tukaani:xz:{ version } :*:*:*:*:*:*:*"
271+ ref_loc = f"cpe:2.3:a:tukaani:xz:{ version } :*:*:*:*:*:*:*" # noqa: E231
272272
273273 target_dir = dirs .source / "externals" / f"xz-{ version } "
274274 update_props (dirs .source , r"xz-\d+(\.\d+)*" , f"xz-{ version } " )
@@ -372,7 +372,7 @@ def update_openssl(dirs: Dirs, env: EnvMapping) -> None:
372372 version = openssl_info ["version" ]
373373 url = openssl_info ["url" ].format (version = version )
374374 sha256 = openssl_info ["sha256" ]
375- ref_loc = f"cpe:2.3:a:openssl:openssl:{ version } :*:*:*:*:*:*:*"
375+ ref_loc = f"cpe:2.3:a:openssl:openssl:{ version } :*:*:*:*:*:*:*" # noqa: E231
376376
377377 is_binary = "cpython-bin-deps" in url
378378 target_dir = (
@@ -456,7 +456,9 @@ def update_openssl(dirs: Dirs, env: EnvMapping) -> None:
456456
457457 env_path = os .environ .get ("PATH" , "" )
458458 build_env = env .copy ()
459- build_env ["PATH" ] = f"{ perl_bin .parent } ;{ nasm_exe [0 ].parent } ;{ env_path } "
459+ build_env [
460+ "PATH"
461+ ] = f"{ perl_bin .parent } ;{ nasm_exe [0 ].parent } ;{ env_path } " # noqa: E231,E702
460462
461463 prefix = target_dir / "build"
462464 openssldir = prefix / "ssl"
@@ -607,7 +609,7 @@ def update_bzip2(dirs: Dirs, env: EnvMapping) -> None:
607609 version = bzip2_info ["version" ]
608610 url = bzip2_info ["url" ].format (version = version )
609611 sha256 = bzip2_info ["sha256" ]
610- ref_loc = f"cpe:2.3:a:bzip:bzip2:{ version } :*:*:*:*:*:*:*"
612+ ref_loc = f"cpe:2.3:a:bzip:bzip2:{ version } :*:*:*:*:*:*:*" # noqa: E231
611613
612614 target_dir = dirs .source / "externals" / f"bzip2-{ version } "
613615 update_props (dirs .source , r"bzip2-\d+(\.\d+)*" , f"bzip2-{ version } " )
@@ -642,7 +644,7 @@ def update_libffi(dirs: Dirs, env: EnvMapping) -> None:
642644 version = libffi_info ["version" ]
643645 url = libffi_info ["url" ].format (version = version )
644646 sha256 = libffi_info ["sha256" ]
645- ref_loc = f"cpe:2.3:a:libffi_project:libffi:{ version } :*:*:*:*:*:*:*"
647+ ref_loc = f"cpe:2.3:a:libffi_project:libffi:{ version } :*:*:*:*:*:*:*" # noqa: E231
646648
647649 target_dir = dirs .source / "externals" / f"libffi-{ version } "
648650 update_props (dirs .source , r"libffi-\d+(\.\d+)*" , f"libffi-{ version } " )
@@ -695,7 +697,7 @@ def update_zlib(dirs: Dirs, env: EnvMapping) -> None:
695697 version = zlib_info ["version" ]
696698 url = zlib_info ["url" ].format (version = version )
697699 sha256 = zlib_info ["sha256" ]
698- ref_loc = f"cpe:2.3:a:gnu:zlib:{ version } :*:*:*:*:*:*:*"
700+ ref_loc = f"cpe:2.3:a:gnu:zlib:{ version } :*:*:*:*:*:*:*" # noqa: E231
699701
700702 target_dir = dirs .source / "externals" / f"zlib-{ version } "
701703 update_props (dirs .source , r"zlib-\d+(\.\d+)*" , f"zlib-{ version } " )
@@ -773,6 +775,37 @@ def update_perl(dirs: Dirs, env: EnvMapping) -> pathlib.Path:
773775 return target_dir
774776
775777
778+ def copy_pyconfig_h (
779+ source : pathlib .Path , build_dir : pathlib .Path , dest_dir : pathlib .Path
780+ ) -> pathlib .Path :
781+ """
782+ Copy ``pyconfig.h`` into the onedir's ``Include`` directory.
783+
784+ Python <= 3.12 ships a checked-in ``PC/pyconfig.h``. Python 3.13+ replaced
785+ that with ``PC/pyconfig.h.in`` and MSBuild generates the real header into
786+ the build output directory. This mirrors the logic in CPython's
787+ ``PC/layout/main.py`` so the onedir's ``Include/`` always ends up with a
788+ ``pyconfig.h`` next to ``Python.h`` -- without it C extensions cannot
789+ locate the configuration macros and fail with
790+ ``fatal error C1083: Cannot open include file: 'pyconfig.h'``.
791+ """
792+ pc_dir = source / "PC"
793+ if (pc_dir / "pyconfig.h.in" ).is_file ():
794+ pyconfig_src = build_dir / "pyconfig.h"
795+ else :
796+ pyconfig_src = pc_dir / "pyconfig.h"
797+
798+ if not pyconfig_src .is_file ():
799+ raise RuntimeError (
800+ f"Expected pyconfig.h at { pyconfig_src } but CPython build did "
801+ "not produce it. Check that the MSBuild step ran successfully."
802+ )
803+
804+ dest = dest_dir / "pyconfig.h"
805+ shutil .copy (src = str (pyconfig_src ), dst = str (dest ))
806+ return dest
807+
808+
776809def build_python (env : EnvMapping , dirs : Dirs , logfp : IO [str ]) -> None :
777810 """
778811 Run the commands to build Python.
@@ -843,7 +876,7 @@ def build_python(env: EnvMapping, dirs: Dirs, logfp: IO[str]) -> None:
843876 "python.exe" ,
844877 "pythonw.exe" ,
845878 "python3.dll" ,
846- f"python{ env ['RELENV_PY_MAJOR_VERSION' ].replace ('.' , '' ) } .dll" ,
879+ f"python{ env ['RELENV_PY_MAJOR_VERSION' ].replace ('.' , '' )} .dll" ,
847880 "vcruntime140.dll" ,
848881 "venvlauncher.exe" ,
849882 "venvwlauncher.exe" ,
@@ -862,10 +895,7 @@ def build_python(env: EnvMapping, dirs: Dirs, logfp: IO[str]) -> None:
862895 dst = str (dirs .prefix / "Include" ),
863896 dirs_exist_ok = True ,
864897 )
865- if "3.13" not in env ["RELENV_PY_MAJOR_VERSION" ]:
866- shutil .copy (
867- src = str (dirs .source / "PC" / "pyconfig.h" ), dst = str (dirs .prefix / "Include" )
868- )
898+ copy_pyconfig_h (dirs .source , build_dir , dirs .prefix / "Include" )
869899
870900 shutil .copytree (
871901 src = str (dirs .source / "Lib" ), dst = str (dirs .prefix / "Lib" ), dirs_exist_ok = True
@@ -877,7 +907,7 @@ def build_python(env: EnvMapping, dirs: Dirs, logfp: IO[str]) -> None:
877907 src = str (build_dir / "python3.lib" ),
878908 dst = str (dirs .prefix / "libs" / "python3.lib" ),
879909 )
880- pylib = f"python{ env ['RELENV_PY_MAJOR_VERSION' ].replace ('.' , '' ) } .lib"
910+ pylib = f"python{ env ['RELENV_PY_MAJOR_VERSION' ].replace ('.' , '' )} .lib"
881911 shutil .copy (src = str (build_dir / pylib ), dst = str (dirs .prefix / "libs" / pylib ))
882912
883913
0 commit comments