@@ -1390,28 +1390,27 @@ The Python SDK is built to work with Python 3.9 and newer. It is built using
1390
1390
1391
1391
To build the SDK from source for use as a dependency, the following prerequisites are required:
1392
1392
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/ )
1395
1394
* [ Rust] ( https://www.rust-lang.org/ )
1396
1395
* [ 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 ` )
1399
1396
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 ` :
1402
1398
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:
1404
1404
1405
1405
``` bash
1406
1406
git clone --recursive https://github.com/temporalio/sdk-python.git
1407
1407
cd sdk-python
1408
1408
```
1409
1409
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:
1412
1411
1413
1412
``` bash
1414
- poetry install --no-root --all-extras
1413
+ uv sync --all-extras
1415
1414
```
1416
1415
1417
1416
#### Build
@@ -1422,16 +1421,11 @@ Now perform the release build:
1422
1421
environment] ( #local-sdk-development-environment ) for the quicker approach to local development).
1423
1422
1424
1423
``` bash
1425
- poetry build
1424
+ uv build
1426
1425
```
1427
1426
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
- ```
1433
1427
1434
- The ` whl ` wheel file in ` dist/ ` is now ready to use.
1428
+ The ` . whl` wheel file in ` dist/ ` is now ready to use.
1435
1429
1436
1430
#### Use
1437
1431
@@ -1487,22 +1481,15 @@ It should output:
1487
1481
1488
1482
### Local SDK development environment
1489
1483
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-project true
1497
- ```
1484
+ For local development, it is quicker to use a debug build.
1498
1485
1499
- Now perform the same steps as the "Prepare" section above by installing the prerequisites, cloning the project,
1500
- installing dependencies, and generating the protobuf code :
1486
+ Perform the same steps as the "Prepare" section above by installing the prerequisites, cloning the project, and
1487
+ installing dependencies:
1501
1488
1502
1489
``` bash
1503
1490
git clone --recursive https://github.com/temporalio/sdk-python.git
1504
1491
cd sdk-python
1505
- poetry install --no-root --all-extras
1492
+ uv sync --all-extras
1506
1493
```
1507
1494
1508
1495
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
1535
1522
#### Proto Generation and Testing
1536
1523
1537
1524
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 the protobuf 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.
1541
1528
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.
1544
1531
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:
1546
1533
``` shell
1547
1534
docker build -f scripts/_proto/Dockerfile .
1548
1535
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
1552
1539
### Style
1553
1540
1554
1541
* 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
1556
1543
* In tests and example code, can import individual classes/functions to make it more readable. Can also do this for
1557
1544
rarely in library code for some Python common items (e.g. ` dataclass ` or ` partial ` ), but not allowed to do this for
1558
1545
any ` temporalio ` packages (except ` temporalio.types ` ) or any classes/functions that aren't clear when unqualified.
0 commit comments