Skip to content

Commit

Permalink
chore: Migrate to uv (#52)
Browse files Browse the repository at this point in the history
* 100m grid

* Migrate to uv
  • Loading branch information
ciscorn committed Feb 3, 2025
1 parent d8d7244 commit 5ebe7d9
Show file tree
Hide file tree
Showing 9 changed files with 293 additions and 302 deletions.
25 changes: 10 additions & 15 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,20 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Install poetry
run: python -m pip install poetry

- uses: actions/setup-python@v5
- name: Setup uv
uses: astral-sh/setup-uv@v5
with:
python-version: 3.8
cache: "poetry"
version: "latest"
enable-cache: true

- name: Install dependencies
run: poetry install

- name: Check poetry.lock
run: poetry lock --check
run: uv sync

# - name: pyright
# run: poetry run pyright .
# run: uv run pyright .

- name: Ruff (format)
run: poetry run ruff format --check .
- name: ruff-format
run: uv run ruff format --check .

- name: Ruff (lint)
run: poetry run ruff check --output-format github .
- name: ruff
run: uv run ruff check --output-format github .
17 changes: 11 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
qgis_image_tag: [release-3_28]
qgis_image_tag: [release-3_22, release-3_28]
env:
OS: ubuntu
QGIS_IMAGE_TAG: ${{ matrix.qgis_image_tag }}
Expand All @@ -20,22 +20,27 @@ jobs:
- name: Pull QGIS image
run: docker pull qgis/qgis:${{ matrix.qgis_image_tag }}

- name: Setup uv
uses: astral-sh/setup-uv@v5
with:
version: "latest"
enable-cache: true

- name: Export requirements.txt
run: |
pip3 install poetry
poetry export --with dev -f requirements.txt -o requirements.txt
uv export --extra dev > requirements.txt
- name: Run tests
run: >
docker run --rm --volume `pwd`:/app -w=/app qgis/qgis:${{ matrix.qgis_image_tag }} sh -c "
pip3 install -r requirements.txt &&
pip3 install --require-hashes --no-deps -r requirements.txt &&
PYTHONPATH=/app xvfb-run -s '+extension GLX -screen 0 1024x768x24' pytest -v --cov --cov-report=xml --cov-report=term
"
- name: Upload coverage
uses: codecov/codecov-action@v4
uses: codecov/codecov-action@v5
with:
file: ./coverage.xml
token: ${{ secrets.CODECOV_TOKEN }}
flags: unittests
env_vars: OS,QGIS_IMAGE_TAG
fail_ci_if_error: false
16 changes: 8 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
PACKAGE_NAME = japanese_grids

# Use this Git ref for packaging
# Use this tag for packaging
VERSION = HEAD

# Windows (OSGeo4W)
Expand Down Expand Up @@ -29,13 +29,13 @@ help:

init: ## Startup project
ifeq ($(OS),Windows_NT)
$(QGIS_PYTHON) -m pip install poetry
$(QGIS_PYTHON) -m poetry config --local virtualenvs.in-project true
$(QGIS_PYTHON) -m poetry install
$(QGIS_PYTHON) -m pip install uv
$(QGIS_PYTHON) -m uv venv --python $(QGIS_PYTHON) --system-site-packages
$(QGIS_PYTHON) -m uv sync
$(QGIS_PYTHON) -c "import pathlib;import qgis;open('.venv/Lib/site-packages/qgis.pth', 'w').write(str((pathlib.Path(qgis.__file__)/'../..').resolve()) + '\n' + str((pathlib.Path(qgis.__file__)/'../../plugins').resolve()))"
else
poetry env use $(QGIS_PYTHON)
poetry install
uv venv --python $(QGIS_PYTHON) --system-site-packages
uv sync
echo $(QGIS_STD_PLUGINS) > .venv/lib/python3.9/site-packages/qgis_std_plugins.pth
endif

Expand All @@ -52,7 +52,7 @@ package: ## Build zip package

test: ## Test
ifeq ($(OS),Windows_NT)
$(QGIS_PYTHON) -m poetry run python -c "import os; os.add_dll_directory(r'${QGIS_DLL}'); import pytest; pytest.main('-v --cov --cov-report=term'.split())"
$(QGIS_PYTHON) -m uv run python -c "import os; os.add_dll_directory(r'${QGIS_DLL}'); import pytest; pytest.main('-v --cov --cov-report=term'.split())"
else
poetry run pytest -v --cov --cov-report=term
uv run pytest -v --cov --cov-report=term
endif
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

[![Test](https://github.com/MIERUNE/qgis-japan-mesh/actions/workflows/test.yml/badge.svg)](https://github.com/MIERUNE/qgis-japan-mesh/actions/workflows/test.yml)

A QGIS Plugin to handle common Japanese grid square codes — 日本で使われている「標準地域メッシュ」と「国土基本図図郭」を QGIS で扱うためのプラグインです。
A QGIS Plugin to handle common Japanese grid squares — 日本で使われている「標準地域メッシュ」と「国土基本図図郭」を QGIS で扱うためのプラグインです。

![image](./docs/image.jpeg)

Expand Down Expand Up @@ -45,4 +45,3 @@ make deploy

- Taku Fukada ([@ciscorn](https://github.com/ciscorn)) - Original Author
- And all contributors

2 changes: 1 addition & 1 deletion japanese_grids/algorithms/utils/gridsquare_to_box.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def lnglat_to_grid_square_code(lng: float, lat: float) -> Optional[Codes]:
lat *= 1.5
lat_r = int(lat)
lng_r = int(lng)
primary_code = f"{lat_r:02d}{lng_r-100:02d}"
primary_code = f"{lat_r:02d}{lng_r - 100:02d}"
if primary_code not in AVAILABLE_PRIMARY_CODES:
return None

Expand Down
Loading

0 comments on commit 5ebe7d9

Please sign in to comment.