From 1fa342b0859439ed671ad43f1c29ad5fa8468e12 Mon Sep 17 00:00:00 2001 From: black-sliver <59490463+black-sliver@users.noreply.github.com> Date: Mon, 25 Aug 2025 17:36:39 +0000 Subject: [PATCH] Core: add python 3.13 support (#5357) * Core: fix freeze support for py3.13+ Loading Utils now patches multiprocessing.freeze_support() Utils.freeze_support() is now deprecated * WebHost: use pony fork on py3.13 * CI: test with py3.13 --- .github/workflows/unittests.yml | 7 ++++--- Launcher.py | 2 +- Utils.py | 20 +++++++++++++------- WebHostLib/requirements.txt | 3 ++- 4 files changed, 20 insertions(+), 12 deletions(-) diff --git a/.github/workflows/unittests.yml b/.github/workflows/unittests.yml index 96219daa..90a5d70b 100644 --- a/.github/workflows/unittests.yml +++ b/.github/workflows/unittests.yml @@ -41,12 +41,13 @@ jobs: python: - {version: '3.11.2'} # Change to '3.11' around 2026-06-10 - {version: '3.12'} + - {version: '3.13'} include: - python: {version: '3.11'} # old compat os: windows-latest - - python: {version: '3.12'} # current + - python: {version: '3.13'} # current os: windows-latest - - python: {version: '3.12'} # current + - python: {version: '3.13'} # current os: macos-latest steps: @@ -74,7 +75,7 @@ jobs: os: - ubuntu-latest python: - - {version: '3.12'} # current + - {version: '3.13'} # current steps: - uses: actions/checkout@v4 diff --git a/Launcher.py b/Launcher.py index 5720012c..adc3cb96 100644 --- a/Launcher.py +++ b/Launcher.py @@ -484,7 +484,7 @@ def main(args: argparse.Namespace | dict | None = None): if __name__ == '__main__': init_logging('Launcher') - Utils.freeze_support() + multiprocessing.freeze_support() multiprocessing.set_start_method("spawn") # if launched process uses kivy, fork won't work parser = argparse.ArgumentParser( description='Archipelago Launcher', diff --git a/Utils.py b/Utils.py index 5a24bc15..e73edd71 100644 --- a/Utils.py +++ b/Utils.py @@ -940,15 +940,15 @@ class DeprecateDict(dict): def _extend_freeze_support() -> None: - """Extend multiprocessing.freeze_support() to also work on Non-Windows for spawn.""" - # upstream issue: https://github.com/python/cpython/issues/76327 + """Extend multiprocessing.freeze_support() to also work on Non-Windows and without setting spawn method first.""" + # original upstream issue: https://github.com/python/cpython/issues/76327 # code based on https://github.com/pyinstaller/pyinstaller/blob/develop/PyInstaller/hooks/rthooks/pyi_rth_multiprocessing.py#L26 import multiprocessing import multiprocessing.spawn def _freeze_support() -> None: """Minimal freeze_support. Only apply this if frozen.""" - from subprocess import _args_from_interpreter_flags + from subprocess import _args_from_interpreter_flags # noqa # Prevent `spawn` from trying to read `__main__` in from the main script multiprocessing.process.ORIGINAL_DIR = None @@ -975,17 +975,23 @@ def _extend_freeze_support() -> None: multiprocessing.spawn.spawn_main(**kwargs) sys.exit() - if not is_windows and is_frozen(): - multiprocessing.freeze_support = multiprocessing.spawn.freeze_support = _freeze_support + def _noop() -> None: + pass + + multiprocessing.freeze_support = multiprocessing.spawn.freeze_support = _freeze_support if is_frozen() else _noop def freeze_support() -> None: - """This behaves like multiprocessing.freeze_support but also works on Non-Windows.""" + """This now only calls multiprocessing.freeze_support since we are patching freeze_support on module load.""" import multiprocessing - _extend_freeze_support() + + deprecate("Use multiprocessing.freeze_support() instead") multiprocessing.freeze_support() +_extend_freeze_support() + + def visualize_regions(root_region: Region, file_name: str, *, show_entrance_names: bool = False, show_locations: bool = True, show_other_regions: bool = True, linetype_ortho: bool = True, regions_to_highlight: set[Region] | None = None) -> None: diff --git a/WebHostLib/requirements.txt b/WebHostLib/requirements.txt index 8fd6dc63..f64ed085 100644 --- a/WebHostLib/requirements.txt +++ b/WebHostLib/requirements.txt @@ -1,6 +1,7 @@ flask>=3.1.1 werkzeug>=3.1.3 -pony>=0.7.19 +pony>=0.7.19; python_version <= '3.12' +pony @ git+https://github.com/black-sliver/pony@7feb1221953b7fa4a6735466bf21a8b4d35e33ba#0.7.19; python_version >= '3.13' waitress>=3.0.2 Flask-Caching>=2.3.0 Flask-Compress>=1.17