Skip to content

Commit 4cf7766

Browse files
adhami3310masenf
andauthored
migrate from poetry to uv (#4952)
* migrate from poetry to uv * woops * maybe * no python3-uv * one more poetry in contributing Co-authored-by: Masen Furer <[email protected]> * use astral install sh * performance tests are special * use 3.12.8 * use uv with absolute path in wsl * link mode copy --------- Co-authored-by: Masen Furer <[email protected]>
1 parent 06c7ba4 commit 4cf7766

17 files changed

+2387
-3307
lines changed

.devcontainer/devcontainer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"image": "mcr.microsoft.com/devcontainers/python:1-3.11-bookworm",
3-
"postCreateCommand": "/bin/bash -c 'python -m pip install poetry && python -m poetry install & git clone https://github.com/reflex-dev/reflex-examples; wait'",
3+
"postCreateCommand": "/bin/bash -c 'python -m pip install uv && python -m uv sync & git clone https://github.com/reflex-dev/reflex-examples; wait'",
44
"forwardPorts": [3000, 8000],
55
"portsAttributes": {
66
"3000": {
Lines changed: 23 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,95 +1,58 @@
11
# Entry conditions:
22
# - `setup/checkout` has already happened
33
# - working dir is the root directory of your project (e.g. `reflex/`).
4-
# - You have a `poetry.lock` file in the root directory of your project
4+
# - You have a `uv.lock` file in the root directory of your project
55
# - You have a `pyproject.toml` file in the root directory of your project
66
#
77
# Exit conditions:
88
# - Python of version `python-version` is ready to be invoked as `python`.
9-
# - Poetry of version `poetry-version` is ready to be invoked as `poetry`.
10-
# - If `run-poetry-install` is true, deps as defined in `pyproject.toml` will have been installed into the venv at `create-venv-at-path`.
9+
# - Uv of version `uv-version` is ready to be invoked as `uv`.
10+
# - If `run-uv-sync` is true, deps as defined in `pyproject.toml` will have been installed into the venv at `create-venv-at-path`.
1111

1212
name: 'Setup Reflex build environment'
13-
description: 'Sets up Python, install poetry (cached), install project deps (cached)'
13+
description: 'Sets up Python, install uv (cached), install project deps (cached)'
1414
inputs:
1515
python-version:
1616
description: 'Python version setup'
1717
required: true
18-
poetry-version:
19-
description: 'Poetry version to install'
18+
uv-version:
19+
description: 'Uv version to install'
2020
required: false
21-
default: '2.1.1'
22-
run-poetry-install:
23-
description: 'Whether to run poetry install on current dir'
21+
default: '0.6.5'
22+
run-uv-sync:
23+
description: 'Whether to run uv sync on current dir'
2424
required: false
2525
default: false
2626
create-venv-at-path:
27-
description: 'Path to venv (if poetry install is enabled)'
27+
description: 'Path to venv (if uv sync is enabled)'
2828
required: false
2929
default: '.venv'
3030

3131
runs:
3232
using: 'composite'
3333
steps:
34-
- name: Set up Python ${{ inputs.python-version }}
35-
uses: actions/setup-python@v5
34+
- name: Install UV
35+
uses: astral-sh/setup-uv@v5
3636
with:
37+
version: ${{ inputs.uv-version }}
3738
python-version: ${{ inputs.python-version }}
38-
39-
# This is required for OS portability in presence of caching.
40-
#
41-
# The act of installing poetry has the side effect of adding
42-
# poetry bin path to system path.
43-
#
44-
# But, if we get a cache hit on the poetry installation, we
45-
# don't get this important side effect. As a result, bare calls
46-
# to "poetry" fails.
47-
- name: Prepare PATH env to include where poetry will be installed into
48-
shell: bash
49-
run: |
50-
echo "~/.local/bin/" >> $GITHUB_PATH
51-
52-
- name: Restore cached poetry install
53-
id: restore-poetry-cache
54-
uses: actions/cache/restore@v4
55-
with:
56-
path: ~/.local
57-
key: ${{ runner.os }}-python-${{ inputs.python-version }}-poetry-${{ inputs.poetry-version }}
58-
59-
- if: steps.restore-poetry-cache.outputs.cache-hit != 'true'
60-
name: Install Poetry
61-
uses: snok/install-poetry@v1
62-
with:
63-
version: ${{ inputs.poetry-version }}
64-
virtualenvs-create: true
65-
virtualenvs-in-project: true
66-
virtualenvs-path: ${{ inputs.create-venv-at-path }}
67-
68-
- if: steps.restore-poetry-cache.outputs.cache-hit != 'true'
69-
name: Save poetry install to cache
70-
uses: actions/cache/save@v4
71-
with:
72-
path: ~/.local
73-
key: ${{ steps.restore-poetry-cache.outputs.cache-primary-key }}
39+
enable-cache: true
40+
cache-dependency-glob: "uv.lock"
7441

7542
- name: Restore cached project python deps
7643
id: restore-pydeps-cache
7744
uses: actions/cache/restore@v4
7845
with:
7946
path: ${{ inputs.create-venv-at-path }}
80-
key: ${{ runner.os }}-python-${{ inputs.python-version }}-pydeps-${{ hashFiles('**/poetry.lock') }}
47+
key: ${{ runner.os }}-python-${{ inputs.python-version }}-pydeps-${{ hashFiles('**/uv.lock') }}
8148

82-
- if: ${{ inputs.run-poetry-install == 'true' && steps.restore-pydeps-cache.outputs.cache-hit != 'true' }}
83-
name: Run poetry install (will get cached)
49+
- if: ${{ inputs.run-uv-sync == 'true' && steps.restore-pydeps-cache.outputs.cache-hit != 'true' }}
50+
name: Run uv sync (will get cached)
8451
# We skip over installing the root package (the current project code under CI)
85-
# Root package should not be cached - its content is not reflected in poetry.lock / cache key
86-
87-
# On Windows, it is scripts/activate. On Linux and MacOS, it is bin/activate
52+
# Root package should not be cached - its content is not reflected in uv.lock / cache key
8853
shell: bash
8954
run: |
90-
python -m venv ${{ inputs.create-venv-at-path }}
91-
source ${{ inputs.create-venv-at-path }}/*/activate
92-
poetry install --no-interaction --no-root
55+
uv sync --all-extras --dev --no-install-project
9356
9457
- if: steps.restore-pydeps-cache.outputs.cache-hit != 'true'
9558
name: Save Python deps to cache
@@ -98,16 +61,11 @@ runs:
9861
path: ${{ inputs.create-venv-at-path }}
9962
key: ${{ steps.restore-pydeps-cache.outputs.cache-primary-key }}
10063

101-
- if: ${{ inputs.run-poetry-install == 'true' }}
102-
name: Run poetry install (root package)
64+
- if: ${{ inputs.run-uv-sync == 'true' }}
65+
name: Run uv sync (root package)
10366
# Here we really install the root package (the current project code under CI).env:
10467
# This should not be cached.
10568
shell: bash
10669
run: |
107-
source ${{ inputs.create-venv-at-path }}/*/activate
108-
poetry install --only-root --no-interaction
70+
uv sync --all-extras --dev
10971
110-
- name: Install uv
111-
shell: bash
112-
run: |
113-
poetry run pip install uv

.github/workflows/benchmarks.yml

Lines changed: 16 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ jobs:
4141
- uses: ./.github/actions/setup_build_env
4242
with:
4343
python-version: ${{ matrix.python-version }}
44-
run-poetry-install: true
45-
create-venv-at-path: .venv
44+
run-uv-sync: true
45+
4646

4747
- name: Clone Reflex Website Repo
4848
uses: actions/checkout@v4
@@ -53,20 +53,20 @@ jobs:
5353

5454
- name: Install Requirements for reflex-web
5555
working-directory: ./reflex-web
56-
run: poetry run uv pip install -r requirements.txt
56+
run: uv pip install -r requirements.txt
5757
- name: Init Website for reflex-web
5858
working-directory: ./reflex-web
59-
run: poetry run reflex init
59+
run: uv run reflex init
6060
- name: Install LightHouse Pre-reqs / Run LightHouse
6161
run: |
6262
# Check that npm is home
6363
npm -v
64-
poetry run bash benchmarks/lighthouse.sh ./reflex-web prod
64+
uv run bash benchmarks/lighthouse.sh ./reflex-web prod
6565
env:
6666
LHCI_GITHUB_APP_TOKEN: $
6767
- name: Run Benchmarks
6868
# Only run if the database creds are available in this context.
69-
run: poetry run python benchmarks/benchmark_lighthouse.py "$GITHUB_SHA" ./integration/benchmarks/.lighthouseci
69+
run: uv run python benchmarks/benchmark_lighthouse.py "$GITHUB_SHA" ./integration/benchmarks/.lighthouseci
7070
env:
7171
GITHUB_SHA: ${{ github.sha }}
7272

@@ -82,15 +82,15 @@ jobs:
8282
- uses: ./.github/actions/setup_build_env
8383
with:
8484
python-version: 3.12.8
85-
run-poetry-install: true
86-
create-venv-at-path: .venv
85+
run-uv-sync: true
86+
8787
- name: Build reflex
8888
run: |
89-
poetry build
89+
uv build
9090
- name: Upload benchmark results
9191
# Only run if the database creds are available in this context.
9292
run:
93-
poetry run python benchmarks/benchmark_package_size.py --os ubuntu-latest
93+
uv run python benchmarks/benchmark_package_size.py --os ubuntu-latest
9494
--python-version 3.12.8 --commit-sha "${{ github.sha }}" --pr-id "${{ github.event.pull_request.id }}"
9595
--branch-name "${{ github.head_ref || github.ref_name }}"
9696
--path ./dist
@@ -114,29 +114,19 @@ jobs:
114114
uses: actions/setup-python@v5
115115
with:
116116
python-version: ${{ matrix.python-version }}
117-
- name: Install Poetry
118-
uses: snok/install-poetry@v1
117+
- name: Install UV
118+
uses: astral-sh/setup-uv@v5
119119
with:
120-
version: 1.3.1
121-
virtualenvs-create: true
122-
virtualenvs-in-project: true
123-
virtualenvs-path: .venv
124-
125-
- name: Run poetry install
126-
shell: bash
127-
run: |
128-
python -m venv .venv
129-
source .venv/*/activate
130-
poetry install --without dev --no-interaction --no-root
120+
version: 0.6.5
131121

132-
- name: Install uv
122+
- name: Run uv sync
133123
shell: bash
134124
run: |
135-
poetry run pip install uv
125+
uv install --no-install-project --no-dev
136126
137127
- name: calculate and upload size
138128
run:
139-
poetry run python benchmarks/benchmark_package_size.py --os "${{ matrix.os }}"
129+
uv run python benchmarks/benchmark_package_size.py --os "${{ matrix.os }}"
140130
--python-version "${{ matrix.python-version }}" --commit-sha "${{ github.sha }}"
141131
--pr-id "${{ github.event.pull_request.id }}"
142132
--branch-name "${{ github.head_ref || github.ref_name }}"

.github/workflows/check_generated_pyi.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,9 @@ jobs:
2626
- uses: ./.github/actions/setup_build_env
2727
with:
2828
python-version: "3.12.8"
29-
run-poetry-install: true
30-
create-venv-at-path: .venv
29+
run-uv-sync: true
3130
- run: |
32-
poetry run python scripts/make_pyi.py
31+
uv run python scripts/make_pyi.py
3332
if [[ $(git status --porcelain) ]]; then
3433
git status
3534
git diff

.github/workflows/check_node_latest.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ jobs:
2727
- uses: ./.github/actions/setup_build_env
2828
with:
2929
python-version: ${{ matrix.python-version }}
30-
run-poetry-install: true
31-
create-venv-at-path: .venv
30+
run-uv-sync: true
31+
3232
- uses: actions/setup-node@v4
3333
with:
3434
node-version: ${{ matrix.node-version }}
3535
- run: |
36-
poetry run uv pip install pyvirtualdisplay pillow pytest-split
37-
poetry run playwright install --with-deps
36+
uv pip install pyvirtualdisplay pillow pytest-split
37+
uv run playwright install --with-deps
3838
- run: |
39-
poetry run pytest tests/test_node_version.py
40-
poetry run pytest tests/integration --splits 2 --group ${{matrix.split_index}}
39+
uv run pytest tests/test_node_version.py
40+
uv run pytest tests/integration --splits 2 --group ${{matrix.split_index}}

.github/workflows/check_outdated_dependencies.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ jobs:
1717
- uses: ./.github/actions/setup_build_env
1818
with:
1919
python-version: '3.10'
20-
run-poetry-install: true
21-
create-venv-at-path: .venv
20+
run-uv-sync: true
21+
2222

2323
- name: Check outdated backend dependencies
2424
run: |
25-
outdated=$(poetry show -oT)
25+
outdated=$(uv pip list --outdated)
2626
echo "Outdated:"
2727
echo "$outdated"
2828
@@ -45,8 +45,8 @@ jobs:
4545
- uses: ./.github/actions/setup_build_env
4646
with:
4747
python-version: "3.10.16"
48-
run-poetry-install: true
49-
create-venv-at-path: .venv
48+
run-uv-sync: true
49+
5050
- name: Clone Reflex Website Repo
5151
uses: actions/checkout@v4
5252
with:
@@ -55,15 +55,15 @@ jobs:
5555
path: reflex-web
5656
- name: Install Requirements for reflex-web
5757
working-directory: ./reflex-web
58-
run: poetry run uv pip install $(grep -ivE "reflex " requirements.txt)
58+
run: uv pip install $(grep -ivE "reflex " requirements.txt)
5959
- name: Install additional dependencies for DB access
60-
run: poetry run uv pip install psycopg
60+
run: uv pip install psycopg
6161
- name: Init Website for reflex-web
6262
working-directory: ./reflex-web
63-
run: poetry run reflex init
63+
run: uv run reflex init
6464
- name: Run Website and Check for errors
6565
run: |
66-
poetry run bash scripts/integration.sh ./reflex-web dev
66+
uv run bash scripts/integration.sh ./reflex-web dev
6767
- name: Check outdated frontend dependencies
6868
working-directory: ./reflex-web/.web
6969
run: |

.github/workflows/integration_app_harness.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@ jobs:
4545
- uses: ./.github/actions/setup_build_env
4646
with:
4747
python-version: ${{ matrix.python-version }}
48-
run-poetry-install: true
49-
create-venv-at-path: .venv
50-
- run: poetry run uv pip install pyvirtualdisplay pillow pytest-split pytest-retry
48+
run-uv-sync: true
49+
50+
- run: uv pip install pyvirtualdisplay pillow pytest-split pytest-retry
5151
- name: Run app harness tests
5252
env:
5353
REDIS_URL: ${{ matrix.state_manager == 'redis' && 'redis://localhost:6379' || '' }}
5454
run: |
55-
poetry run playwright install chromium
56-
poetry run pytest tests/integration --retries 3 --maxfail=5 --splits 2 --group ${{matrix.split_index}}
55+
uv run playwright install chromium
56+
uv run pytest tests/integration --retries 3 --maxfail=5 --splits 2 --group ${{matrix.split_index}}

0 commit comments

Comments
 (0)