Skip to content

Commit 9c80e2c

Browse files
committed
feat: move from poetry to uv
1 parent 3bde027 commit 9c80e2c

File tree

18 files changed

+4226
-6520
lines changed

18 files changed

+4226
-6520
lines changed

.devcontainer/Dockerfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
ARG VARIANT=3.13
22
FROM mcr.microsoft.com/devcontainers/python:${VARIANT}
33

4-
RUN pip3 install poetry pre-commit
5-
RUN poetry config virtualenvs.in-project true
4+
RUN pip3 install uv pre-commit

.github/workflows/codeflash.yaml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,16 @@ jobs:
2626
- uses: actions/checkout@v4
2727
with:
2828
fetch-depth: 0
29+
- name: Install uv
30+
uses: astral-sh/setup-uv@v5
31+
with:
32+
enable-cache: true
33+
cache-dependency-glob: "uv.lock"
2934
- name: Set up Python
3035
uses: actions/setup-python@v5
3136
with:
3237
python-version: "3.11"
3338
- name: Install Project Dependencies
34-
run: |
35-
python -m pip install --upgrade pip
36-
pip install poetry
37-
poetry install --all-extras
39+
run: uv sync --all-extras
3840
- name: Run Codeflash to optimize code
39-
run: |
40-
poetry env use python
41-
poetry run codeflash --benchmark --benchmarks-root tests/benchmarks
41+
run: uvx codeflash --benchmark --benchmarks-root tests/benchmarks

.github/workflows/e2e-tests.yml

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,27 +30,26 @@ jobs:
3030
cd e2e
3131
bunx playwright install --with-deps
3232
33+
- name: Install uv
34+
uses: astral-sh/setup-uv@v5
35+
with:
36+
enable-cache: true
37+
cache-dependency-glob: "uv.lock"
38+
3339
- name: Setup Python
3440
uses: actions/setup-python@v5
3541
with:
3642
python-version: "3.12"
3743

38-
- name: Install Poetry
39-
uses: snok/install-poetry@v1
40-
with:
41-
version: latest
42-
virtualenvs-create: true
43-
virtualenvs-in-project: true
44-
4544
- name: Install Python dependencies
4645
run: |
47-
poetry install --extras cli
48-
poetry run pip install graphql-core==3.3.0a9
46+
uv sync --extra cli
47+
uv pip install graphql-core==3.3.0a9
4948
5049
- name: Start Strawberry server
5150
run: |
5251
cd e2e
53-
poetry run strawberry dev app:schema --port 8000 &
52+
uv run strawberry dev app:schema --port 8000 &
5453
echo $! > server.pid
5554
sleep 5 # Wait for server to start
5655

.github/workflows/federation-compatibility.yml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ on:
1313
- "strawberry/federation/**"
1414
- "strawberry/printer/**"
1515
- "pyproject.toml"
16-
- "poetry.lock"
16+
- "uv.lock"
1717
- ".github/workflows/federation-compatibility.yml"
1818

1919
jobs:
@@ -24,17 +24,19 @@ jobs:
2424
steps:
2525
- uses: actions/checkout@v3
2626

27-
- run: pipx install poetry
27+
- name: Install uv
28+
uses: astral-sh/setup-uv@v5
29+
with:
30+
enable-cache: true
31+
cache-dependency-glob: "uv.lock"
2832
- uses: actions/setup-python@v4
2933
id: setup-python
3034
with:
3135
python-version: "3.12"
32-
cache: "poetry"
33-
- run: poetry env use python3.12
34-
- run: poetry install
36+
- run: uv sync
3537

3638
- name: export schema
37-
run: poetry run strawberry export-schema schema:schema > schema.graphql
39+
run: uv run strawberry export-schema schema:schema > schema.graphql
3840
working-directory: federation-compatibility
3941

4042
- uses: apollographql/federation-subgraph-compatibility@v2

.github/workflows/pre-release-pr.yml

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,13 @@ jobs:
1212
- uses: actions/checkout@v2
1313
with:
1414
ref: ${{ github.event.client_payload.pull_request.head.sha }}
15+
- name: Install uv
16+
uses: astral-sh/setup-uv@v5
1517
- name: Set up Python
16-
uses: actions/setup-python@v4
17-
with:
18-
python-version: "3.10"
18+
run: uv python install 3.12
1919
- name: Install deps
2020
run: |
21-
python -m pip install pip --upgrade
22-
pip install poetry
23-
pip install githubrelease
24-
pip install autopub
25-
pip install httpx
21+
uv pip install --system githubrelease autopub httpx
2622
- name: Check if release exists
2723
id: check_release
2824
run: echo "::set-output name=release::$(autopub check)"
@@ -57,13 +53,16 @@ jobs:
5753
id: release
5854
env:
5955
GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }}
60-
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }}
56+
UV_PUBLISH_TOKEN: ${{ secrets.PYPI_TOKEN }}
6157
run: |
6258
autopub prepare
63-
poetry version $(poetry version -s).dev.$(date '+%s')
64-
poetry build
65-
poetry publish --username __token__
66-
echo "::set-output name=version::$(poetry version -s)"
59+
# Get current version and append dev timestamp
60+
CURRENT_VERSION=$(grep -m1 'version = ' pyproject.toml | cut -d'"' -f2)
61+
DEV_VERSION="${CURRENT_VERSION}.dev.$(date '+%s')"
62+
sed -i "s/version = \"${CURRENT_VERSION}\"/version = \"${DEV_VERSION}\"/" pyproject.toml
63+
uv build
64+
uv publish
65+
echo "::set-output name=version::${DEV_VERSION}"
6766
- name: Create or update comment
6867
uses: peter-evans/create-or-update-comment@v1
6968
if: steps.check_release.outputs.release == ''
@@ -79,6 +78,6 @@ jobs:
7978
You can try it by doing:
8079
8180
```shell
82-
poetry add strawberry-graphql==${{ steps.release.outputs.version }}
81+
uv add strawberry-graphql==${{ steps.release.outputs.version }}
8382
```
8483
edit-mode: replace

.github/workflows/release.yml

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,13 @@ jobs:
3535
- uses: actions/checkout@v2
3636
with:
3737
persist-credentials: false
38+
- name: Install uv
39+
uses: astral-sh/setup-uv@v5
3840
- name: Set up Python
39-
uses: actions/setup-python@v4
40-
with:
41-
python-version: "3.10"
41+
run: uv python install 3.12
4242
- name: Install deps
4343
run: |
44-
python -m pip install pip --upgrade
45-
pip install poetry
46-
pip install githubrelease
47-
pip install autopub
48-
pip install httpx
44+
uv pip install --system githubrelease autopub httpx
4945
- name: Check if we should release
5046
id: check_release
5147
run: |
@@ -55,14 +51,14 @@ jobs:
5551
if: steps.check_release.outputs.release == ''
5652
env:
5753
GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }}
58-
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }}
54+
UV_PUBLISH_TOKEN: ${{ secrets.PYPI_TOKEN }}
5955
run: |
6056
git remote set-url origin https://${{ secrets.BOT_TOKEN }}@github.com/${{ github.repository }}
6157
autopub prepare
62-
poetry build
58+
uv build
6359
autopub commit
6460
autopub githubrelease
65-
poetry publish --username __token__
61+
uv publish
6662
- name: Get project version
6763
id: get-version
6864
shell: python
@@ -97,11 +93,10 @@ jobs:
9793
needs: [release-file-check, get-contributor-info, release]
9894
if: ${{ needs.release-file-check.outputs.status == 'OK' }}
9995
steps:
100-
- uses: actions/setup-python@v4
101-
with:
102-
python-version: "3.10"
96+
- name: Install uv
97+
uses: astral-sh/setup-uv@v5
10398
- name: Install dependencies
104-
run: pip install httpx
99+
run: uv pip install --system httpx
105100
- name: Update release on GitHub
106101
shell: python
107102
run: |
@@ -176,11 +171,10 @@ jobs:
176171
if: ${{ needs.release-file-check.outputs.status == 'OK' }}
177172

178173
steps:
179-
- uses: actions/setup-python@v4
180-
with:
181-
python-version: "3.10"
174+
- name: Install uv
175+
uses: astral-sh/setup-uv@v5
182176
- name: Install dependencies
183-
run: pip install tweepy==4.14.0
177+
run: uv pip install --system tweepy==4.14.0
184178
- name: Send tweet
185179
shell: python
186180
run: |

.github/workflows/test.yml

Lines changed: 36 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ on:
1414
- "tests/**"
1515
- "noxfile.py"
1616
- "pyproject.toml"
17-
- "poetry.lock"
17+
- "uv.lock"
1818
- ".github/workflows/test.yml"
1919

2020
jobs:
@@ -26,15 +26,13 @@ jobs:
2626
steps:
2727
- uses: actions/checkout@v4
2828
- name: Install uv
29-
uses: astral-sh/setup-uv@v3
30-
- run: uv venv
31-
- run: uv pip install poetry nox nox-poetry
29+
uses: astral-sh/setup-uv@v5
30+
- run: uv sync
3231
- id: set-matrix
3332
shell: bash
3433
run: |
35-
. .venv/bin/activate
3634
echo sessions=$(
37-
nox --json -t tests -l |
35+
uv run nox --json -t tests -l |
3836
jq 'map(
3937
{
4038
session,
@@ -54,6 +52,11 @@ jobs:
5452

5553
steps:
5654
- uses: actions/checkout@v4
55+
- name: Install uv
56+
uses: astral-sh/setup-uv@v5
57+
with:
58+
enable-cache: true
59+
cache-dependency-glob: "uv.lock"
5760
- uses: actions/setup-python@v5
5861
with:
5962
python-version: |
@@ -63,8 +66,8 @@ jobs:
6366
3.13
6467
3.14
6568
66-
- run: pip install poetry nox nox-poetry uv
67-
- run: nox -r -t tests -s "${{ matrix.session.session }}"
69+
- run: uv sync
70+
- run: uv run nox -r -t tests -s "${{ matrix.session.session }}"
6871
- uses: actions/upload-artifact@v4
6972
if: ${{ always() }}
7073
with:
@@ -96,73 +99,76 @@ jobs:
9699

97100
steps:
98101
- uses: actions/checkout@v4
99-
- run: pipx install poetry
102+
- name: Install uv
103+
uses: astral-sh/setup-uv@v5
104+
with:
105+
enable-cache: true
106+
cache-dependency-glob: "uv.lock"
100107
- uses: actions/setup-python@v5
101108
id: setup-python
102109
with:
103110
python-version: "3.12"
104111
architecture: x64
105-
cache: "poetry"
106112

107-
- run: poetry env use 3.12
108-
- run: poetry install
109-
if: steps.setup-python.outputs.cache-hit != 'true'
113+
- run: uv sync
110114

111115
- name: Run benchmarks
112116
uses: CodSpeedHQ/action@v4
113117
with:
114118
mode: simulation
115-
run: poetry run pytest tests/benchmarks --codspeed -p no:codeflash-benchmark
119+
run: uv run pytest tests/benchmarks --codspeed -p no:codeflash-benchmark
116120

117121
lint:
118122
name: ✨ Lint
119123
runs-on: ubuntu-latest
120124

121125
steps:
122126
- uses: actions/checkout@v4
123-
- run: pipx install poetry
124-
- run: pipx install coverage
127+
- name: Install uv
128+
uses: astral-sh/setup-uv@v5
129+
with:
130+
enable-cache: true
131+
cache-dependency-glob: "uv.lock"
125132
- uses: actions/setup-python@v5
126133
id: setup-python
127134
with:
128135
python-version: "3.12"
129-
cache: "poetry"
130136

131-
- run: poetry install --with integrations
132-
if: steps.setup-python.outputs.cache-hit != 'true'
137+
- run: uv sync
133138

134139
- run: |
135-
mkdir .mypy_cache
140+
mkdir -p .mypy_cache
136141
137-
poetry run mypy --install-types --non-interactive --cache-dir=.mypy_cache/ --config-file mypy.ini
142+
uv run mypy --install-types --non-interactive --cache-dir=.mypy_cache/ --config-file mypy.ini
138143
139144
unit-tests-on-windows:
140145
name: 🪟 Tests on Windows
141146
runs-on: windows-latest
142147

143148
steps:
144149
- uses: actions/checkout@v4
145-
- run: pipx install poetry
146-
- run: pipx install coverage
150+
- name: Install uv
151+
uses: astral-sh/setup-uv@v5
152+
with:
153+
enable-cache: true
154+
cache-dependency-glob: "uv.lock"
147155
- uses: actions/setup-python@v5
148156
id: setup-python
149157
with:
150158
python-version: "3.11"
151-
cache: "poetry"
152159

153-
- run: poetry install --with integrations
154-
if: steps.setup-python.outputs.cache-hit != 'true'
160+
- run: uv sync
155161
# Since we are running all the integrations at once, we can't use
156162
# pydantic v2. It is not compatible with starlette yet
157-
- run: poetry run pip install pydantic==1.10
163+
- run: uv pip install pydantic==1.10
158164

159-
# we use poetry directly instead of nox since we want to
165+
# we use uv directly instead of nox since we want to
160166
# test all integrations at once on windows
161167
# but we want to exclude tests/mypy since we are using an old version of pydantic
162168
- run: |
163-
poetry run pytest --cov=. --cov-append --cov-report=xml -n auto --showlocals --ignore tests/mypy -vv
169+
uv run pytest --cov=. --cov-append --cov-report=xml -n auto --showlocals --ignore tests/mypy -vv
164170
- name: coverage xml
165-
run: coverage xml -i
171+
run: uv run coverage xml -i
166172
if: ${{ always() }}
167173

168174
- uses: codecov/codecov-action@v4

.gitpod.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
tasks:
22
- before: |
3-
curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python -
4-
source $HOME/.poetry/env
5-
pip install pre-commit
3+
pip install uv pre-commit
64
init: |
7-
poetry install
5+
uv sync
86
pre-commit install --install-hooks

0 commit comments

Comments
 (0)