Skip to content

Commit a383f27

Browse files
switch to uv and pyproject.toml (#855)
* switch to uv and pyproject.toml * refactor docs * use uvx * remove strict * update python version * use dependency-groups more, upgrade setup-uv action * fix publish * limit fastapi to <0.118.0 * add uv installation note --------- Co-authored-by: hrodmn <[email protected]>
1 parent 2c1182b commit a383f27

File tree

23 files changed

+3593
-333
lines changed

23 files changed

+3593
-333
lines changed

.github/workflows/cicd.yaml

Lines changed: 39 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -5,53 +5,59 @@ on:
55
pull_request:
66
branches: [main]
77

8+
env:
9+
LATEST_PY_VERSION: '3.14'
10+
811
jobs:
912
test:
1013
runs-on: ubuntu-latest
1114
strategy:
1215
matrix:
13-
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
16+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
1417
timeout-minutes: 20
1518

1619
steps:
1720
- name: Check out repository code
1821
uses: actions/checkout@v5
19-
20-
# Setup Python (faster than using Python container)
21-
- name: Setup Python
22-
uses: actions/setup-python@v6
22+
23+
- name: Install uv
24+
uses: astral-sh/setup-uv@v7
2325
with:
24-
python-version: ${{ matrix.python-version }}
25-
26-
- name: Lint code
27-
if: ${{ matrix.python-version == 3.13 }}
28-
run: |
29-
python -m pip install pre-commit
30-
pre-commit run --all-files
26+
version: "0.9.*"
27+
enable-cache: true
28+
29+
- name: Set up Python ${{ matrix.python-version }}
30+
run: uv python install ${{ matrix.python-version }}
3131

32-
- name: Install types
32+
- name: Install dependencies
3333
run: |
34-
python -m pip install ./stac_fastapi/types[dev]
34+
uv sync
3535
36-
- name: Install core api
37-
run: |
38-
python -m pip install ./stac_fastapi/api[dev]
39-
40-
- name: Install Extensions
36+
- name: Lint code
37+
if: ${{ matrix.python-version == env.LATEST_PY_VERSION }}
4138
run: |
42-
python -m pip install ./stac_fastapi/extensions[dev]
39+
uv run pre-commit run --all-files
4340
44-
- name: Test
45-
run: python -m pytest -svvv
41+
- name: Run tests
42+
run: uv run pytest -svvv
4643
env:
4744
ENVIRONMENT: testing
4845

4946
test-docs:
5047
runs-on: ubuntu-latest
5148
steps:
52-
- uses: actions/checkout@v5
53-
- name: Test generating docs
54-
run: make docs
49+
- name: Checkout main
50+
uses: actions/checkout@v5
51+
52+
- name: Install uv
53+
uses: astral-sh/setup-uv@v7
54+
with:
55+
version: "0.9.*"
56+
enable-cache: true
57+
58+
- name: Test docs
59+
run: |
60+
uv run --group docs mkdocs build -f docs/mkdocs.yml
5561
5662
benchmark:
5763
needs: [test]
@@ -60,25 +66,18 @@ jobs:
6066
- name: Check out repository code
6167
uses: actions/checkout@v5
6268

63-
- name: Setup Python
64-
uses: actions/setup-python@v6
69+
- name: Install uv
70+
uses: astral-sh/setup-uv@v7
6571
with:
66-
python-version: "3.13"
67-
68-
- name: Install types
69-
run: |
70-
python -m pip install ./stac_fastapi/types[dev]
71-
72-
- name: Install core api
73-
run: |
74-
python -m pip install ./stac_fastapi/api[dev,benchmark]
75-
76-
- name: Install extensions
72+
version: "0.9.*"
73+
enable-cache: true
74+
75+
- name: Install dependencies
7776
run: |
78-
python -m pip install ./stac_fastapi/extensions
77+
uv sync
7978
8079
- name: Run Benchmark
81-
run: python -m pytest stac_fastapi/api/tests/benchmarks.py --benchmark-only --benchmark-columns 'min, max, mean, median' --benchmark-json output.json
80+
run: uv run pytest stac_fastapi/api/tests/benchmarks.py --benchmark-only --benchmark-columns 'min, max, mean, median' --benchmark-json output.json
8281

8382
- name: Store and benchmark result
8483
if: github.repository == 'stac-utils/stac-fastapi'

.github/workflows/deploy_mkdocs.yml

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,11 @@ jobs:
2020
- name: Checkout main
2121
uses: actions/checkout@v5
2222

23-
- name: Set up Python 3.11
24-
uses: actions/setup-python@v6
23+
- name: Install uv
24+
uses: astral-sh/setup-uv@v7
2525
with:
26-
python-version: 3.11
27-
28-
- name: Install dependencies
29-
run: |
30-
python -m pip install --upgrade pip
31-
python -m pip install \
32-
stac_fastapi/types[docs] \
33-
stac_fastapi/api[docs] \
34-
stac_fastapi/extensions[docs] \
35-
26+
version: "0.9.*"
27+
enable-cache: true
28+
3629
- name: Deploy docs
37-
run: mkdocs gh-deploy --force -f docs/mkdocs.yml
30+
run: uv run --group docs mkdocs gh-deploy --force -f docs/mkdocs.yml

.github/workflows/publish.yml

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,15 @@ jobs:
1212
steps:
1313
- uses: actions/checkout@v5
1414

15-
- name: Set up Python 3.x
16-
uses: actions/setup-python@v6
15+
- name: Install uv
16+
uses: astral-sh/setup-uv@v7
1717
with:
18-
python-version: "3.x"
19-
20-
- name: Install release dependencies
21-
run: |
22-
python -m pip install --upgrade pip
23-
pip install setuptools wheel twine
24-
18+
version: "0.9.*"
19+
enable-cache: true
20+
2521
- name: Build and publish package
2622
env:
27-
TWINE_USERNAME: ${{ secrets.PYPI_STACUTILS_USERNAME }}
28-
TWINE_PASSWORD: ${{ secrets.PYPI_STACUTILS_PASSWORD }}
23+
UV_PUBLISH_USERNAME: ${{ secrets.PYPI_STACUTILS_USERNAME }}
24+
UV_PUBLISH_PASSWORD: ${{ secrets.PYPI_STACUTILS_PASSWORD }}
2925
run: |
3026
scripts/publish

CHANGES.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
## [Unreleased]
44

5+
### Changed
6+
7+
- switch to pyproject.toml for package metadata
8+
- use `uv` for project managment
9+
- add python 3.14 support
10+
511
## [6.0.0] - 2025-06-19
612

713
### Changed

CONTRIBUTING.md

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,40 +2,48 @@
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
812
git clone https://github.com/stac-utils/stac-fastapi.git
913
cd stac-fastapi
10-
python -m pip install -e stac_fastapi/api[dev]
14+
uv sync --dev
1115
```
1216

1317
**pre-commit**
1418

1519
This repo is set to use `pre-commit` to run *ruff*, *pydocstring* and mypy when committing new code.
1620

1721
```bash
18-
pre-commit install
22+
uv run pre-commit install
23+
24+
# If needed, you can run pre-commit script manually
25+
uv run pre-commit run --all-files
1926
```
2027

2128
### Docs
2229

2330
```bash
2431
git clone https://github.com/stac-utils/stac-fastapi.git
2532
cd stac-fastapi
26-
python pip install -e stac_fastapi/api["docs"]
33+
# Build docs
34+
uv run --group docs mkdocs build -f docs/mkdocs.yml
2735
```
2836

2937
Hot-reloading docs:
3038

3139
```bash
32-
$ mkdocs serve -f docs/mkdocs.yml
40+
uv run --group docs mkdocs serve -f docs/mkdocs.yml --livereload
3341
```
3442

3543
To manually deploy docs (note you should never need to do this because GitHub
3644
Actions deploys automatically for new commits.):
3745

3846
```bash
3947
# deploy
40-
$ mkdocs gh-deploy -f docs/mkdocs.yml
48+
uv run --group docs mkdocs gh-deploy -f docs/mkdocs.yml
4149
```

Dockerfile

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,16 @@
1-
FROM python:3.12-slim AS base
2-
3-
# Any python libraries that require system libraries to be installed will likely
4-
# need the following packages in order to build
5-
RUN apt-get update && \
6-
apt-get -y upgrade && \
7-
apt-get install -y build-essential git && \
8-
apt-get clean && \
9-
rm -rf /var/lib/apt/lists/*
10-
11-
ENV CURL_CA_BUNDLE=/etc/ssl/certs/ca-certificates.crt
12-
13-
FROM base AS builder
1+
FROM ghcr.io/astral-sh/uv:python3.14-bookworm-slim
142

153
WORKDIR /app
164

5+
RUN apt-get update && apt-get install -y gcc
176
COPY . /app
187

19-
RUN python -m pip install \
20-
-e ./stac_fastapi/types[dev] \
21-
-e ./stac_fastapi/api[dev] \
22-
-e ./stac_fastapi/extensions[dev]
8+
ENV CURL_CA_BUNDLE=/etc/ssl/certs/ca-certificates.crt
9+
ENV UV_COMPILE_BYTECODE=1
10+
ENV UV_LINK_MODE=copy
11+
ENV UV_TOOL_BIN_DIR=/usr/local/bin
12+
RUN --mount=type=cache,target=/root/.cache/uv \
13+
--mount=type=bind,source=uv.lock,target=uv.lock \
14+
uv sync --locked --no-dev
15+
16+
ENV PATH="/app/.venv/bin:$PATH"

Dockerfile.docs

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

Makefile

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,16 @@ image:
44

55
.PHONY: install
66
install:
7-
python -m pip install wheel && \
8-
python -m pip install -e ./stac_fastapi/types[dev] && \
9-
python -m pip install -e ./stac_fastapi/api[dev] && \
10-
python -m pip install -e ./stac_fastapi/extensions[dev]
7+
uv sync --dev
118

12-
.PHONY: docs-image
13-
docs-image:
14-
docker compose -f compose.docs.yml \
15-
build
9+
.PHONY: test
10+
test: install
11+
uv run pytest
1612

1713
.PHONY: docs
18-
docs: docs-image
19-
docker compose -f compose.docs.yml \
20-
run docs
14+
docs:
15+
uv run --group docs mkdocs build -f docs/mkdocs.yml
2116

22-
.PHONY: test
23-
test: image
24-
python -m pytest .
17+
.PHONY: benchmark
18+
benchmark: install
19+
uv run pytest stac_fastapi/api/tests/benchmarks.py --benchmark-only --benchmark-columns 'min, max, mean, median'

README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,17 +77,18 @@ Other backends may be available from other sources, search [PyPI](https://pypi.o
7777

7878
Install the packages in editable mode:
7979

80+
We recommand using [`uv`](https://docs.astral.sh/uv) as project manager for development.
81+
82+
See https://docs.astral.sh/uv/getting-started/installation/ for installation
83+
8084
```shell
81-
python -m pip install \
82-
-e 'stac_fastapi/types[dev]' \
83-
-e 'stac_fastapi/api[dev]' \
84-
-e 'stac_fastapi/extensions[dev]'
85+
uv sync --dev
8586
```
8687

8788
To run the tests:
8889

8990
```shell
90-
python -m pytest
91+
uv run pytest
9192
```
9293

9394
## Releasing

RELEASING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ This is a checklist for releasing a new version of **stac-fastapi**.
88

99
Note: You can use [`bump-my-version`](https://github.com/callowayproject/bump-my-version) CLI
1010
```
11-
bump-my-version bump --new-version 3.1.0
11+
uv run bump-my-version bump --new-version 3.1.0
1212
```
1313
1414
4. Update [CHANGES.md](./CHANGES.md) for the new version. Add the appropriate header, and update the links at the bottom of the file.

0 commit comments

Comments
 (0)