Skip to content

Commit 5ec3d12

Browse files
committed
Switch to uv and ruff
Throw out pipenv, yapf and all that to be replaced by the more powerful tools uv and ruff
1 parent ddc645d commit 5ec3d12

File tree

5 files changed

+1624
-27
lines changed

5 files changed

+1624
-27
lines changed

.python-version

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

Dockerfile

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ ENV USER=geoadmin
88
ENV GROUP=geoadmin
99
ENV INSTALL_DIR=/opt/service-control
1010
ENV SRC_DIR=/usr/local/src/service-control
11-
ENV PIPENV_VENV_IN_PROJECT=1
1211

1312
RUN apt-get -qq update > /dev/null \
1413
&& apt-get -qq clean \
@@ -23,15 +22,16 @@ RUN apt-get -qq update > /dev/null \
2322
&& apt-get -qq -y install \
2423
# dev dependencies
2524
binutils libproj-dev \
25+
postgresql-client-common \
2626
# silent the installation
2727
> /dev/null \
2828
&& apt-get -qq clean \
29-
&& rm -rf /var/lib/apt/lists/* \
30-
&& pip3 install pipenv \
31-
&& pipenv --version
29+
&& rm -rf /var/lib/apt/lists/*
30+
31+
RUN pip3 install uv
3232

33-
COPY Pipfile.lock Pipfile ${SRC_DIR}/
34-
RUN cd ${SRC_DIR} && pipenv sync
33+
COPY pyproject.toml uv.lock ${SRC_DIR}/
34+
RUN cd ${SRC_DIR} && uv sync
3535

3636
COPY --chown=${USER}:${GROUP} app/ ${INSTALL_DIR}/app/
3737

@@ -54,13 +54,13 @@ RUN apt-get -qq update > /dev/null \
5454
# silent the install
5555
> /dev/null \
5656
&& apt-get -qq clean \
57-
&& rm -rf /var/lib/apt/lists/* \
58-
&& pip3 install pipenv \
59-
&& pipenv --version
57+
&& rm -rf /var/lib/apt/lists/*
58+
59+
RUN pip3 install uv
6060

6161
# Install all dev dependencies
62-
COPY Pipfile.lock Pipfile ${INSTALL_DIR}/
63-
RUN cd ${INSTALL_DIR} && pipenv sync --dev
62+
COPY pyproject.toml uv.lock ${INSTALL_DIR}/
63+
RUN cd ${INSTALL_DIR} && uv sync --dev
6464

6565
# this is only used with the docker-compose setup within CI
6666
# to ensure that the app is only started once the DB container

Makefile

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,15 @@ DJANGO_MANAGER := $(CURRENT_DIR)/$(APP_SRC_DIR)/manage.py
3131
DJANGO_MANAGER_DEBUG := -m debugpy --listen localhost:5678 --wait-for-client $(CURRENT_DIR)/$(APP_SRC_DIR)/manage.py
3232

3333
# Commands
34-
PIPENV_RUN := pipenv run
35-
PYTHON := $(PIPENV_RUN) python3
36-
TEST := $(PIPENV_RUN) pytest
37-
YAPF := $(PIPENV_RUN) yapf
38-
ISORT := $(PIPENV_RUN) isort
39-
PYLINT := $(PIPENV_RUN) pylint
40-
MYPY := $(PIPENV_RUN) mypy
34+
UV_RUN := uv run
35+
PYTHON := $(UV_RUN)
36+
TEST := $(UV_RUN) pytest
37+
RUFF := $(UV_RUN) ruff
38+
ISORT := $(UV_RUN) isort
39+
MYPY := $(UV_RUN) mypy
4140
PSQL := PGPASSWORD=postgres psql -h localhost -p 15433 -U postgres
4241
PGRESTORE := PGPASSWORD=postgres pg_restore -h localhost -p 15433 -U postgres
43-
BANDIT := $(PIPENV_RUN) bandit
42+
BANDIT := $(UV_RUN) bandit
4443

4544
# Find all python files that are not inside a hidden directory (directory starting with .)
4645
PYTHON_FILES := $(shell find $(APP_SRC_DIR) -type f -name "*.py" -print)
@@ -53,33 +52,32 @@ DOCKER_IMG_LOCAL_TAG := $(DOCKER_REGISTRY)/$(SERVICE_NAME):local-$(USER)-$(GIT_H
5352
AWS_DEFAULT_REGION = eu-central-1
5453

5554
# Env file for dockerrun, defaults to .env.local / .env
56-
ENV_FILE ?= $(if $(wildcard .env.local),.env.local,.env)
55+
export UV_ENV_FILE ?= $(if $(wildcard .env.local),.env.local,.env)
5756

5857
.PHONY: ci
5958
ci:
6059
# Create virtual env with all packages for development using the Pipfile.lock
61-
pipenv sync --dev
60+
uv sync --dev
6261

6362
.PHONY: setup
6463
setup: $(SETTINGS_TIMESTAMP) ## Create virtualenv with all packages for development
65-
pipenv install --dev
64+
uv sync --dev
6665
cp .env.default .env
67-
pipenv shell
6866

6967
.PHONY: format
7068
format: ## Call yapf to make sure your code is easier to read and respects some conventions.
71-
$(YAPF) -p -i --style .style.yapf $(PYTHON_FILES)
69+
$(RUFF) format ${PYTHON_FILES}
7270
$(ISORT) $(PYTHON_FILES)
7371

7472

7573
.PHONY: django-checks
7674
django-checks: ## Run the django checks
77-
$(PYTHON) $(DJANGO_MANAGER) check --fail-level WARNING
75+
$(UV_RUN) $(DJANGO_MANAGER) check --fail-level WARNING
7876

7977
.PHONY: django-check-migrations
8078
django-check-migrations: ## Check the migrations
8179
@echo "Check for missing migration files"
82-
$(PYTHON) $(DJANGO_MANAGER) makemigrations --no-input --check
80+
$(UV_RUN) $(DJANGO_MANAGER) makemigrations --no-input --check
8381

8482

8583
.PHONY: ci-check-format
@@ -140,7 +138,7 @@ dockerrun: dockerbuild ## Run the locally built docker image
140138
.PHONY: lint
141139
lint: ## Run the linter on the code base
142140
@echo "Run pylint..."
143-
LOGGING_CFG=0 $(PYLINT) $(PYTHON_FILES)
141+
LOGGING_CFG=0 $(RUFF) check $(PYTHON_FILES)
144142

145143
.PHONY: type-check
146144
type-check: ## Run the type-checker mypy

pyproject.toml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
[project]
2+
name = "service-control"
3+
version = "0.1.0"
4+
description = "Add your description here"
5+
readme = "README.md"
6+
requires-python = ">=3.12"
7+
dependencies = [
8+
"beautifulsoup4>=4.13.4",
9+
"boto3>=1.40.15",
10+
"django>=5.2.5",
11+
"django-environ>=0.12.0",
12+
"django-ninja>=1.4.3",
13+
"ecs-logging>=2.2.0",
14+
"gevent>=25.5.1",
15+
"gunicorn>=23.0.0",
16+
"logging-utilities>=5.1.0",
17+
"nanoid>=2.0.0",
18+
"psycopg[binary]>=3.2.9",
19+
"pystac-client>=0.9.0",
20+
"pyyaml>=6.0.2",
21+
"requests>=2.32.5",
22+
"whitenoise>=6.9.0",
23+
]
24+
25+
[dependency-groups]
26+
dev = [
27+
"bandit>=1.8.6",
28+
"boto3-stubs>=1.40.15",
29+
"debugpy>=1.8.16",
30+
"dill>=0.4.0",
31+
"django-debug-toolbar>=6.0.0",
32+
"django-extensions>=4.1",
33+
"django-stubs>=5.2.2",
34+
"factory-boy>=3.3.3",
35+
"faker>=37.5.3",
36+
"ipdb>=0.13.13",
37+
"isort>=6.0.1",
38+
"mypy>=1.17.1",
39+
"pytest>=8.4.1",
40+
"pytest-cov>=6.2.1",
41+
"pytest-django>=4.11.1",
42+
"pytest-xdist>=3.8.0",
43+
"ruff>=0.12.10",
44+
"types-gevent>=25.4.0.20250822",
45+
"types-nanoid>=2.0.0.20240601",
46+
"types-requests>=2.32.4.20250809",
47+
]

0 commit comments

Comments
 (0)