From 07d3567c607704139e5ee86cf27a3cc615cfe4f4 Mon Sep 17 00:00:00 2001 From: Sergei Ozeranskii Date: Fri, 24 Jan 2025 22:13:56 +0100 Subject: [PATCH] chore: remove Python < 3.9 support (#728) (#730) * chore: remove Python < 3.9 logic and update dependencies (#728) - Bump the minimum supported Python version from 3.8 to 3.9 - Remove macOS-specific code for Python < 3.8 - Update references in README, build.py, and poetry.lock accordingly Closes #728 * rollback poetry.lock file * fixed code formatting --- README.md | 2 +- build.py | 2 +- pyproject.toml | 2 +- tests/conftest.py | 6 ------ tests/worker/test_replayer.py | 40 ++++++++++++++++++++++------------- 5 files changed, 28 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index d04e2b87..2b28d1e8 100644 --- a/README.md +++ b/README.md @@ -1373,7 +1373,7 @@ users are encouraged to not use gevent in asyncio applications (including Tempor # Development -The Python SDK is built to work with Python 3.8 and newer. It is built using +The Python SDK is built to work with Python 3.9 and newer. It is built using [SDK Core](https://github.com/temporalio/sdk-core/) which is written in Rust. ### Building diff --git a/build.py b/build.py index de177735..f0b14871 100644 --- a/build.py +++ b/build.py @@ -16,7 +16,7 @@ def build(setup_kwargs): path="temporalio/bridge/Cargo.toml", binding=Binding.PyO3, py_limited_api=True, - features=["pyo3/abi3-py38"], + features=["pyo3/abi3-py39"], ) ], zip_safe=False, diff --git a/pyproject.toml b/pyproject.toml index a8c0d336..ee3b6cec 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -214,7 +214,7 @@ exclude = [ ] [tool.ruff] -target-version = "py38" +target-version = "py39" [build-system] build-backend = "poetry.core.masonry.api" diff --git a/tests/conftest.py b/tests/conftest.py index 378dc753..1c8bbf9d 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -39,12 +39,6 @@ from temporalio.testing import WorkflowEnvironment from tests.helpers.worker import ExternalPythonWorker, ExternalWorker -# Due to https://github.com/python/cpython/issues/77906, multiprocessing on -# macOS starting with Python 3.8 has changed from "fork" to "spawn". For -# pre-3.8, we are changing it for them. -if sys.version_info < (3, 8) and sys.platform.startswith("darwin"): - multiprocessing.set_start_method("spawn", True) - def pytest_addoption(parser): parser.addoption( diff --git a/tests/worker/test_replayer.py b/tests/worker/test_replayer.py index 390e7d79..b55e251f 100644 --- a/tests/worker/test_replayer.py +++ b/tests/worker/test_replayer.py @@ -171,9 +171,11 @@ async def test_replayer_workflow_nondeterministic(client: Client) -> None: async def test_replayer_workflow_nondeterministic_json() -> None: - with Path(__file__).with_name("test_replayer_nondeterministic_history.json").open( - "r" - ) as f: + with ( + Path(__file__) + .with_name("test_replayer_nondeterministic_history.json") + .open("r") as f + ): history_json = f.read() with pytest.raises(workflow.NondeterminismError): await Replayer(workflows=[SayHelloWorkflow]).replay_workflow( @@ -184,9 +186,11 @@ async def test_replayer_workflow_nondeterministic_json() -> None: async def test_replayer_multiple_histories_fail_fast() -> None: with Path(__file__).with_name("test_replayer_complete_history.json").open("r") as f: history_json = f.read() - with Path(__file__).with_name("test_replayer_nondeterministic_history.json").open( - "r" - ) as f: + with ( + Path(__file__) + .with_name("test_replayer_nondeterministic_history.json") + .open("r") as f + ): history_json_bad = f.read() callcount = 0 @@ -210,9 +214,11 @@ async def histories(): async def test_replayer_multiple_histories_fail_slow() -> None: with Path(__file__).with_name("test_replayer_complete_history.json").open("r") as f: history_json = f.read() - with Path(__file__).with_name("test_replayer_nondeterministic_history.json").open( - "r" - ) as f: + with ( + Path(__file__) + .with_name("test_replayer_nondeterministic_history.json") + .open("r") as f + ): history_json_bad = f.read() callcount = 0 @@ -389,9 +395,11 @@ async def test_replayer_command_reordering_backward_compatibility() -> None: to [UpdateAccepted, CompleteWorkflowExecution], and events 5 and 6 can be applied to the corresponding state machines. """ - with Path(__file__).with_name( - "test_replayer_command_reordering_backward_compatibility.json" - ).open() as f: + with ( + Path(__file__) + .with_name("test_replayer_command_reordering_backward_compatibility.json") + .open() as f + ): history = f.read() await Replayer(workflows=[UpdateCompletionAfterWorkflowReturn]).replay_workflow( WorkflowHistory.from_json("fake", history) @@ -475,9 +483,11 @@ async def test_replayer_async_ordering() -> None: async def test_replayer_alternate_async_ordering() -> None: - with Path(__file__).with_name( - "test_replayer_event_tracing_alternate.json" - ).open() as f: + with ( + Path(__file__) + .with_name("test_replayer_event_tracing_alternate.json") + .open() as f + ): history = f.read() await Replayer( workflows=[ActivityAndSignalsWhileWorkflowDown],