Skip to content

Commit 9189461

Browse files
authored
Merge pull request #175 from duo-labs/feat/astral-uv-support
Use Astral's uv and ruff
2 parents 0180883 + 8ebb8ae commit 9189461

File tree

20 files changed

+681
-858
lines changed

20 files changed

+681
-858
lines changed

.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ indent_size = 2
88
indent_style = space
99
insert_final_newline = true
1010

11-
[*.{py,md}]
11+
[*.{py,md,toml}]
1212
indent_size = 4

.github/workflows/unit_test.yml

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,21 +30,27 @@ jobs:
3030
- 6379:6379
3131

3232
steps:
33-
- uses: actions/checkout@v3
33+
- uses: actions/checkout@v5
34+
3435
- name: Set up Python ${{ matrix.python-version }}
35-
uses: actions/setup-python@v4
36+
uses: actions/setup-python@v6
37+
with:
38+
python-version-file: "pyproject.toml"
39+
40+
- name: Install uv
41+
uses: astral-sh/setup-uv@v6
3642
with:
37-
python-version: ${{ matrix.python-version }}
43+
version: "0.9.9"
44+
3845
- name: Install dependencies
39-
run: |
40-
python -m pip install --upgrade pipenv
41-
pipenv install --deploy --dev
46+
run: uv sync --locked --all-extras --dev
47+
4248
- name: Test with unittest
43-
run: |
44-
pipenv run _app/manage.py test homepage.tests
49+
run: uv run python _app/manage.py test homepage.tests
4550
env:
4651
# Tests are running "locally" while Redis is in a container
4752
REDIS_HOSTNAME: localhost
53+
4854
- name: Run mypy
4955
run: |
50-
pipenv run mypy _app/homepage
56+
uv run mypy _app/homepage

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,6 @@ _psql
55
*.env
66
.DS_Store
77
_app/**/styles/*.css
8+
_app/.venv
9+
_app/pyproject.toml
10+
_app/uv.lock

.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.10

Dockerfile

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
# Tweak the base image by installing pipenv
1+
# Tweak the base image by installing uv
22
FROM python:3.10-slim AS base
3-
RUN pip install pipenv
3+
4+
# Install uv (https://docs.astral.sh/uv/guides/integration/docker/#installing-uv)
5+
COPY --from=ghcr.io/astral-sh/uv:0.9.9 /uv /uvx /bin/
46

57
# Begin our actual build
68
FROM base AS base1
@@ -11,13 +13,12 @@ ARG DJANGO_SECRET_KEY
1113
RUN mkdir -p /usr/src/app
1214

1315
COPY ./_app /usr/src/app
14-
COPY Pipfile /usr/src/app/
15-
COPY Pipfile.lock /usr/src/app/
16+
COPY pyproject.toml uv.lock /usr/src/app/
1617

1718
WORKDIR /usr/src/app
1819

1920
# Install Python dependencies
20-
RUN pipenv install --system --deploy
21+
RUN uv sync --locked
2122

2223
# Collect static files
23-
RUN python manage.py collectstatic --no-input
24+
RUN uv run python manage.py collectstatic --no-input

Pipfile

Lines changed: 0 additions & 25 deletions
This file was deleted.

Pipfile.lock

Lines changed: 0 additions & 803 deletions
This file was deleted.

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@ Duo's introduction to the wonderful world of WebAuthn. Powered by [py_webauthn](
55
## Prerequisites
66

77
- Docker
8-
- Pipenv
9-
- Make sure Python3 is available
10-
- Enables `pipenv install` to set up libraries locally for the editor to crawl. The Django container also uses Pipenv to install dependencies to encourage use of this new Python package management tool.
8+
- uv (See https://docs.astral.sh/uv/getting-started/installation/)
9+
- Run `uv sync` locally to install dependencies and give the editor something to crawl
1110

1211
## Environmental Variable
1312

_app/homepage/admin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
from django.contrib import admin
1+
# from django.contrib import admin
22

33
# Register your models here.

_app/homepage/helpers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@ def truncate_credential_id_to_ui_string(id: str) -> str:
2828
# Return the entire ID if there's nothing to truncate
2929
return id
3030

31-
return f"{id[0:truncation_length]}...{id[(0-truncation_length):]}"
31+
return f"{id[0:truncation_length]}...{id[(0 - truncation_length) :]}"

0 commit comments

Comments
 (0)