Skip to content

Commit c051c9f

Browse files
authored
feat: search to an arrow table (#54)
1 parent b7a8893 commit c051c9f

File tree

11 files changed

+366
-68
lines changed

11 files changed

+366
-68
lines changed

.github/workflows/ci.yaml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,12 @@ jobs:
4848
mkdir -p ${{ github.workspace }}/opt/duckdb
4949
unzip libduckdb-${{ matrix.os.duckdb-slug }}.zip -d ${{ github.workspace }}/opt/duckdb
5050
- name: Sync
51-
run: uv sync --no-install-project
52-
- name: Build directly with maturin
53-
run: uv run maturin dev --uv
51+
run: uv sync --all-extras
5452
- name: Lint
5553
run: scripts/lint
5654
- name: Test
5755
run: scripts/test
56+
- name: Sync w/o extras
57+
run: uv sync
58+
- name: Test w/o extras
59+
run: uv run pytest

.github/workflows/pypi.yaml

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ jobs:
1919
runs-on: ubuntu-22.04
2020
strategy:
2121
matrix:
22+
maturin:
23+
- args: "-i 3.10"
24+
name: python-310
25+
- args: "-i 3.11 -F pyo3/abi3-py311"
26+
name: python-311+
2227
platform:
2328
- target: x86_64
2429
manylinux: auto
@@ -29,13 +34,13 @@ jobs:
2934
steps:
3035
- uses: actions/checkout@v4
3136
- uses: astral-sh/setup-uv@v5
32-
- name: Install Pythons
37+
- name: Install Python
3338
run: uv python install 3.10
3439
- name: Build wheels
3540
uses: PyO3/maturin-action@v1
3641
with:
3742
target: ${{ matrix.platform.target }}
38-
args: --release --out dist -i 3.10 --auditwheel repair
43+
args: --release --out dist ${{ matrix.maturin.args }} --auditwheel repair
3944
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
4045
manylinux: ${{ matrix.platform.manylinux }}
4146
before-script-linux: |
@@ -53,13 +58,18 @@ jobs:
5358
- name: Upload wheels
5459
uses: actions/upload-artifact@v4
5560
with:
56-
name: wheels-linux-${{ matrix.platform.target }}
61+
name: wheels-linux-${{ matrix.platform.target }}-${{ matrix.maturin.name }}
5762
path: dist
5863

5964
macos:
6065
runs-on: ${{ matrix.platform.runner }}
6166
strategy:
6267
matrix:
68+
maturin:
69+
- args: "-i 3.10"
70+
name: python-310
71+
- args: "-i 3.11 -F pyo3/abi3-py311"
72+
name: python-311+
6373
platform:
6474
- runner: macos-13
6575
target: x86_64
@@ -87,7 +97,7 @@ jobs:
8797
DUCKDB_LIB_DIR: ${{ github.workspace }}/opt/duckdb
8898
with:
8999
target: ${{ matrix.platform.target }}
90-
args: --release --out dist -i 3.10
100+
args: --release --out dist ${{ matrix.maturin.args }}
91101
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
92102
- name: Repair wheel
93103
run: .venv/bin/delocate-wheel -v dist/*.whl
@@ -96,7 +106,7 @@ jobs:
96106
- name: Upload wheels
97107
uses: actions/upload-artifact@v4
98108
with:
99-
name: wheels-macos-${{ matrix.platform.target }}
109+
name: wheels-macos-${{ matrix.platform.target }}-${{ matrix.maturin.name }}
100110
path: dist
101111

102112
sdist:

Cargo.lock

Lines changed: 82 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@ crate-type = ["cdylib"]
1111
[dependencies]
1212
clap = "4.5.30"
1313
geojson = "0.24.1"
14-
pyo3 = { version = "0.23.4", features = ["abi3-py310", "extension-module"] }
14+
pyo3 = { version = "0.23.4", features = ["extension-module"] }
1515
pyo3-async-runtimes = { version = "0.23.0", features = [
1616
"tokio",
1717
"tokio-runtime",
1818
] }
19+
pyo3-arrow = "0.7.2"
1920
pythonize = "0.23.0"
2021
serde = "1.0.217"
2122
serde_json = "1.0.138"
@@ -27,8 +28,9 @@ stac-api = { features = [
2728
"client",
2829
"python",
2930
], git = "https://github.com/stac-utils/stac-rs" }
30-
stac-cli = { git = "https://github.com/stac-utils/stac-rs", default-features = false, features = [
31+
stac-cli = { git = "https://github.com/stac-utils/stac-rs", features = [
3132
"pgstac",
33+
"duckdb",
3234
] }
3335
stac-duckdb = { git = "https://github.com/stac-utils/stac-rs" }
3436
thiserror = "2.0.11"

README.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ A small no-dependency Python package for [STAC](https://stacspec.org/), using Ru
1111

1212
## Why?
1313

14-
Why make a new STAC Python library, when we already have [PySTAC](https://github.com/stac-utils/pystac)?
15-
Well, we've built some things in [stac-rs](https://github.com/stac-utils/stac-rs) (a collection of STAC Rust libraries) that we want to provide to the Python ecosystem, such as:
14+
Q: We already have [PySTAC](https://github.com/stac-utils/pystac), so why did we make a new STAC Python library?
15+
16+
A: We want to provide a couple of things in [stac-rs](https://github.com/stac-utils/stac-rs) (a collection of STAC Rust libraries) to the Python ecosystem:
1617

1718
- Read, write, and search [stac-geoparquet](https://github.com/stac-utils/stac-geoparquet)
1819
- `async` functions
@@ -24,7 +25,11 @@ If you don't need those things, **stacrs** probably isn't for you — use **pyst
2425
Install via **pip**:
2526

2627
```shell
28+
# basic
2729
python -m pip install stacrs
30+
31+
# add methods to return arrow tables
32+
python -m pip install 'stacrs[arrow]'
2833
```
2934

3035
Or via **conda**:
@@ -47,6 +52,11 @@ items = await stacrs.search(
4752
max_items=100,
4853
)
4954

55+
# If you installed with `pystac[arrow]`:
56+
from geopandas import GeoDataFrame
57+
table = await stacrs.search_to_arrow(...)
58+
data_frame = GeoDataFrame.from_arrow(table)
59+
5060
# Write items to a stac-geoparquet file
5161
await stacrs.write("items.parquet", items)
5262

pyproject.toml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ classifiers = [
2121
]
2222
keywords = ["stac", "geospatial"]
2323
dynamic = ["version"]
24+
dependencies = []
25+
26+
[project.optional-dependencies]
27+
arrow = ["arro3-core>=0.4.5"]
2428

2529
[project.scripts]
2630
stacrs = "stacrs:main"
@@ -34,7 +38,7 @@ Issues = "https://github.com/stac-utils/issues"
3438
files = "**/*.py"
3539

3640
[[tool.mypy.overrides]]
37-
module = "pyarrow.*"
41+
module = ["pyarrow.*", "geopandas.*"]
3842
ignore_missing_imports = true
3943

4044
[tool.pytest.ini_options]
@@ -43,6 +47,7 @@ asyncio_default_fixture_loop_scope = "function"
4347

4448
[dependency-groups]
4549
dev = [
50+
"geopandas>=1.0.1",
4651
"maturin>=1.7.4",
4752
"mypy>=1.11.2",
4853
"pyarrow>=19.0.1",

0 commit comments

Comments
 (0)