Skip to content

Commit 0a404be

Browse files
committed
switch to UV
1 parent 329b722 commit 0a404be

File tree

8 files changed

+2279
-82
lines changed

8 files changed

+2279
-82
lines changed

.github/workflows/ci.yml

Lines changed: 56 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -8,36 +8,33 @@ on:
88
- '*'
99
pull_request:
1010
env:
11-
LATEST_PY_VERSION: '3.13'
11+
LATEST_PY_VERSION: '3.14'
1212

1313
jobs:
1414
tests:
1515
runs-on: ubuntu-latest
1616
strategy:
1717
matrix:
18-
python-version:
19-
- '3.11'
20-
- '3.12'
21-
- '3.13'
22-
# - '3.14.0-alpha.2' wait for pyproj and rasterio wheels to support 3.14
18+
python-version: ['3.11', '3.12', '3.13', '3.14']
2319

2420
steps:
2521
- uses: actions/checkout@v5
26-
- name: Set up Python ${{ matrix.python-version }}
27-
uses: actions/setup-python@v5
22+
23+
- name: Install uv
24+
uses: astral-sh/setup-uv@v7
2825
with:
26+
version: "0.9.*"
27+
enable-cache: true
2928
python-version: ${{ matrix.python-version }}
3029

3130
- name: Install dependencies
3231
run: |
33-
python -m pip install --upgrade pip
34-
python -m pip install .["test"]
32+
uv sync
3533
36-
- name: run pre-commit
34+
- name: Run pre-commit
3735
if: ${{ matrix.python-version == env.LATEST_PY_VERSION }}
3836
run: |
39-
python -m pip install pre-commit
40-
pre-commit run --all-files
37+
uv run pre-commit run --all-files
4138
4239
- name: Run tests
4340
run: python -m pytest --cov morecantile --cov-report term-missing --cov-report xml
@@ -51,24 +48,50 @@ jobs:
5148
fail_ci_if_error: false
5249
token: ${{ secrets.CODECOV_TOKEN }}
5350

51+
# We need two set of tests because rasterio wheels are not availble for python 3.14 yet
52+
tests-rasterio:
53+
runs-on: ubuntu-latest
54+
strategy:
55+
matrix:
56+
python-version: ['3.11', '3.12', '3.13']
57+
58+
steps:
59+
- uses: actions/checkout@v5
60+
61+
- name: Install uv
62+
uses: astral-sh/setup-uv@v7
63+
with:
64+
version: "0.9.*"
65+
enable-cache: true
66+
python-version: ${{ matrix.python-version }}
67+
68+
- name: Install dependencies
69+
run: |
70+
uv sync --extra rasterio
71+
72+
- name: Run tests
73+
run: python -m pytest --cov morecantile --cov-report term-missing --cov-report xml
74+
5475
benchmark:
55-
needs: [tests]
76+
needs: [tests, tests-rasterio]
5677
runs-on: ubuntu-latest
5778
steps:
5879
- uses: actions/checkout@v5
59-
- name: Set up Python
60-
uses: actions/setup-python@v5
80+
81+
- name: Install uv
82+
uses: astral-sh/setup-uv@v7
6183
with:
62-
python-version: '3.13'
84+
version: "0.9.*"
85+
enable-cache: true
86+
python-version: ${{ env.LATEST_PY_VERSION }}
6387

6488
- name: Install dependencies
6589
run: |
66-
python -m pip install --upgrade pip
67-
python -m pip install -e ".[benchmark]"
90+
uv sync --group benchmark
6891
6992
- name: Run Benchmark
7093
run: |
71-
python -m pytest tests/benchmarks.py --benchmark-only --benchmark-columns 'min, max, mean, median' --benchmark-sort 'min' --benchmark-json output.json
94+
uv run pytest tests/benchmarks.py --benchmark-only --benchmark-columns 'min, max, mean, median' --benchmark-sort 'min' --benchmark-json output.json
7295
7396
- name: Store and Compare benchmark result
7497
uses: benchmark-action/github-action-benchmark@v1
@@ -87,21 +110,22 @@ jobs:
87110
benchmark-data-dir-path: dev/benchmarks
88111

89112
publish:
90-
needs: [tests]
113+
needs: [tests, tests-rasterio]
91114
runs-on: ubuntu-latest
92115
if: startsWith(github.event.ref, 'refs/tags') || github.event_name == 'release'
93116
steps:
94117
- uses: actions/checkout@v5
95-
- name: Set up Python
96-
uses: actions/setup-python@v5
118+
119+
- name: Install uv
120+
uses: astral-sh/setup-uv@v7
97121
with:
122+
version: "0.9.*"
123+
enable-cache: true
98124
python-version: ${{ env.LATEST_PY_VERSION }}
99125

100126
- name: Install dependencies
101127
run: |
102-
python -m pip install --upgrade pip
103-
python -m pip install flit
104-
python -m pip install .
128+
uv sync --group deploy
105129
106130
- name: Set tag version
107131
id: tag
@@ -112,11 +136,13 @@ jobs:
112136
- name: Set module version
113137
id: module
114138
run: |
115-
echo version=$(python -c'import morecantile; print(morecantile.__version__)') >> $GITHUB_OUTPUT
139+
echo "version=$(uv run hatch --quiet version)" >> $GITHUB_OUTPUT
116140
117141
- name: Build and publish
118142
if: ${{ steps.tag.outputs.version }} == ${{ steps.module.outputs.version}}
119143
env:
120-
FLIT_USERNAME: ${{ secrets.PYPI_USERNAME }}
121-
FLIT_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
122-
run: flit publish
144+
HATCH_INDEX_USER: ${{ secrets.PYPI_USERNAME }}
145+
HATCH_INDEX_AUTH: ${{ secrets.PYPI_PASSWORD }}
146+
run: |
147+
uv run hatch build
148+
uv run hatch publish

.github/workflows/deploy_mkdocs.yml

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,11 @@ jobs:
1919
- name: Checkout main
2020
uses: actions/checkout@v5
2121

22-
- name: Set up Python 3.13
23-
uses: actions/setup-python@v5
22+
- name: Install uv
23+
uses: astral-sh/setup-uv@v7
2424
with:
25-
python-version: 3.13
26-
27-
- name: Install dependencies
28-
run: |
29-
python -m pip install --upgrade pip
30-
python -m pip install numpy
31-
python -m pip install .["docs"]
25+
version: "0.9.*"
26+
enable-cache: true
3227

3328
- name: Deploy docs
34-
run: mkdocs gh-deploy --force -f docs/mkdocs.yml
29+
run: uv run --group docs mkdocs gh-deploy --force -f docs/mkdocs.yml

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/abravalheri/validate-pyproject
3-
rev: v0.12.1
3+
rev: v0.24
44
hooks:
55
- id: validate-pyproject
66

CONTRIBUTING.md

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,52 +2,58 @@
22

33
Issues and pull requests are more than welcome.
44

5+
We recommand using [`uv`](https://docs.astral.sh/uv) as project manager for development.
6+
7+
See https://docs.astral.sh/uv/getting-started/installation/ for installation
8+
59
**dev install**
610

711
```bash
8-
$ git clone https://github.com/developmentseed/morecantile.git
9-
$ cd morecantile
10-
$ python -m pip install -e .["dev"]
12+
git clone https://github.com/developmentseed/morecantile.git
13+
cd morecantile
14+
15+
uv sync --extra rasterio
1116
```
1217

1318
You can then run the tests with the following command:
1419

1520
```sh
16-
python -m pytest --cov morecantile --cov-report term-missing -s -vv
21+
uv run pytest --cov morecantile --cov-report term-missing -s -vv
1722
```
1823

1924
### pre-commit
2025

2126
This repo is set to use `pre-commit` to run *isort*, *flake8*, *pydocstring*, *black* ("uncompromising Python code formatter") and mypy when committing new code.
2227

2328
```bash
24-
$ pre-commit install
29+
uv run pre-commit install
2530
```
2631

2732
##### Performance tests
2833

2934
```sh
30-
python -m pip install -e ".[benchmark]"
31-
python -m pytest tests/benchmarks.py --benchmark-only --benchmark-columns 'min, max, mean, median' --benchmark-sort 'min'
35+
uv sync --group benchmark
36+
uv run pytest tests/benchmarks.py --benchmark-only --benchmark-columns 'min, max, mean, median' --benchmark-sort 'min'
3237
```
3338

3439
### Docs
3540

3641
```bash
37-
$ git clone https://github.com/developmentseed/morecantile.git
38-
$ cd morecantile
39-
$ python -m pip install -e .["docs"]
42+
git clone https://github.com/developmentseed/morecantile.git
43+
cd morecantile
44+
45+
uv sync --group docs
4046
```
4147

4248
Hot-reloading docs:
4349

4450
```bash
45-
$ mkdocs serve -f docs/mkdocs.yml
51+
uv run mkdocs serve -f docs/mkdocs.yml
4652
```
4753

4854
To manually deploy docs (note you should never need to do this because Github
4955
Actions deploys automatically for new commits.):
5056

5157
```bash
52-
$ mkdocs gh-deploy -f docs/mkdocs.yml
53-
```
58+
uv run mkdocs gh-deploy -f docs/mkdocs.yml
59+
```

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,12 @@ Morecantile is like [mercantile](https://github.com/mapbox/mercantile) (the best
4444
## Install
4545

4646
```bash
47-
$ python -m pip install -U pip
48-
$ python -m pip install morecantile
47+
python -m pip install -U pip
48+
python -m pip install morecantile
4949

5050
# Or install from source:
51-
$ python -m pip install -U pip
52-
$ python -m pip install git+https://github.com/developmentseed/morecantile.git
51+
python -m pip install -U pip
52+
python -m pip install git+https://github.com/developmentseed/morecantile.git
5353
```
5454

5555
## Usage

pyproject.toml

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ classifiers = [
1515
"Programming Language :: Python :: 3.11",
1616
"Programming Language :: Python :: 3.12",
1717
"Programming Language :: Python :: 3.13",
18+
"Programming Language :: Python :: 3.14",
1819
"Topic :: Scientific/Engineering :: GIS",
1920
]
2021
dynamic = ["version"]
@@ -29,22 +30,18 @@ dependencies = [
2930
rasterio = [
3031
"rasterio>=1.2.1",
3132
]
32-
test = [
33+
34+
[dependency-groups]
35+
dev = [
3336
"mercantile",
3437
"pytest",
3538
"pytest-cov",
36-
"rasterio>=1.2.1",
3739
# ref: https://github.com/pallets/click/issues/2939
3840
"click!=8.2.1,!=8.2.2",
39-
]
40-
benchmark = [
41-
"pytest",
42-
"pytest-benchmark",
43-
]
44-
dev = [
4541
"pre-commit",
4642
"bump-my-version",
4743
]
44+
4845
docs = [
4946
"mkdocs>=1.4.3",
5047
"mkdocs-material[imaging]>=9.5",
@@ -53,6 +50,14 @@ docs = [
5350
"pygments",
5451
]
5552

53+
benchmark = [
54+
"pytest-benchmark",
55+
]
56+
57+
deploy = [
58+
"hatch",
59+
]
60+
5661
[project.urls]
5762
Source = "https://github.com/developmentseed/morecantile"
5863
Documentation = "https://developmentseed.org/morecantile/"
@@ -61,20 +66,17 @@ Documentation = "https://developmentseed.org/morecantile/"
6166
morecantile = "morecantile.scripts.cli:cli"
6267

6368
[build-system]
64-
requires = ["flit_core>=3.2,<4"]
65-
build-backend = "flit_core.buildapi"
69+
requires = ["hatchling"]
70+
build-backend = "hatchling.build"
6671

67-
[tool.flit.module]
68-
name = "morecantile"
72+
[tool.hatch.version]
73+
path = "morecantile/__init__.py"
6974

70-
[tool.flit.sdist]
71-
exclude = [
72-
"tests/",
73-
"docs/",
74-
".github/",
75-
"CHANGES.md",
76-
"CONTRIBUTING.md",
77-
]
75+
[tool.hatch.build.targets.sdist]
76+
only-include = ["morecantile/"]
77+
78+
[tool.hatch.build.targets.wheel]
79+
only-include = ["morecantile/"]
7880

7981
[tool.coverage.run]
8082
branch = true
@@ -114,7 +116,6 @@ ignore = [
114116
[tool.ruff.lint.per-file-ignores]
115117
"tests/*.py" = ["D1"]
116118

117-
118119
[tool.pytest.ini_options]
119120
filterwarnings = [
120121
"ignore:You will likely lose important projection*:UserWarning",

tests/test_models.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import pyproj
99
import pytest
1010
from pydantic import ValidationError
11-
from rasterio.crs import CRS as rioCRS
1211

1312
import morecantile
1413
from morecantile.commons import Tile
@@ -405,7 +404,6 @@ def test_mars_tms_construction():
405404
matrix_scale=[2, 1],
406405
)
407406
assert "4326" not in mars_tms.geographic_crs.to_wkt()
408-
assert "4326" not in mars_tms.rasterio_geographic_crs.to_wkt()
409407
assert mars_tms.xy_bbox.left == pytest.approx(-180.0)
410408
assert mars_tms.xy_bbox.bottom == pytest.approx(-90.0)
411409
assert mars_tms.xy_bbox.right == pytest.approx(180.0)
@@ -427,7 +425,6 @@ def test_mars_web_mercator_long_lat():
427425
id="MarsWebMercator",
428426
)
429427
assert "4326" not in mars_tms_wm.geographic_crs.to_wkt()
430-
assert "4326" not in mars_tms_wm.rasterio_geographic_crs.to_wkt()
431428
assert mars_tms_wm.bbox.left == pytest.approx(-180.0)
432429
assert mars_tms_wm.bbox.bottom == pytest.approx(-85.0511287)
433430
assert mars_tms_wm.bbox.right == pytest.approx(180.0)
@@ -549,6 +546,10 @@ def test_crs_uris_for_defaults(tilematrixset):
549546

550547
def test_rasterio_crs():
551548
"""Check rasterio CRS methods."""
549+
_ = pytest.importorskip("rasterio")
550+
551+
from rasterio.crs import CRS as rioCRS
552+
552553
tms = morecantile.tms.get("WebMercatorQuad")
553554
assert isinstance(tms.rasterio_crs, rioCRS)
554555
assert isinstance(tms.rasterio_geographic_crs, rioCRS)

0 commit comments

Comments
 (0)