Skip to content

Commit df8d63b

Browse files
Merge pull request #238 from stac-utils/feature/switch-to-uv
switch to UV
2 parents 532fbea + 8313347 commit df8d63b

File tree

8 files changed

+3701
-69
lines changed

8 files changed

+3701
-69
lines changed

.github/workflows/ci.yml

Lines changed: 35 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -22,35 +22,32 @@ jobs:
2222
runs-on: ubuntu-latest
2323
strategy:
2424
matrix:
25-
python-version:
26-
- '3.10'
27-
- '3.11'
28-
- '3.12'
29-
- '3.13'
25+
python-version: ['3.11', '3.12', '3.13']
3026

3127
steps:
3228
- uses: actions/checkout@v5
33-
- name: Set up Python ${{ matrix.python-version }}
34-
uses: actions/setup-python@v6
29+
30+
- name: Install uv
31+
uses: astral-sh/setup-uv@v7
3532
with:
33+
version: "0.9.*"
34+
enable-cache: true
3635
python-version: ${{ matrix.python-version }}
3736

3837
- name: install lib postgres
3938
uses: nyurik/action-setup-postgis@v2
4039

4140
- name: Install dependencies
4241
run: |
43-
python -m pip install --upgrade pip
44-
python -m pip install -e .["test,psycopg"]
42+
uv sync --extra psycopg
4543
4644
- name: Run pre-commit
4745
if: ${{ matrix.python-version == env.LATEST_PY_VERSION }}
4846
run: |
49-
python -m pip install pre-commit
50-
pre-commit run --all-files
47+
uv run pre-commit run --all-files
5148
5249
- name: Run tests
53-
run: python -m pytest --cov titiler.pgstac --cov-report xml --cov-report term-missing --asyncio-mode=strict -s -vv
50+
run: uv run pytest --cov titiler.pgstac --cov-report xml --cov-report term-missing --asyncio-mode=strict -s -vv
5451

5552
- name: Upload Results
5653
if: ${{ matrix.python-version == env.LATEST_PY_VERSION }}
@@ -65,14 +62,21 @@ jobs:
6562
needs: [tests]
6663
runs-on: ubuntu-latest
6764
env:
68-
PGSTAC_VERSION: '0.9.2'
65+
PGSTAC_VERSION: '0.9.8'
6966
steps:
7067
- uses: actions/checkout@v5
7168

72-
- name: Set up Python 3.12
73-
uses: actions/setup-python@v6
69+
- name: Install uv
70+
uses: astral-sh/setup-uv@v7
7471
with:
75-
python-version: '3.12'
72+
version: "0.9.*"
73+
enable-cache: true
74+
python-version: ${{ env.LATEST_PY_VERSION }}
75+
76+
- name: Install dependencies
77+
run: |
78+
uv sync --extra psycopg
79+
uv pip install pypgstac==${{ env.PGSTAC_VERSION }}
7680
7781
- name: Launch services
7882
run: docker compose up -d tiler-uvicorn
@@ -82,23 +86,19 @@ jobs:
8286
- name: install lib postgres
8387
uses: nyurik/action-setup-postgis@v2
8488

85-
- name: Install python dependencies
86-
run: |
87-
python -m pip install pypgstac==${{ env.PGSTAC_VERSION }} psycopg[pool] httpx pytest pytest-benchmark rasterio
88-
8989
- name: Ingest Stac Items/Collection
9090
run: |
91-
pypgstac pgready --dsn postgresql://username:[email protected]:5439/postgis
92-
pypgstac load collections benchmark/stac/collection.json --dsn postgresql://username:[email protected]:5439/postgis --method insert_ignore
93-
pypgstac load items benchmark/stac/items.json --dsn postgresql://username:[email protected]:5439/postgis --method insert_ignore
91+
uv run pypgstac pgready --dsn postgresql://username:[email protected]:5439/postgis
92+
uv run pypgstac load collections benchmark/stac/collection.json --dsn postgresql://username:[email protected]:5439/postgis --method insert_ignore
93+
uv run pypgstac load items benchmark/stac/items.json --dsn postgresql://username:[email protected]:5439/postgis --method insert_ignore
9494
9595
- name: Sleep for 10 seconds
9696
run: sleep 10s
9797
shell: bash
9898

9999
- name: Run Benchmark
100100
run: |
101-
python -m pytest .github/workflows/tests/benchmarks.py --benchmark-only --benchmark-columns 'min, max, mean, median' --benchmark-json output.json
101+
uv run --group benchmark pytest .github/workflows/tests/benchmarks.py --benchmark-only --benchmark-columns 'min, max, mean, median' --benchmark-json output.json
102102
103103
- name: Store and benchmark result
104104
uses: benchmark-action/github-action-benchmark@v1
@@ -124,17 +124,14 @@ jobs:
124124
if: startsWith(github.event.ref, 'refs/tags') || github.event_name == 'release'
125125
steps:
126126
- uses: actions/checkout@v5
127-
- name: Set up Python
128-
uses: actions/setup-python@v6
127+
128+
- name: Install uv
129+
uses: astral-sh/setup-uv@v7
129130
with:
131+
version: "0.9.*"
132+
enable-cache: true
130133
python-version: ${{ env.LATEST_PY_VERSION }}
131134

132-
- name: Install dependencies
133-
run: |
134-
python -m pip install --upgrade pip
135-
python -m pip install wheel twine build
136-
python -m pip install .
137-
138135
- name: Set tag version
139136
id: tag
140137
run: |
@@ -144,17 +141,17 @@ jobs:
144141
- name: Set module version
145142
id: module
146143
run: |
147-
echo version=$(python -c'import titiler.pgstac; print(titiler.pgstac.__version__)') >> $GITHUB_OUTPUT
148-
144+
echo version=$(uv run python -c'import titiler.pgstac; print(titiler.pgstac.__version__)') >> $GITHUB_OUTPUT
145+
149146
- name: Build and publish
150147
if: ${{ steps.tag.outputs.version }} == ${{ steps.module.outputs.version}}
151148
env:
152-
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
153-
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
149+
UV_PUBLISH_USERNAME: ${{ secrets.PYPI_USERNAME }}
150+
UV_PUBLISH_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
154151
run: |
155152
rm -rf dist
156-
python -m build
157-
twine upload dist/*
153+
uv build
154+
uv publish dist/*
158155
159156
publish-docker:
160157
needs: [tests]

.github/workflows/deploy_mkdocs.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@ jobs:
1616
- name: Checkout main
1717
uses: actions/checkout@v5
1818

19-
- name: Set up Python 3.12
20-
uses: actions/setup-python@v6
19+
- name: Install uv
20+
uses: astral-sh/setup-uv@v7
2121
with:
22-
python-version: 3.12
22+
version: "0.9.*"
23+
enable-cache: true
2324

2425
- name: Install dependencies
2526
run: |
@@ -43,3 +44,6 @@ jobs:
4344
- name: Deploy documentation and update alias for latest
4445
run: |
4546
mike deploy ${{ steps.module.outputs.version}} latest --push --update-aliases --config-file docs/mkdocs.yml
47+
48+
- name: Deploy docs
49+
run: uv run --group docs --extra psycopg mike deploy ${{ steps.module.outputs.version}} latest --push --update-aliases --config-file 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: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,27 @@
22

33
Issues and pull requests are more than welcome: https://github.com/stac-utils/titiler-pgstac/issues
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/stac-utils/titiler-pgstac.git
9-
$ cd titiler-pgstac
10-
$ python -m pip install -e ".[dev,test,psycopg]"
12+
git clone https://github.com/stac-utils/titiler-pgstac.git
13+
cd titiler-pgstac
14+
15+
uv sync --extra psycopg
1116
```
1217

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

1520
```sh
16-
python -m pytest --cov titiler.pgstac --cov-report term-missing
21+
uv run pytest --cov titiler.pgstac --cov-report term-missing
1722
```
1823

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

2126
```bash
22-
$ pre-commit install
27+
uv run pre-commit run --all-files
2328
```

README.md

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,20 +34,25 @@ To install from PyPI and run:
3434

3535
```bash
3636
# Make sure to have pip up to date
37-
$ python -m pip install -U pip
37+
python -m pip install -U pip
3838

3939
# Install `psycopg` or `psycopg["binary"]` or `psycopg["c"]`
40-
$ python -m pip install psycopg["binary"]
40+
python -m pip install psycopg["binary"]
4141

42-
$ python -m pip install titiler.pgstac
42+
python -m pip install titiler.pgstac
4343
```
4444

4545
To install from sources and run for development:
4646

47+
We recommand using [`uv`](https://docs.astral.sh/uv) as project manager for development.
48+
49+
See https://docs.astral.sh/uv/getting-started/installation/ for installation
50+
4751
```
48-
$ git clone https://github.com/stac-utils/titiler-pgstac.git
49-
$ cd titiler-pgstac
50-
$ python -m pip install -e .
52+
git clone https://github.com/stac-utils/titiler-pgstac.git
53+
cd titiler-pgstac
54+
55+
uv sync --extra psycopg
5156
```
5257

5358
### `PgSTAC` version

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ services:
7777

7878
database:
7979
container_name: stac-db
80-
image: ghcr.io/stac-utils/pgstac:v${PGSTAC_VERSION-0.9.2}
80+
image: ghcr.io/stac-utils/pgstac:v${PGSTAC_VERSION-0.9.8}
8181
environment:
8282
- POSTGRES_USER=username
8383
- POSTGRES_PASSWORD=password

pyproject.toml

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "titiler-pgstac"
33
description = "Connect PgSTAC and TiTiler."
44
readme = "README.md"
5-
requires-python = ">=3.10"
5+
requires-python = ">=3.11"
66
license = {file = "LICENSE"}
77
authors = [
88
{name = "Vincent Sarago", email = "[email protected]"},
@@ -20,7 +20,6 @@ classifiers = [
2020
"Intended Audience :: Information Technology",
2121
"Intended Audience :: Science/Research",
2222
"License :: OSI Approved :: MIT License",
23-
"Programming Language :: Python :: 3.10",
2423
"Programming Language :: Python :: 3.11",
2524
"Programming Language :: Python :: 3.12",
2625
"Programming Language :: Python :: 3.13",
@@ -54,17 +53,20 @@ telemetry = [
5453
"opentelemetry-instrumentation-logging",
5554
"opentelemetry-exporter-otlp",
5655
]
56+
57+
[dependency-groups]
5758
dev = [
58-
"pre-commit",
59-
"bump-my-version",
60-
]
61-
test = [
6259
"pytest",
6360
"pytest-cov",
6461
"pytest-asyncio",
6562
"httpx",
6663
"pypgstac>=0.7,<=0.10",
6764
"pytest-postgresql",
65+
"pre-commit",
66+
"bump-my-version",
67+
]
68+
benchmark = [
69+
"pytest-benchmark",
6870
]
6971
docs = [
7072
"mkdocs>=1.4.3",
@@ -82,17 +84,18 @@ Issues = "https://github.com/stac-utils/titiler-pgstac/issues"
8284
Source = "https://github.com/stac-utils/titiler-pgstac"
8385
Changelog = "https://stac-utils.github.io/titiler-pgstac/release-notes/"
8486

85-
[build-system]
86-
requires = ["pdm-backend"]
87-
build-backend = "pdm.backend"
88-
89-
[tool.pdm.version]
90-
source = "file"
87+
[tool.hatch.version]
9188
path = "titiler/pgstac/__init__.py"
9289

93-
[tool.pdm.build]
94-
includes = ["titiler/pgstac"]
95-
excludes = ["tests/", "**/.mypy_cache", "**/.DS_Store"]
90+
[tool.hatch.build.targets.sdist]
91+
only-include = ["titiler"]
92+
93+
[tool.hatch.build.targets.wheel]
94+
only-include = ["titiler"]
95+
96+
[build-system]
97+
requires = ["hatchling"]
98+
build-backend = "hatchling.build"
9699

97100
[tool.coverage.run]
98101
branch = true

0 commit comments

Comments
 (0)