Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit49ca10e

Browse files
authored
uv + maturin migration (temporalio#768)
1 parentff480f0 commit49ca10e

File tree

15 files changed

+1712
-2205
lines changed

15 files changed

+1712
-2205
lines changed

‎.github/workflows/build-binaries.yml‎

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -43,24 +43,31 @@ jobs:
4343
uses:Swatinem/rust-cache@v2
4444
with:
4545
workspaces:temporalio/bridge -> target
46-
47-
# Prepare
48-
# Using fixed Poetry version until
49-
# https://github.com/python-poetry/poetry/issues/7611 and
50-
# https://github.com/python-poetry/poetry/pull/7694 are fixed
51-
-run:python -m pip install --upgrade wheel "poetry==1.3.2" poethepoet
52-
-run:poetry install --no-root --all-extras
46+
-uses:astral-sh/setup-uv@v5
47+
-run:uv sync --all-extras
5348

5449
# Add the source dist only for Linux x64 for now
5550
-if:${{ matrix.package-suffix == 'linux-amd64' }}
56-
run:poetry build --formatsdist
51+
run:uv build --sdist
5752

58-
# Build and fix the wheel
59-
-run:poetry run cibuildwheel --output-dir dist
60-
-run:poe fix-wheel
53+
# Build the wheel
54+
-run:uv run cibuildwheel --output-dir dist
6155

62-
# Simple test
63-
-run:poe test-dist-single
56+
# Install the wheel in a new venv and run a test
57+
-name:Test wheel
58+
shell:bash
59+
run:|
60+
mkdir __test_wheel__
61+
cd __test_wheel__
62+
cp -r ../tests .
63+
python -m venv .venv
64+
bindir=bin
65+
if [ "$RUNNER_OS" = "Windows" ]; then
66+
bindir=Scripts
67+
fi
68+
./.venv/$bindir/pip install 'protobuf>=3.20' 'types-protobuf>=3.20' 'typing-extensions<5,>=4.2.0' pytest pytest_asyncio grpcio pydantic opentelemetry-api opentelemetry-sdk python-dateutil
69+
./.venv/$bindir/pip install --no-index --find-links=../dist temporalio
70+
./.venv/$bindir/python -m pytest -s -k test_workflow_hello
6471
6572
# Upload dist
6673
-uses:actions/upload-artifact@v4

‎.github/workflows/ci.yml‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,9 @@ jobs:
4646
# TODO(cretz): Can upgrade proto when https://github.com/arduino/setup-protoc/issues/99 fixed
4747
version:"23.x"
4848
repo-token:${{ secrets.GITHUB_TOKEN }}
49-
-run:python -m pip install --upgrade wheel poetry poethepoet
50-
-run:poetry install --no-root --all-extras
49+
-uses:astral-sh/setup-uv@v5
50+
-run:uv tool install poethepoet
51+
-run:uv sync --all-extras
5152
-run:poe bridge-lint
5253
if:${{ matrix.clippyLinter }}
5354
-run:poe lint
@@ -82,8 +83,9 @@ jobs:
8283
env:
8384
TEMPORAL_TEST_PROTO3:1
8485
run:|
85-
poetry add --python 3.9 "protobuf<4"
86-
poetry install --no-root --all-extras
86+
uv add --python 3.9 "protobuf<4"
87+
uv sync --all-extras
88+
poe build-develop
8789
poe gen-protos
8890
poe format
8991
[[ -z $(git status --porcelain temporalio) ]] || (git diff temporalio; echo "Protos changed"; exit 1)
@@ -107,8 +109,9 @@ jobs:
107109
108110
# Runs the sdk features repo tests with this repo's current SDK code
109111
features-tests:
110-
uses:temporalio/features/.github/workflows/python.yaml@main
112+
uses:temporalio/features/.github/workflows/python.yaml@uv
111113
with:
112114
python-repo-path:${{github.event.pull_request.head.repo.full_name}}
113115
version:${{github.event.pull_request.head.ref}}
114116
version-is-repo-ref:true
117+
features-repo-ref:uv

‎.github/workflows/run-bench.yml‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,10 @@ jobs:
4444
version:"23.x"
4545
repo-token:${{ secrets.GITHUB_TOKEN }}
4646

47+
-uses:astral-sh/setup-uv@v5
4748
# Build
48-
-run:python -m pipinstall --upgrade wheel poetry poethepoet
49-
-run:poetry install --no-root --all-extras
49+
-run:uv toolinstall poethepoet
50+
-run:uv sync --all-extras
5051
-run:poe build-develop-with-release
5152

5253
# Run a bunch of bench tests. We run multiple times since results vary.

‎README.md‎

Lines changed: 22 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1390,28 +1390,27 @@ The Python SDK is built to work with Python 3.9 and newer. It is built using
13901390

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

1393-
*[Python](https://www.python.org/) >= 3.9
1394-
* Make sure the latest version of`pip` is in use
1393+
*[uv](https://docs.astral.sh/uv/)
13951394
*[Rust](https://www.rust-lang.org/)
13961395
*[Protobuf Compiler](https://protobuf.dev/)
1397-
*[poetry](https://github.com/python-poetry/poetry) (e.g.`python -m pip install poetry`)
1398-
*[poe](https://github.com/nat-n/poethepoet) (e.g.`python -m pip install poethepoet`)
13991396

1400-
macOS note: If errors are encountered, it may be better to install Python and Rust as recommended from their websites
1401-
instead of via`brew`.
1397+
Use`uv` to install`poe`:
14021398

1403-
With the prerequisites installed, first clone the SDK repository recursively:
1399+
```bash
1400+
uv tool install poethepoet
1401+
```
1402+
1403+
Now clone the SDK repository recursively:
14041404

14051405
```bash
14061406
git clone --recursive https://github.com/temporalio/sdk-python.git
14071407
cd sdk-python
14081408
```
14091409

1410-
Use`poetry` to install the dependencies with`--no-root` to not install this package (because we still need to build
1411-
it):
1410+
Install the dependencies:
14121411

14131412
```bash
1414-
poetry install --no-root --all-extras
1413+
uv sync --all-extras
14151414
```
14161415

14171416
####Build
@@ -1422,16 +1421,11 @@ Now perform the release build:
14221421
environment](#local-sdk-development-environment) for the quicker approach to local development).
14231422

14241423
```bash
1425-
poetry build
1424+
uv build
14261425
```
14271426

1428-
The compiled wheel doesn't have the exact right tags yet for use, so run this script to fix it:
1429-
1430-
```bash
1431-
poe fix-wheel
1432-
```
14331427

1434-
The`whl` wheel file in`dist/` is now ready to use.
1428+
The`.whl` wheel file in`dist/` is now ready to use.
14351429

14361430
####Use
14371431

@@ -1487,22 +1481,15 @@ It should output:
14871481

14881482
###Local SDK development environment
14891483

1490-
For local development, it is often quicker to use debug builds and a local virtual environment.
1491-
1492-
While not required, it often helps IDEs if we put the virtual environment`.venv` directory in the project itself. This
1493-
can be configured system-wide via:
1494-
1495-
```bash
1496-
poetry config virtualenvs.in-projecttrue
1497-
```
1484+
For local development, it is quicker to use a debug build.
14981485

1499-
Now performthe same steps as the "Prepare" section above by installing the prerequisites, cloning the project,
1500-
installing dependencies, and generating the protobuf code:
1486+
Performthe same steps as the "Prepare" section above by installing the prerequisites, cloning the project, and
1487+
installing dependencies:
15011488

15021489
```bash
15031490
git clone --recursive https://github.com/temporalio/sdk-python.git
15041491
cd sdk-python
1505-
poetry install --no-root --all-extras
1492+
uv sync --all-extras
15061493
```
15071494

15081495
Now compile the Rust extension in develop mode which is quicker than release mode:
@@ -1535,14 +1522,14 @@ poe test -s --log-cli-level=DEBUG -k test_sync_activity_thread_cancel_caught
15351522
####Proto Generation and Testing
15361523

15371524
To allow for backwards compatibility, protobuf code is generated on the 3.x series of the protobuf library. To generate
1538-
protobuf code, you must be on Python <= 3.10, and then run`poetry add "protobuf<4"` +
1539-
`poetry install --no-root --all-extras`. Then theprotobuf files can be generated via`poe gen-protos`. Tests can be run
1540-
for protobuf version 3 by setting the`TEMPORAL_TEST_PROTO3` env var to`1` prior to running tests.
1525+
protobuf code, you must be on Python <= 3.10, and then run`uv add "protobuf<4"` +`uv sync --all-extras`. Then the
1526+
protobuf files can be generated via`poe gen-protos`. Tests can be run for protobuf version 3 by setting the
1527+
`TEMPORAL_TEST_PROTO3` env var to`1` prior to running tests.
15411528

1542-
Do not commit`poetry.lock` or`pyproject.toml` changes. To go back from this downgrade, restore both of those files
1543-
and run`poetry install --no-root --all-extras`. Make sure you`poe format` the results.
1529+
Do not commit`uv.lock` or`pyproject.toml` changes. To go back from this downgrade, restore both of those files and run
1530+
`uv sync --all-extras`. Make sure you`poe format` the results.
15441531

1545-
For a less system-intrusive approach, you can (note this approach[may have a bug](https://github.com/temporalio/sdk-python/issues/543)):
1532+
For a less system-intrusive approach, you can:
15461533
```shell
15471534
docker build -f scripts/_proto/Dockerfile.
15481535
docker run --rm -v"${PWD}/temporalio/api:/api_new" -v"${PWD}/temporalio/bridge/proto:/bridge_new"<just built image sha>
@@ -1552,7 +1539,7 @@ poe format
15521539
###Style
15531540

15541541
* Mostly[Google Style Guide](https://google.github.io/styleguide/pyguide.html). Notable exceptions:
1555-
* We use[Black](https://github.com/psf/black) for formatting, so that takes precedence
1542+
* We use[ruff](https://docs.astral.sh/ruff/) for formatting, so that takes precedence
15561543
* In tests and example code, can import individual classes/functions to make it more readable. Can also do this for
15571544
rarely in library code for some Python common items (e.g.`dataclass` or`partial`), but not allowed to do this for
15581545
any`temporalio` packages (except`temporalio.types`) or any classes/functions that aren't clear when unqualified.

‎build.py‎

Lines changed: 0 additions & 28 deletions
This file was deleted.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp