Skip to content

Commit 5393bc6

Browse files
committed
Migrate from poetry to uv
uv is usually easier to use.
1 parent ee37c35 commit 5393bc6

File tree

9 files changed

+596
-925
lines changed

9 files changed

+596
-925
lines changed

.github/workflows/deploy-application.yml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ on:
3030
required: true
3131
type: string
3232

33-
permissions: { }
33+
permissions: {}
3434

3535
concurrency:
3636
group: deploy-mavis-${{ inputs.environment }}
@@ -95,14 +95,13 @@ jobs:
9595
with:
9696
role-to-assume: ${{ env.aws_role }}
9797
aws-region: eu-west-2
98-
- name: Install poetry
99-
run: pipx install poetry
98+
- name: Install uv
99+
uses: astral-sh/setup-uv@v5
100100
- name: Setup python
101101
uses: actions/setup-python@v5
102102
with:
103103
python-version: 3.13.0
104-
cache: poetry
105-
- run: poetry install
104+
- run: uv sync --dev
106105
- name: Get image digest
107106
id: get-image-digest
108107
run: |
@@ -133,7 +132,7 @@ jobs:
133132
run: mv ${{ steps.create-task-definition.outputs.task-definition }} ${{ runner.temp }}/reporting-task-definition.json
134133
- name: Populate SSM parameters for reporting service
135134
run: |
136-
poetry run scripts/populate_ssm_parameters.py ${{ inputs.environment }} reporting
135+
uv run scripts/populate_ssm_parameters.py ${{ inputs.environment }} reporting
137136
- name: Upload artifact for reporting task definition
138137
uses: actions/upload-artifact@v4
139138
with:
@@ -151,7 +150,7 @@ jobs:
151150
deploy:
152151
name: Deploy reporting service
153152
runs-on: ubuntu-latest
154-
needs: [ prepare-deployment, approve-deployments ]
153+
needs: [prepare-deployment, approve-deployments]
155154
permissions:
156155
id-token: write
157156
steps:

.tool-versions

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
python 3.13.0
2-
poetry 2.1.3
3-
gitleaks 8.28.0
1+
gitleaks latest
2+
python 3.13
3+
uv latest

Dockerfile

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,32 @@ FROM python:3.13.7-alpine AS builder
22

33
WORKDIR /app
44

5-
ADD package.json package-lock.json pyproject.toml poetry.lock Makefile /app/
5+
ADD package.json package-lock.json pyproject.toml uv.lock Makefile /app/
66

77
RUN apk add build-base libffi-dev npm bash curl
88

9-
RUN pip install poetry
10-
RUN make install
9+
RUN pip install uv
1110

11+
ADD ./mavis_reporting /app/mavis_reporting
12+
ADD README.md /app/
13+
14+
RUN uv sync --frozen --all-extras
15+
RUN npm install
16+
17+
FROM builder
1218

13-
FROM builder
1419
WORKDIR /app
1520

16-
ADD ./mavis_reporting /app/mavis_reporting
1721
RUN make build-assets
1822

19-
# Create a new group `app` with Group ID `1000`.
2023
RUN addgroup --gid 1000 app
21-
# Create a new user `app`, sets home directory to `/app`, User ID `1000`, in
22-
# the group `app`. The `-DH` option results in a system account.
2324
RUN adduser app -h /app -u 1000 -G app -DH
24-
# Change the user for subsequent commands in Dockerfile to the user with ID
25-
# `1000`.
25+
RUN mkdir -p /app/.cache/uv && chown -R app:app /app/.cache
26+
RUN chown -R app:app /app/.venv
27+
2628
USER 1000
2729

2830
VOLUME ["/tmp", "/var/tmp", "/usr/tmp"]
2931

3032
# pass through additional arguments like --workers=5 via GUNICORN_CMD_ARGS
31-
CMD ["poetry", "run", "gunicorn", "--bind", "0.0.0.0:5000", "mavis_reporting:create_app()"]
33+
CMD ["uv", "run", "gunicorn", "--bind", "0.0.0.0:5000", "mavis_reporting:create_app()"]

Makefile

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,10 @@ clean:
1111
@rm -rf .venv
1212
@rm -rf __pycache__
1313

14-
sentinel: package.json package-lock.json pyproject.toml poetry.lock
14+
sentinel: package.json package-lock.json pyproject.toml uv.lock
1515
@echo "== Installing dependencies =="
1616
@npm install || (echo "Failed to install npm dependencies"; exit 1)
17-
@poetry config virtualenvs.in-project true
18-
@poetry install || (echo "Failed to install Python dependencies"; exit 1)
17+
@uv sync --all-extras || (echo "Failed to install Python dependencies"; exit 1)
1918

2019
@echo "== Copying NHSUK favicons =="
2120
@make copy-nhsuk-favicons
@@ -31,17 +30,17 @@ install: sentinel
3130

3231
.PHONY: lint
3332
lint: install
34-
poetry run ruff check .
33+
uv run ruff check .
3534

3635
.PHONY: lint-fix
3736
lint-fix: install
38-
poetry run ruff check --fix .
37+
uv run ruff check --fix .
3938

4039
.PHONY: dev
4140
dev: install
4241
@echo "== Starting development servers =="
4342
@echo "Press Ctrl+C to stop all processes"
44-
@poetry run honcho start -f Procfile.dev
43+
@uv run honcho start -f Procfile.dev
4544

4645
.PHONY: copy-nhsuk-favicons
4746
copy-nhsuk-favicons:
@@ -57,13 +56,13 @@ run-docker:
5756

5857
test: install
5958
@echo "Running all tests .."
60-
@poetry run pytest tests --verbose
59+
@uv run pytest tests --verbose
6160

6261
.PHONY: test-coverage
6362
test-coverage: install
6463
@echo "Checking coverage on all tests .."
65-
@poetry run coverage run -m pytest tests --verbose
66-
@poetry run coverage report --fail-under=${COVERAGE_THRESHOLD}
67-
@poetry run coverage html
68-
@poetry run coverage xml coverage.xml
69-
@poetry run coverage-badge -o coverage.svg
64+
@uv run coverage run -m pytest tests --verbose
65+
@uv run coverage report --fail-under=${COVERAGE_THRESHOLD}
66+
@uv run coverage html
67+
@uv run coverage xml coverage.xml
68+
@uv run coverage-badge -o coverage.svg

Procfile.dev

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
scss: npm run build:scss:dev
22
js: npm run build:js:dev
3-
flask: poetry run flask run --debug -p 5001
3+
flask: uv run flask run --debug -p 5001

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ A Flask-based web application for the commissioner reporting component of Mavis.
2121

2222
2. **Install project dependencies**
2323

24-
This will install the project dependencies using Poetry and NPM.
24+
This will install the project dependencies using uv and NPM.
2525

26-
Note that the Poetry virtual environment will be created in the `.venv` directory to allow IDEs to use the correct Python interpreter.
26+
Note that the uv virtual environment will be created in the `.venv` directory to allow IDEs to use the correct Python interpreter.
2727

2828
```bash
2929
make install

0 commit comments

Comments
 (0)