Skip to content

Commit

Permalink
Drop Python 3.7 support, ensure 3.12 support, update dependencies, an…
Browse files Browse the repository at this point in the history
…d implement asyncio.timeout (#422)
  • Loading branch information
cretz authored Nov 16, 2023
1 parent 4e0883e commit 06cfd03
Show file tree
Hide file tree
Showing 15 changed files with 407 additions and 236 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build-binaries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ jobs:
- if: ${{ !endsWith(matrix.os, '-arm') }}
uses: actions/setup-python@v4
with:
python-version: "3.11"
python-version: "3.12"
- if: ${{ matrix.os == 'ubuntu-arm' }}
uses: deadsnakes/[email protected]
with:
python-version: "3.11"
python-version: "3.12"

# Install Rust locally for non-Linux (Linux uses an internal docker
# command to build with cibuildwheel which uses rustup install defined
Expand All @@ -55,7 +55,7 @@ jobs:
# https://github.com/python-poetry/poetry/issues/7611 and
# https://github.com/python-poetry/poetry/pull/7694 are fixed
- run: python -m pip install --upgrade wheel "poetry==1.3.2" poethepoet
- run: poetry install --no-root -E opentelemetry
- run: poetry install --no-root --all-extras

# Add the source dist only for Linux x64 for now
- if: ${{ matrix.package-suffix == 'linux-amd64' }}
Expand Down
18 changes: 5 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,18 @@ jobs:
strategy:
fail-fast: true
matrix:
python: ["3.7", "3.11"]
python: ["3.8", "3.12"]
os: [ubuntu-latest, macos-latest, windows-latest, ubuntu-arm]
include:
- os: ubuntu-latest
python: "3.11"
python: "3.12"
docsTarget: true
- os: ubuntu-latest
python: "3.7"
python: "3.8"
protoCheckTarget: true
- os: ubuntu-arm
runsOn: buildjet-4vcpu-ubuntu-2204-arm
runs-on: ${{ matrix.runsOn || matrix.os }}
# For Windows there is currently a bug with Windows + pytest + warnings +
# importlib + Python < 3.12. Based on others' investigations, disabling
# bytecode fixes it.
# See https://github.com/temporalio/sdk-python/pull/346#issuecomment-1636108747
env:
PYTHONDONTWRITEBYTECODE: "${{ matrix.os == 'windows-latest' && '1' || '' }}"
steps:
- uses: actions/checkout@v2
with:
Expand All @@ -44,9 +38,7 @@ jobs:
- if: ${{ !endsWith(matrix.os, '-arm') }}
uses: actions/setup-python@v4
with:
# Due to a yet-uninvestigated change in 3.11.6 that breaks the Rust
# linker on Windows, we are pinning 3.11 to 3.11.5 here
python-version: ${{ matrix.python == '3.11' && '3.11.5' || matrix.python }}
python-version: ${{ matrix.python }}
- if: ${{ matrix.os == 'ubuntu-arm' }}
uses: deadsnakes/[email protected]
with:
Expand All @@ -55,7 +47,7 @@ jobs:
# https://github.com/python-poetry/poetry/issues/7611 and
# https://github.com/python-poetry/poetry/pull/7694 are fixed
- run: python -m pip install --upgrade wheel "poetry==1.3.2" poethepoet
- run: poetry install --no-root -E opentelemetry
- run: poetry install --no-root --all-extras
- run: poe lint
- run: poe build-develop
- run: poe test -s -o log_cli_level=DEBUG
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/run-bench.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ jobs:
working-directory: temporalio/bridge
- uses: actions/setup-python@v4
with:
python-version: "3.11"
python-version: "3.12"

# Build
- run: python -m pip install --upgrade wheel poetry poethepoet
- run: poetry install --no-root -E opentelemetry
- run: poetry install --no-root --all-extras
- run: poe build-develop-with-release

# Run a bunch of bench tests. We run multiple times since results vary.
Expand Down
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
![Temporal Python SDK](https://assets.temporal.io/w/py-banner.svg)

[![Python 3.7+](https://img.shields.io/pypi/pyversions/temporalio.svg?style=for-the-badge)](https://pypi.org/project/temporalio)
[![Python 3.8+](https://img.shields.io/pypi/pyversions/temporalio.svg?style=for-the-badge)](https://pypi.org/project/temporalio)
[![PyPI](https://img.shields.io/pypi/v/temporalio.svg?style=for-the-badge)](https://pypi.org/project/temporalio)
[![MIT](https://img.shields.io/pypi/l/temporalio.svg?style=for-the-badge)](LICENSE)

Expand Down Expand Up @@ -668,6 +668,9 @@ Some things to note about the above code:
* A timer is represented by normal `asyncio.sleep()`
* Timers are also implicitly started on any `asyncio` calls with timeouts (e.g. `asyncio.wait_for`)
* Timers are Temporal server timers, not local ones, so sub-second resolution rarely has value
* Calls that use a specific point in time, e.g. `call_at` or `timeout_at`, should be based on the current loop time
(i.e. `workflow.time()`) and not an actual point in time. This is because fixed times are translated to relative ones
by subtracting the current loop time which may not be the actual current time.

#### Conditions

Expand All @@ -683,7 +686,6 @@ of the common `asyncio` calls work as normal. Some asyncio features are disabled
* Thread related calls such as `to_thread()`, `run_coroutine_threadsafe()`, `loop.run_in_executor()`, etc
* Calls that alter the event loop such as `loop.close()`, `loop.stop()`, `loop.run_forever()`,
`loop.set_task_factory()`, etc
* Calls that use a specific time such as `loop.call_at()`
* Calls that use anything external such as networking, subprocesses, disk IO, etc

Cancellation is done the same way as `asyncio`. Specifically, a task can be requested to be cancelled but does not
Expand Down Expand Up @@ -1295,7 +1297,7 @@ users are encouraged to not use gevent in asyncio applications (including Tempor

# Development

The Python SDK is built to work with Python 3.7 and newer. It is built using
The Python SDK is built to work with Python 3.8 and newer. It is built using
[SDK Core](https://github.com/temporalio/sdk-core/) which is written in Rust.

### Building
Expand All @@ -1304,7 +1306,7 @@ The Python SDK is built to work with Python 3.7 and newer. It is built using

To build the SDK from source for use as a dependency, the following prerequisites are required:

* [Python](https://www.python.org/) >= 3.7
* [Python](https://www.python.org/) >= 3.8
* [Rust](https://www.rust-lang.org/)
* [poetry](https://github.com/python-poetry/poetry) (e.g. `python -m pip install poetry`)
* [poe](https://github.com/nat-n/poethepoet) (e.g. `python -m pip install poethepoet`)
Expand Down
2 changes: 1 addition & 1 deletion build.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def build(setup_kwargs):
path="temporalio/bridge/Cargo.toml",
binding=Binding.PyO3,
py_limited_api=True,
features=["pyo3/abi3-py37"],
features=["pyo3/abi3-py38"],
)
],
zip_safe=False,
Expand Down
Loading

0 comments on commit 06cfd03

Please sign in to comment.