From 290070cafbb057f5f63b04d740c1f8cf15e100a2 Mon Sep 17 00:00:00 2001 From: Igor Apresov Date: Mon, 27 Jul 2026 16:52:39 +0700 Subject: [PATCH] fix: initialize multiprocessing in frozen tools --- manifests/rlm-tools-bsl.json | 2 +- tests/test_python_builder.py | 15 +++++++++++++++ tests/test_repository_contract.py | 2 +- toolchain/builders/python_pyinstaller.py | 2 ++ 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/manifests/rlm-tools-bsl.json b/manifests/rlm-tools-bsl.json index a55d2d0..8f9cef2 100644 --- a/manifests/rlm-tools-bsl.json +++ b/manifests/rlm-tools-bsl.json @@ -2,7 +2,7 @@ "schemaVersion": 3, "name": "rlm-tools-bsl", "version": "1.29.1", - "buildRevision": 1, + "buildRevision": 2, "source": { "kind": "release", "repository": "https://github.com/Dach-Coin/rlm-tools-bsl", diff --git a/tests/test_python_builder.py b/tests/test_python_builder.py index 45ad182..99bc56f 100644 --- a/tests/test_python_builder.py +++ b/tests/test_python_builder.py @@ -10,12 +10,27 @@ build_python_pyinstaller, parse_uv_version, verify_builder_identity, + write_entrypoint_stub, ) from toolchain.manifest import load_manifest from toolchain.source import PreparedSource class PythonBuilderTests(unittest.TestCase): + def test_frozen_entrypoint_dispatches_multiprocessing_before_cli_parsing(self) -> None: + root = Path(self.enterContext(tempfile.TemporaryDirectory())) + stub = root / "entrypoint.py" + + write_entrypoint_stub(stub, "rlm_tools_bsl.server", "main") + + source = stub.read_text(encoding="utf-8") + self.assertIn("import multiprocessing", source) + self.assertIn("multiprocessing.freeze_support()", source) + self.assertLess( + source.index("multiprocessing.freeze_support()"), + source.index("sys.exit(main())"), + ) + def test_parses_uv_platform_metadata_and_checks_exact_identity(self) -> None: self.assertEqual( parse_uv_version("uv 0.11.29 (901092ee1 aarch64-apple-darwin)"), diff --git a/tests/test_repository_contract.py b/tests/test_repository_contract.py index 9a1bdfb..fa2edb5 100644 --- a/tests/test_repository_contract.py +++ b/tests/test_repository_contract.py @@ -26,7 +26,7 @@ def test_checked_in_tools_have_independent_release_identities(self) -> None: "release", "v1.29.1", "8bc6e9fc83b522f9a79eab3193eb13fc2cecb8ed", - "rlm-tools-bsl-v1.29.1-build.1", + "rlm-tools-bsl-v1.29.1-build.2", ), "bsl-analyzer": ( "release", diff --git a/toolchain/builders/python_pyinstaller.py b/toolchain/builders/python_pyinstaller.py index a1f27ca..6a666f3 100644 --- a/toolchain/builders/python_pyinstaller.py +++ b/toolchain/builders/python_pyinstaller.py @@ -96,6 +96,7 @@ def write_entrypoint_stub(path: Path, module: str, attr: str) -> None: "\n".join( [ "import importlib", + "import multiprocessing", "import sys", "", f"MODULE = {module!r}", @@ -108,6 +109,7 @@ def write_entrypoint_stub(path: Path, module: str, attr: str) -> None: " return obj()", "", "if __name__ == '__main__':", + " multiprocessing.freeze_support()", " sys.exit(main())", "", ]