Skip to content

Commit c415605

Browse files
authored
Merge pull request #55 from steder/claude/dependabot-updates-modernize-WbEUJ
Migrate to uv and apply pending Dependabot bumps
2 parents 106bded + c26761a commit c415605

14 files changed

Lines changed: 899 additions & 2203 deletions

.github/python-app.yml

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

.github/workflows/python-app.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Python application
2+
3+
on:
4+
push:
5+
branches: [ "*" ]
6+
pull_request:
7+
branches: [ "*" ]
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
build:
14+
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
- name: Install ImageMagick
20+
run: sudo apt-get update && sudo apt-get install -y imagemagick libmagickwand-dev
21+
- name: Install uv
22+
uses: astral-sh/setup-uv@v5
23+
with:
24+
enable-cache: true
25+
python-version: "3.13"
26+
- name: Install dependencies
27+
run: uv sync --all-groups --frozen
28+
- name: Lint with flake8
29+
run: |
30+
uv run flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics --exclude=.venv,.git,__pycache__
31+
uv run flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics --exclude=.venv,.git,__pycache__
32+
- name: Test with pytest
33+
run: uv run pytest

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
.tox
22
__pycache__
33
.coverage
4-
requirements.pypy.txt
4+
.venv
5+
.pytest_cache
6+
*.egg-info

.travis.yml

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

Dockerfile

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,38 @@
1-
FROM python:3.13-slim as builder
1+
FROM python:3.13-slim AS builder
22

3-
# metadata
4-
MAINTAINER steder@gmail.com
5-
LABEL version="1.0"
3+
LABEL org.opencontainers.image.authors="steder@gmail.com"
4+
LABEL version="2.0"
65

7-
ENV ENV=development
6+
ENV ENV=development \
7+
UV_LINK_MODE=copy \
8+
UV_COMPILE_BYTECODE=1 \
9+
UV_PYTHON_DOWNLOADS=never
810

9-
# actual container setup:
1011
RUN apt-get update \
1112
&& apt-get -y upgrade \
1213
&& apt-get install -y --no-install-recommends \
1314
build-essential \
1415
imagemagick \
1516
git \
16-
&& pip install poetry \
1717
&& apt-get clean \
1818
&& rm -rf /var/lib/apt/lists/*
1919

20-
FROM builder as giraffe
20+
COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv
2121

22-
# Giraffe listens on 9876 by default
23-
EXPOSE 9876
22+
FROM builder AS giraffe
2423

25-
# let's get the code!
24+
EXPOSE 9876
2625

2726
WORKDIR /opt/app
2827

29-
COPY pyproject.toml poetry.lock /opt/app/
30-
RUN poetry install --no-root --without=dev
28+
COPY pyproject.toml uv.lock /opt/app/
29+
RUN uv sync --frozen --no-dev --no-install-project
3130

3231
COPY . /opt/app
3332

34-
RUN poetry install --without=dev
35-
36-
CMD ["poetry", "run", "gunicorn", "-k", "uvicorn.workers.UvicornWorker", "-c", "etc/gunicorn.conf.py", "giraffe:app", "--log-level=DEBUG"]
33+
CMD ["uv", "run", "--no-dev", "gunicorn", "-k", "uvicorn.workers.UvicornWorker", "-c", "etc/gunicorn.conf.py", "giraffe:app", "--log-level=DEBUG"]
3734

38-
FROM giraffe as dev
39-
RUN poetry install
35+
FROM giraffe AS dev
36+
RUN uv sync --frozen
4037

41-
CMD ["poetry", "run", "python", "/opt/app/giraffe.py"]
38+
CMD ["uv", "run", "python", "/opt/app/giraffe.py"]

README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ More specifically, this started out as something to help out the design team and
88

99
Instead, we moved to uploading original images to S3 and letting the resizing, overlays, etc happen dynamically in Giraffe.
1010

11-
![travis ci build status](https://travis-ci.org/steder/giraffe.png)
11+
![python application build status](https://github.com/steder/giraffe/actions/workflows/python-app.yml/badge.svg)
1212

1313
## Why call it Giraffe?
1414

@@ -96,8 +96,9 @@ Supported params:
9696
### Dependencies
9797

9898
At a system level you'll need:
99-
- `Python` (3.7+, or pypy3)
99+
- `Python` 3.13+
100100
- `ImageMagick` (remember to use `--with-liblqr` if you want to be able to use content-aware resizing)
101+
- [`uv`](https://docs.astral.sh/uv/) for managing the Python environment and dependencies
101102

102103
For deployment with Gunicorn you may also want `libev`.
103104

@@ -111,14 +112,14 @@ You need to set the following environment variables for giraffe to work properly
111112
### Development
112113

113114
```
114-
mkvirtualenv giraffe
115-
pip install -r requirements.txt
115+
uv sync --all-groups
116+
uv run python giraffe.py
116117
```
117118

118119
#### Testing
119120

120121
```
121-
pytest
122+
uv run pytest
122123
```
123124

124125
### Deployment

app.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ if [ -e $ROOT/conf.sh ]; then
2626
fi
2727

2828
# Option 1: Gunicorn with Uvicorn workers (Recommended for production)
29-
# poetry run newrelic-admin run-program gunicorn -k uvicorn.workers.UvicornWorker -c etc/gunicorn.conf.py giraffe:app --log-level=DEBUG
29+
# uv run newrelic-admin run-program gunicorn -k uvicorn.workers.UvicornWorker -c etc/gunicorn.conf.py giraffe:app --log-level=DEBUG
3030

3131
# Option 2: Direct Uvicorn (Simple, but less process management)
32-
poetry run newrelic-admin run-program uvicorn giraffe:app --host 0.0.0.0 --port 8080 --workers 4 --log-level debug
32+
uv run newrelic-admin run-program uvicorn giraffe:app --host 0.0.0.0 --port 8080 --workers 4 --log-level debug
3333

3434
# Option 3: Hypercorn (For HTTP/3 support)
35-
# poetry run newrelic-admin run-program hypercorn giraffe:app --bind 0.0.0.0:8080 --workers 4 --log-level debug
35+
# uv run newrelic-admin run-program hypercorn giraffe:app --bind 0.0.0.0:8080 --workers 4 --log-level debug
3636

3737
# Option 4: Granian (Maximum performance)
38-
# poetry run newrelic-admin run-program granian --interface asgi giraffe:app --host 0.0.0.0 --port 8080 --workers 4
38+
# uv run newrelic-admin run-program granian --interface asgi giraffe:app --host 0.0.0.0 --port 8080 --workers 4

etc/old_fabfile.py

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

0 commit comments

Comments
 (0)