Skip to content

Commit 254e5c0

Browse files
authored
Merge pull request #92 from geotribu/chore/migrate-from-poetry-to-uv
chore: migrate from poetry to uv
2 parents 97efd33 + 1f7fad8 commit 254e5c0

File tree

13 files changed

+2319
-3100
lines changed

13 files changed

+2319
-3100
lines changed

.github/dependabot.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
version: 2
22
updates:
3-
- package-ecosystem: poetry
3+
- package-ecosystem: "uv"
44
directory: "/"
55
schedule:
66
interval: monthly

.github/labeler.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ dependencies:
66
- changed-files:
77
- any-glob-to-any-file:
88
- pyproject.toml
9-
- poetry.lock
9+
- uv.lock
1010

1111
documentation:
1212
- changed-files:

.github/workflows/lint.yml

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,27 +38,21 @@ jobs:
3838
with:
3939
python-version: ${{ env.PYTHON_VERSION }}
4040
cache: "pip"
41-
cache-dependency-path: "poetry.lock"
41+
cache-dependency-path: "uv.lock"
4242

43-
- name: Install poetry
44-
uses: snok/install-poetry@v1
45-
with:
46-
version: 2.1.3
47-
virtualenvs-create: true
48-
virtualenvs-in-project: true
49-
virtualenvs-path: ~/.venv
50-
installer-parallel: true
43+
- name: Install uv
44+
uses: astral-sh/setup-uv@v7
5145

5246
- name: Install requirements
53-
run: poetry install
47+
run: uv sync
5448

5549
- name: Check black lint
56-
run: poetry run black --check --diff ./gischat
50+
run: uv run black --check --diff ./gischat
5751

5852
- name: Check isort lint
59-
run: poetry run isort --check --profile=black ./gischat
53+
run: uv run isort --check --profile=black ./gischat
6054

6155
- name: Lint with flake8
6256
run: |
63-
poetry run flake8 gischat --count --select=E9,F63,F7,F82 --show-source --statistics
64-
poetry run flake8 gischat --count --exit-zero --statistics
57+
uv run flake8 gischat --count --select=E9,F63,F7,F82 --show-source --statistics
58+
uv run flake8 gischat --count --exit-zero --statistics

.github/workflows/tests.yml

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ on:
1515
- "**/*.py"
1616
- ".github/workflows/tests.yml"
1717
- "pyproject.toml"
18-
- "poetry.lock"
18+
- "uv.lock"
1919

2020
jobs:
2121

@@ -49,27 +49,21 @@ jobs:
4949
with:
5050
python-version: ${{ matrix.python-version }}
5151
cache: "pip"
52-
cache-dependency-path: "poetry.lock"
52+
cache-dependency-path: "uv.lock"
5353

54-
- name: Install poetry
55-
uses: snok/install-poetry@v1
56-
with:
57-
version: 2.1.3
58-
virtualenvs-create: true
59-
virtualenvs-in-project: true
60-
virtualenvs-path: ~/.venv
61-
installer-parallel: true
54+
- name: Install uv
55+
uses: astral-sh/setup-uv@v7
6256

6357
- name: Install requirements
64-
run: poetry install
58+
run: uv sync
6559

6660
- name: Set up Redis
6761
uses: shogo82148/actions-setup-redis@v1
6862
with:
69-
redis-version: "7.4"
63+
redis-version: "8"
7064

7165
- name: Unit tests
72-
run: poetry run pytest -v --cov --cov-report xml:coverage.xml
66+
run: uv run pytest -v --cov --cov-report xml:coverage.xml
7367

7468
- name: Upload coverage to Codecov
7569
uses: codecov/[email protected]

Dockerfile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM python:3.11-alpine AS python-base
1+
FROM python:3.12-alpine AS python-base
22
LABEL org.opencontainers.image.source="https://github.com/geotribu/gischat"
33
LABEL maintainer="Guilhem Allaman <[email protected]>"
44

@@ -11,17 +11,17 @@ ARG PIP_NO_CACHE_DIR 1
1111
WORKDIR /gischat
1212

1313
COPY pyproject.toml /gischat/pyproject.toml
14-
COPY poetry.lock /gischat/poetry.lock
14+
COPY uv.lock /gischat/uv.lock
1515
COPY log_config.yaml /gischat/log_config.yaml
1616
COPY entrypoint.sh /gischat/entrypoint.sh
1717
COPY README.md /gischat/README.md
1818

1919
COPY gischat /gischat/gischat
2020

2121
RUN chmod +x entrypoint.sh \
22-
&& pip install poetry
22+
&& pip install uv
2323

24-
RUN poetry install
24+
RUN uv sync
2525

2626
EXPOSE 8000
2727

README.md

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -352,10 +352,10 @@ That's it, you should be able to chat now with your fellow GIS mates !
352352
353353
## Development
354354
355-
1. Install [poetry](https://python-poetry.org/):
355+
1. Install [uv](https://github.com/astral-sh/uv):
356356
357357
```sh
358-
python -m pip install poetry
358+
python -m pip install uv
359359
```
360360
361361
1. Install [`redis`](https://redis.io/) on your local machine:
@@ -364,16 +364,16 @@ That's it, you should be able to chat now with your fellow GIS mates !
364364
sudo apt install redis-server
365365
```
366366
367-
1. Install project's dependencies using poetry:
367+
1. Install project's dependencies using `uv`:
368368

369369
```sh
370-
poetry install
370+
uv sync
371371
```
372372

373373
1. Install pre-commit tools:
374374

375375
```sh
376-
poetry run pre-commit install
376+
uv run pre-commit install
377377
```
378378

379379
1. Create local environment file and edit it:
@@ -385,7 +385,7 @@ That's it, you should be able to chat now with your fellow GIS mates !
385385
1. Launch API:
386386

387387
```sh
388-
poetry run uvicorn gischat.app:app --reload --env-file .env --log-config=log_config.yaml
388+
uv run uvicorn gischat.app:app --reload --env-file .env --log-config=log_config.yaml
389389
```
390390

391391
## Build
@@ -404,14 +404,8 @@ That's it, you should be able to chat now with your fellow GIS mates !
404404

405405
## Testing
406406

407-
1. Install dev dependencies:
408-
409-
```sh
410-
poetry install --with=dev
411-
```
412-
413407
1. Run unit tests:
414408

415409
```sh
416-
poetry run pytest tests
410+
uv run pytest tests
417411
```

entrypoint.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
WORKERS=${NB_UVICORN_WORKERS:-1}
44

5-
exec poetry run uvicorn gischat.app:app \
5+
exec uv run uvicorn gischat.app:app \
66
--host 0.0.0.0 \
77
--port 8000 \
88
--proxy-headers \

gischat/app.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
StatusModel,
5252
VersionModel,
5353
)
54-
from gischat.utils import QCHAT_CHEATCODES, get_poetry_version
54+
from gischat.utils import QCHAT_CHEATCODES, get_uv_version
5555

5656
# initialize sentry
5757
if os.getenv("SENTRY_DSN", None):
@@ -102,7 +102,7 @@ async def lifespan(app: FastAPI):
102102
app = FastAPI(
103103
title="gischat API",
104104
summary="Chat with your GIS tribe in QGIS, GIS mobile apps and other clients !",
105-
version=get_poetry_version(),
105+
version=get_uv_version(),
106106
lifespan=lifespan,
107107
)
108108

@@ -146,7 +146,7 @@ async def get_qchat_web_page(request: Request):
146146

147147
@app.get("/version", response_model=VersionModel)
148148
async def get_version() -> VersionModel:
149-
return VersionModel(version=get_poetry_version())
149+
return VersionModel(version=get_uv_version())
150150

151151

152152
QFIELD_PLUGIN_LATEST_DOWNLOAD_URL = "https://github.com/geotribu/qchat-qfield-plugin/releases/latest/download/qfchat-latest.zip"

gischat/utils.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,14 @@
55
QCHAT_CHEATCODES = ["givemesomecheese", "iamarobot", "its10oclock", "qgisprolicense"]
66

77

8-
def get_poetry_version() -> str:
8+
def get_uv_version() -> str:
99
v = "unknown"
1010
pyproject_toml_file = Path(__file__).parent.parent / "pyproject.toml"
11+
1112
if pyproject_toml_file.exists() and pyproject_toml_file.is_file():
1213
data = toml.load(pyproject_toml_file)
13-
# check tool.poetry.version
14-
if (
15-
"tool" in data
16-
and "poetry" in data["tool"]
17-
and "version" in data["tool"]["poetry"]
18-
):
19-
v = data["tool"]["poetry"]["version"]
14+
15+
if "project" in data and "version" in data["project"]:
16+
v = data["project"]["version"]
17+
2018
return v

0 commit comments

Comments
 (0)