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
1212name : ' 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)'
1414inputs :
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
3131runs :
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
0 commit comments