Skip to content

Commit 95a5f46

Browse files
committed
build: change from poetry to uv
1 parent 6a01c4e commit 95a5f46

File tree

8 files changed

+998
-1213
lines changed

8 files changed

+998
-1213
lines changed

.github/workflows/ci.yml

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,13 @@ jobs:
3737

3838
steps:
3939
- uses: actions/checkout@v4
40-
- name: Install poetry
41-
run: pipx install poetry
40+
- name: Install uv
41+
uses: astral-sh/setup-uv@v4
4242
- name: "Set up python ${{ matrix.python-version }}"
4343
id: setup-python
4444
uses: actions/setup-python@v5
4545
with:
4646
python-version: ${{ matrix.python-version }}
47-
cache: 'poetry'
4847
#----------------------------------------------
4948
# ----- cache and install os packages -----
5049
#----------------------------------------------
@@ -67,19 +66,11 @@ jobs:
6766
sudo apt-get update
6867
sudo apt-get install -y --no-install-recommends binutils libproj-dev gdal-bin libgeoip1 python3-gdal
6968
#----------------------------------------------
70-
# install dependencies
69+
# install dependencies and run tests
7170
#----------------------------------------------
72-
- name: Install dependencies
73-
run: poetry install --no-interaction --no-root
74-
#----------------------------------------------
75-
# install your root project, if required
76-
#----------------------------------------------
77-
- name: Install library
78-
run: poetry install --no-interaction
79-
#----------------------------------------------
80-
# Run tests
81-
#----------------------------------------------
82-
- name: Run tests
71+
- name: Install dependencies and run tests
8372
env:
8473
DATABASE_URL: "postgres://${{ env.POSTGRES_USER }}:${{ env.POSTGRES_PASSWORD }}@localhost:5432/${{ env.POSTGRES_DB }}"
85-
run: poetry run python ./runtests.py
74+
run: |
75+
uv sync --extra dev
76+
uv run python ./runtests.py

Dockerfile

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM python:3.12
1+
FROM ghcr.io/astral-sh/uv:python3.13-bookworm-slim
22

33
ENV PYTHONUNBUFFERED 1
44

@@ -10,17 +10,24 @@ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -qq -y --no
1010
python3-gdal \
1111
&& rm -rf /var/lib/apt/lists/*
1212

13-
# Requirements have to be pulled and installed here, otherwise caching won't work
14-
RUN pip install --no-cache-dir -U pip
15-
RUN pip install --no-cache-dir poetry poetry-plugin-export
16-
COPY pyproject.toml poetry.lock ./
17-
RUN poetry export --with dev --without-hashes -f requirements.txt > requirements.txt
18-
RUN pip install --no-cache-dir -r requirements.txt
13+
WORKDIR /app
14+
15+
RUN --mount=type=cache,target=/root/.cache/uv \
16+
--mount=type=bind,source=uv.lock,target=uv.lock \
17+
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
18+
uv sync --locked --no-install-project
1919

2020
COPY ./docker-entrypoint.sh /entrypoint.sh
2121
RUN sed -i 's/\r//' /entrypoint.sh
2222
RUN chmod +x /entrypoint.sh
2323

24-
WORKDIR /app
24+
COPY . /app/
25+
26+
RUN --mount=type=cache,target=/root/.cache/uv \
27+
--mount=type=bind,source=uv.lock,target=uv.lock \
28+
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
29+
uv sync --locked
30+
31+
ENV PATH="/app/.venv/bin:$PATH"
2532

2633
ENTRYPOINT ["/entrypoint.sh"]

README.rst

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,31 @@ Quick start
4242

4343
5. Access the ``/locations/`` URL.
4444

45-
Run Tests
46-
---------
45+
Development
46+
-----------
47+
48+
This project uses `uv <https://docs.astral.sh/uv/>`_ for dependency management.
49+
50+
Install dependencies::
51+
52+
uv sync
53+
54+
Run tests::
4755

4856
docker compose run --rm django python ./runtests.py
4957

58+
Format code::
59+
60+
uv run invoke format
61+
62+
Run linting::
63+
64+
uv run invoke lint
65+
66+
Create migrations:
67+
68+
docker compose run --rm django python example/manage.py makemigrations
69+
5070

5171
Credits
5272
-------

docker-compose.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ services:
1919
- postgres
2020
volumes:
2121
- .:/app
22+
- type: volume
23+
source: venv
24+
target: /app/.venv
2225
environment:
2326
- POSTGRES_USER=location_api
2427
- POSTGRES_PASSWORD=location_api
@@ -30,3 +33,4 @@ services:
3033
volumes:
3134
postgres_data_local: {}
3235
postgres_backup_local: {}
36+
venv: # Volume for the virtual environment for persistent in the container.

poetry.lock

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

pyproject.toml

Lines changed: 54 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,66 @@
1-
[tool]
2-
[tool.poetry]
1+
[project]
32
name = "django-location-api"
43
version = "0.1.0"
5-
homepage = "https://github.com/carlosfunk/django-location-api"
64
description = "Django package for location services"
7-
authors = ["Carl Robben <carl@successmonkey.co.nz>"]
5+
authors = [{ name = "Carl Robben", email = "carl@successmonkey.co.nz" }]
6+
requires-python = ">=3.10,<4"
87
readme = "README.rst"
9-
license = "BSD-3-Clause"
10-
classifiers=[
11-
'Environment :: Web Environment',
12-
'Framework :: Django',
13-
'Framework :: Django :: 4.1',
14-
'Development Status :: 2 - Pre-Alpha',
15-
'Intended Audience :: Developers',
16-
'License :: OSI Approved :: BSD License',
17-
'Natural Language :: English',
18-
'Programming Language :: Python :: 3',
19-
'Programming Language :: Python :: 3 :: Only',
20-
'Programming Language :: Python :: 3.10',
21-
'Programming Language :: Python :: 3.11',
22-
'Programming Language :: Python :: 3.12',
23-
'Topic :: Internet :: WWW/HTTP',
24-
'Topic :: Internet :: WWW/HTTP :: Dynamic Content'
8+
license = "BSD-3-Clause"
9+
classifiers = [
10+
"Environment :: Web Environment",
11+
"Framework :: Django",
12+
"Framework :: Django :: 4.1",
13+
"Development Status :: 2 - Pre-Alpha",
14+
"Intended Audience :: Developers",
15+
"License :: OSI Approved :: BSD License",
16+
"Natural Language :: English",
17+
"Programming Language :: Python :: 3",
18+
"Programming Language :: Python :: 3 :: Only",
19+
"Programming Language :: Python :: 3.10",
20+
"Programming Language :: Python :: 3.11",
21+
"Programming Language :: Python :: 3.12",
22+
"Topic :: Internet :: WWW/HTTP",
23+
"Topic :: Internet :: WWW/HTTP :: Dynamic Content",
2524
]
26-
packages = [
27-
{ include = "location_api" },
28-
{ include = "tests", format = "sdist" },
25+
dependencies = [
26+
"django~=4.2",
27+
"djangorestframework>=3.14.0,<4",
28+
"djangorestframework-gis~=1.0",
29+
"django-filter~=24.3",
2930
]
3031

31-
[tool.poetry.dependencies]
32-
python = ">=3.10,<4"
33-
django = "^4.2"
34-
djangorestframework = "^3.14.0"
35-
djangorestframework-gis = "^1.0"
36-
django-filter = "^24.3"
32+
[project.urls]
33+
Homepage = "https://github.com/carlosfunk/django-location-api"
3734

38-
[tool.poetry.group.dev.dependencies]
39-
bumpversion = "*"
40-
coverage = "*"
41-
flake8 = "*"
42-
invoke = "*"
43-
isort = "*"
44-
pylint = "*"
45-
sphinx = ">=5.3.0"
46-
black = "*"
47-
faker = "^18.4.0"
48-
factory-boy = "^3.2.1"
49-
django-environ = "^0.8.1"
50-
psycopg2-binary = "^2.9.6"
35+
[tool.uv]
36+
package = true
37+
dev-dependencies = [
38+
"bumpversion",
39+
"coverage",
40+
"flake8",
41+
"invoke",
42+
"isort",
43+
"pylint",
44+
"sphinx>=5.3.0",
45+
"black",
46+
"faker>=18.4.0,<19",
47+
"factory-boy>=3.2.1,<4",
48+
"django-environ>=0.8.1,<0.9",
49+
"psycopg2-binary>=2.9.6,<3",
50+
]
51+
52+
[tool.hatch.build.targets.sdist]
53+
include = [
54+
"location_api",
55+
"tests",
56+
]
57+
58+
[tool.hatch.build.targets.wheel]
59+
include = ["location_api"]
5160

5261
[build-system]
53-
requires = ["poetry-core"]
54-
build-backend = "poetry.core.masonry.api"
62+
requires = ["hatchling"]
63+
build-backend = "hatchling.build"
5564

5665
[tool.isort]
57-
profile = "black"
66+
profile = "black"

tasks.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,12 +166,12 @@ def build(c):
166166
"""
167167
Build source and wheel packages
168168
"""
169-
_run(c, "poetry build")
169+
_run(c, "uv build")
170170

171171

172172
@task(pre=[clean, build])
173173
def release(c):
174174
"""
175175
Make a release of the python package to pypi
176176
"""
177-
_run(c, "poetry publish")
177+
_run(c, "uv publish")

0 commit comments

Comments
 (0)