Skip to content

Commit be4eb5f

Browse files
mishushakovclaude
andauthored
chore(python-sdk): migrate from Poetry to uv (#1513)
Migrates the Python SDK's packaging and CI from Poetry to [uv](https://docs.astral.sh/uv/): `pyproject.toml` is converted to PEP 621 metadata using uv's native `uv_build` backend (verified to produce a byte-equivalent wheel containing both `e2b` and `e2b_connect`), `poetry.lock` is replaced with `uv.lock`, and the `Makefile`, `package.json` scripts, `.tool-versions`, `CLAUDE.md`, and all six GitHub workflows now use `uv` (`astral-sh/setup-uv` + `uv sync`/`build`/`version`/`publish`). It also drops the now-redundant explicit sync steps (since `uv run` auto-syncs) and removes the orphaned `pydoc-markdown` dev dependency, whose only consumer was deleted long ago — trimming 58 packages from the dev lockfile. ## Usage ```sh cd packages/python-sdk uv sync # install deps (replaces `poetry install`) uv run pytest # run tests uv build # build the wheel/sdist make lint # ruff (run via `uv run`) ``` No user-facing SDK change — packaging/tooling only — so no changeset is included; the published package contents are unchanged. --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent a6b1cf4 commit be4eb5f

13 files changed

Lines changed: 1200 additions & 1985 deletions

.github/workflows/lint.yml

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -69,23 +69,17 @@ jobs:
6969
- name: Install dependencies
7070
run: pnpm install --frozen-lockfile
7171

72-
- name: Set up Python
73-
uses: actions/setup-python@v4
72+
- name: Install uv
73+
uses: astral-sh/setup-uv@v6
7474
with:
75+
version: '${{ env.TOOL_VERSION_UV }}'
7576
python-version: '${{ env.TOOL_VERSION_PYTHON }}'
76-
77-
- name: Install and configure Poetry
78-
uses: snok/install-poetry@v1
79-
with:
80-
version: '${{ env.TOOL_VERSION_POETRY }}'
81-
virtualenvs-create: true
82-
virtualenvs-in-project: true
83-
installer-parallel: true
77+
enable-cache: true
8478

8579
- name: Install Python dependencies
8680
working-directory: packages/python-sdk
8781
run: |
88-
poetry install --with dev
82+
uv sync --locked
8983
9084
- name: Run linting
9185
run: |

.github/workflows/pkg_artifacts.yml

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -80,25 +80,19 @@ jobs:
8080
name: e2b-cli
8181
path: packages/cli/*.tgz
8282

83-
- name: Set up Python
84-
uses: actions/setup-python@v4
83+
- name: Install uv
84+
uses: astral-sh/setup-uv@v6
8585
with:
86+
version: '${{ env.TOOL_VERSION_UV }}'
8687
python-version: '${{ env.TOOL_VERSION_PYTHON }}'
87-
88-
- name: Install and configure Poetry
89-
uses: snok/install-poetry@v1
90-
with:
91-
version: '${{ env.TOOL_VERSION_POETRY }}'
92-
virtualenvs-create: true
93-
virtualenvs-in-project: true
94-
installer-parallel: true
88+
enable-cache: true
9589

9690
- name: Build Python SDK
9791
working-directory: packages/python-sdk
9892
run: |
99-
BASE_VERSION=$(poetry version -s)
100-
poetry version "${BASE_VERSION}+${BRANCH_ID}"
101-
poetry build
93+
BASE_VERSION=$(uv version --short)
94+
uv version "${BASE_VERSION}+${BRANCH_ID}"
95+
uv build
10296
10397
- name: Upload Python SDK artifact
10498
uses: actions/upload-artifact@v4

.github/workflows/publish_candidates.yml

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -66,29 +66,22 @@ jobs:
6666
npm install -g npm@^11.6
6767
npm --version
6868
69-
- name: Set up Python
70-
uses: actions/setup-python@v4
69+
- name: Install uv
70+
uses: astral-sh/setup-uv@v6
7171
if: ${{ inputs.python-sdk }}
7272
with:
73+
version: '${{ env.TOOL_VERSION_UV }}'
7374
python-version: '${{ env.TOOL_VERSION_PYTHON }}'
74-
75-
- name: Install and configure Poetry
76-
uses: snok/install-poetry@v1
77-
if: ${{ inputs.python-sdk }}
78-
with:
79-
version: '${{ env.TOOL_VERSION_POETRY }}'
80-
virtualenvs-create: true
81-
virtualenvs-in-project: true
82-
installer-parallel: true
75+
enable-cache: true
8376

8477
- name: Publish Python RC
8578
if: ${{ inputs.python-sdk }}
8679
working-directory: packages/python-sdk
8780
run: |
88-
BASE_VERSION=$(poetry version -s)
89-
poetry version "${BASE_VERSION}rc${{ github.run_id }}"
90-
poetry build
91-
poetry config pypi-token.pypi ${PYPI_TOKEN} && poetry publish --skip-existing
81+
BASE_VERSION=$(uv version --short)
82+
uv version "${BASE_VERSION}rc${{ github.run_id }}"
83+
uv build
84+
uv publish --token ${PYPI_TOKEN} --check-url https://pypi.org/simple/
9285
env:
9386
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
9487

.github/workflows/publish_packages.yml

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,12 @@ jobs:
3535
uppercase: 'true'
3636
prefix: 'tool_version_'
3737

38-
- name: Set up Python
39-
uses: actions/setup-python@v4
38+
- name: Install uv
39+
uses: astral-sh/setup-uv@v6
4040
with:
41+
version: '${{ env.TOOL_VERSION_UV }}'
4142
python-version: '${{ env.TOOL_VERSION_PYTHON }}'
42-
43-
- name: Install and configure Poetry
44-
uses: snok/install-poetry@v1
45-
with:
46-
version: '${{ env.TOOL_VERSION_POETRY }}'
47-
virtualenvs-create: true
48-
virtualenvs-in-project: true
49-
installer-parallel: true
43+
enable-cache: true
5044

5145
- uses: pnpm/action-setup@v4
5246
with:

.github/workflows/python_sdk_tests.yml

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,27 +37,21 @@ jobs:
3737
uppercase: 'true'
3838
prefix: 'tool_version_'
3939

40-
- name: Set up Python
41-
uses: actions/setup-python@v4
40+
- name: Install uv
41+
uses: astral-sh/setup-uv@v6
4242
with:
43+
version: '${{ env.TOOL_VERSION_UV }}'
4344
python-version: '${{ env.TOOL_VERSION_PYTHON }}'
44-
45-
- name: Install and configure Poetry
46-
uses: snok/install-poetry@v1
47-
with:
48-
version: '${{ env.TOOL_VERSION_POETRY }}'
49-
virtualenvs-create: true
50-
virtualenvs-in-project: true
51-
installer-parallel: true
45+
enable-cache: true
5246

5347
- name: Install dependencies
54-
run: poetry install
48+
run: uv sync --locked
5549

5650
- name: Test build
57-
run: poetry build
51+
run: uv build
5852

5953
- name: Run tests
60-
run: poetry run pytest --verbose --numprocesses=4
54+
run: uv run pytest --verbose --numprocesses=4
6155
env:
6256
E2B_API_KEY: ${{ secrets.E2B_API_KEY }}
6357
E2B_DOMAIN: ${{ inputs.E2B_DOMAIN }}

.github/workflows/typecheck.yml

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -65,23 +65,17 @@ jobs:
6565
- name: Install dependencies
6666
run: pnpm install --frozen-lockfile
6767

68-
- name: Set up Python
69-
uses: actions/setup-python@v4
68+
- name: Install uv
69+
uses: astral-sh/setup-uv@v6
7070
with:
71+
version: '${{ env.TOOL_VERSION_UV }}'
7172
python-version: '${{ env.TOOL_VERSION_PYTHON }}'
72-
73-
- name: Install and configure Poetry
74-
uses: snok/install-poetry@v1
75-
with:
76-
version: '${{ env.TOOL_VERSION_POETRY }}'
77-
virtualenvs-create: true
78-
virtualenvs-in-project: true
79-
installer-parallel: true
73+
enable-cache: true
8074

8175
- name: Install Python dependencies
8276
working-directory: packages/python-sdk
8377
run: |
84-
poetry install --with dev
78+
uv sync --locked
8579
8680
- name: Run typecheck
8781
run: |

.tool-versions

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ deno 1.46.3
22
nodejs 20.19.5
33
pnpm 9.15.5
44
python 3.10
5-
poetry 2.1.1
5+
uv 0.10.0

CLAUDE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Use pnpm for node and poetry for python to install and update dependencies.
1+
Use pnpm for node and uv for python to install and update dependencies.
22
Run `pnpm run format`, `pnpm run lint` and `pnpm run typecheck` before committing changes.
33
When modifying the SDK packages, ensure equivalent changes are applied to both JS as well as sync and async Python implementations.
44
To re-generate the API client run `make codegen` in the repository root when modifying spec/.

packages/python-sdk/Makefile

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,10 @@ generate-envd:
2727

2828
generate: generate-api generate-envd generate-mcp generate-volume-api
2929

30+
# Install the code-generation toolchain into the uv env. After this, run the
31+
# generators locally with e.g. `uv run make generate-api`.
3032
init:
31-
pip install openapi-python-client datamodel-code-generator
33+
uv sync --group codegen
3234

3335
typecheck:
3436
ty check
@@ -52,10 +54,6 @@ generate-mcp:
5254
--disable-timestamp \
5355
--extra-fields forbid
5456

55-
.PHONY: setup
56-
setup:
57-
poetry install
58-
5957
.PHONY: test
60-
test: setup
61-
poetry run pytest --verbose --numprocesses=4
58+
test:
59+
uv run pytest --verbose --numprocesses=4

packages/python-sdk/package.json

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@
33
"private": true,
44
"version": "2.30.0",
55
"scripts": {
6-
"example": "poetry run python example.py",
7-
"test": "poetry run pytest -n 4 --verbose -x",
8-
"postVersion": "poetry version $(pnpm pkg get version --workspaces=false | tr -d \\\")",
9-
"postPublish": "poetry build && poetry config pypi-token.pypi ${PYPI_TOKEN} && poetry publish --skip-existing",
10-
"pretest": "poetry install",
11-
"typecheck": "poetry run make typecheck",
12-
"lint": "poetry run make lint",
13-
"format": "poetry run make format"
6+
"example": "uv run python example.py",
7+
"test": "uv run pytest -n 4 --verbose -x",
8+
"postVersion": "uv version $(pnpm pkg get version --workspaces=false | tr -d \\\")",
9+
"postPublish": "uv build && uv publish --token ${PYPI_TOKEN} --check-url https://pypi.org/simple/",
10+
"typecheck": "uv run make typecheck",
11+
"lint": "uv run make lint",
12+
"format": "uv run make format"
1413
}
1514
}

0 commit comments

Comments
 (0)