Skip to content

Commit 0c739a4

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 0c739a4

File tree

5 files changed

+1626
-30
lines changed

5 files changed

+1626
-30
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: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ GIT_TAG = `git describe --tags || echo "no version info"`
1515
AUTHOR = $(USER)
1616

1717
# Imports the environment variables
18-
## TODO if we call the file .env, then it'll be read by pipenv too
1918
## which is good for running migrate
2019
# ifneq ("$(wildcard .env)","")
2120
# include .env
@@ -25,22 +24,24 @@ AUTHOR = $(USER)
2524
# export
2625
# endif
2726

27+
# Env file for dockerrun, defaults to .env.local / .env
28+
export UV_ENV_FILE ?= $(if $(wildcard .env),.env,.env.default)
29+
2830
# Django specific
2931
APP_SRC_DIR := app
3032
DJANGO_MANAGER := $(CURRENT_DIR)/$(APP_SRC_DIR)/manage.py
3133
DJANGO_MANAGER_DEBUG := -m debugpy --listen localhost:5678 --wait-for-client $(CURRENT_DIR)/$(APP_SRC_DIR)/manage.py
3234

3335
# 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
36+
UV_RUN := uv run
37+
PYTHON := $(UV_RUN)
38+
TEST := $(UV_RUN) pytest
39+
RUFF := $(UV_RUN) ruff
40+
ISORT := $(UV_RUN) isort
41+
MYPY := $(UV_RUN) mypy
4142
PSQL := PGPASSWORD=postgres psql -h localhost -p 15433 -U postgres
4243
PGRESTORE := PGPASSWORD=postgres pg_restore -h localhost -p 15433 -U postgres
43-
BANDIT := $(PIPENV_RUN) bandit
44+
BANDIT := $(UV_RUN) bandit
4445

4546
# Find all python files that are not inside a hidden directory (directory starting with .)
4647
PYTHON_FILES := $(shell find $(APP_SRC_DIR) -type f -name "*.py" -print)
@@ -52,34 +53,30 @@ DOCKER_IMG_LOCAL_TAG := $(DOCKER_REGISTRY)/$(SERVICE_NAME):local-$(USER)-$(GIT_H
5253
# AWS variables
5354
AWS_DEFAULT_REGION = eu-central-1
5455

55-
# Env file for dockerrun, defaults to .env.local / .env
56-
ENV_FILE ?= $(if $(wildcard .env.local),.env.local,.env)
57-
5856
.PHONY: ci
5957
ci:
6058
# Create virtual env with all packages for development using the Pipfile.lock
61-
pipenv sync --dev
59+
uv sync --dev
6260

6361
.PHONY: setup
6462
setup: $(SETTINGS_TIMESTAMP) ## Create virtualenv with all packages for development
65-
pipenv install --dev
63+
uv sync --dev
6664
cp .env.default .env
67-
pipenv shell
6865

6966
.PHONY: format
7067
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)
68+
$(RUFF) format ${PYTHON_FILES}
7269
$(ISORT) $(PYTHON_FILES)
7370

7471

7572
.PHONY: django-checks
7673
django-checks: ## Run the django checks
77-
$(PYTHON) $(DJANGO_MANAGER) check --fail-level WARNING
74+
$(UV_RUN) $(DJANGO_MANAGER) check --fail-level WARNING
7875

7976
.PHONY: django-check-migrations
8077
django-check-migrations: ## Check the migrations
8178
@echo "Check for missing migration files"
82-
$(PYTHON) $(DJANGO_MANAGER) makemigrations --no-input --check
79+
$(UV_RUN) $(DJANGO_MANAGER) makemigrations --no-input --check
8380

8481

8582
.PHONY: ci-check-format
@@ -140,7 +137,7 @@ dockerrun: dockerbuild ## Run the locally built docker image
140137
.PHONY: lint
141138
lint: ## Run the linter on the code base
142139
@echo "Run pylint..."
143-
LOGGING_CFG=0 $(PYLINT) $(PYTHON_FILES)
140+
LOGGING_CFG=0 $(RUFF) check $(PYTHON_FILES)
144141

145142
.PHONY: type-check
146143
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)