Skip to main content

The power of Rust for the Python STAC ecosystem

Project description

rustac

GitHub Workflow Status GitHub Workflow Status PyPI - Version Conda forge PyPI - License Contributor Covenant

The rustac logo

The power of Rust for the Python STAC ecosystem.

[!TIP] We pronounce rustac "ruh-stac".

[!NOTE] Until 2025-04-17, this package was named stacrs. See this RFC for context on the name change.

Why?

Q: We already have PySTAC, so why rustac?

A: rustac can

If you don't need those things, rustac probably isn't for you — use pystac and its friend, pystac-client.

Installation

rustac has zero required dependencies. Install via pip:

# basic
python -m pip install rustac

# support arrow tables
python -m pip install 'rustac[arrow]'

Or via conda:

conda install conda-forge::rustac

From source

You'll need Rust. By default, rustac wants to find DuckDB on your system:

brew install duckdb  # if you're using Homebrew ... if not, get DuckDB another way
python -m pip install -U git+https://github.com/stac-utils/rustac-py

If you don't want to (or can't) install DuckDB, can build DuckDB as a "bundled" build (warning: it takes a while):

MATURIN_PEP517_ARGS="--features=duckdb-bundled" python -m pip install -U git+https://github.com/stac-utils/rustac-py

Usage

import asyncio
import rustac

async def main() -> None:
    # Search a STAC API
    items = await rustac.search(
        "https://landsatlook.usgs.gov/stac-server",
        collections="landsat-c2l2-sr",
        intersects={"type": "Point", "coordinates": [-105.119, 40.173]},
        sortby="-properties.datetime",
        max_items=100,
    )

    # If you installed with `pystac[arrow]`:
    from geopandas import GeoDataFrame

    table = rustac.to_arrow(items)
    data_frame = GeoDataFrame.from_arrow(table)
    items = rustac.from_arrow(data_frame.to_arrow())

    # Write items to a stac-geoparquet file
    await rustac.write("/tmp/items.parquet", items)

    # Read items from a stac-geoparquet file as an item collection
    item_collection = await rustac.read("/tmp/items.parquet")

    # Use `search_to` for better performance if you know you'll be writing the items
    # to a file
    await rustac.search_to(
        "/tmp/items.parquet",
        "https://landsatlook.usgs.gov/stac-server",
        collections="landsat-c2l2-sr",
        intersects={"type": "Point", "coordinates": [-105.119, 40.173]},
        sortby="-properties.datetime",
        max_items=100,
    )

asyncio.run(main())

See the documentation for details. In particular, our examples demonstrate some of the more interesting features.

Command line interface (CLI)

rustac comes with a CLI:

rustac -h

stac-geoparquet

rustac replicates much of the behavior in the stac-geoparquet library, and even uses some of the same Rust dependencies. We believe there are a couple of issues with stac-geoparquet that make rustac a worthy replacement:

  • The stac-geoparquet repo includes Python dependencies
  • It doesn't have a nice one-shot API for reading and writing
  • It includes some leftover code and logic from its genesis as a tool for the Microsoft Planetary Computer

We test to ensure compatibility between the two libraries, and we intend to consolidate to a single "stac-geoparquet" library at some point in the future.

Development

Get Rust, uv, and (optionally) libduckdb. Then:

git clone git@github.com:stac-utils/rustac-py.git
cd rustac-py
scripts/test

See CONTRIBUTING.md for more information about contributing to this project.

DuckDB

By default, this package expects libduckdb to be present on your system. If you get this sort of error when building:

  = note: ld: library 'duckdb' not found

Set your DUCKDB_LIB_DIR to point to your libduckdb. If you're using homebrew, that might look like this:

export DUCKDB_LIB_DIR=/opt/homebrew/lib

Alternatively, you can use the duckdb-bundled feature to build DuckDB bindings into the Rust library:

maturin dev --uv -F duckdb-bundled && pytest

[!WARNING] Building DuckDB bundled takes a long while.

Docs

If you want to run an off-cycle docs update (e.g. if you fixed something and want to post it without having to make a new release):

mike deploy [version] latest --push

Acknowledgements

We'd like to thank @jkeifer, @parksjr, and @Xenocide122 (all from @Element84) for creating the rustac logo from an AI-generated image from this prompt:

There is a library for working with STAC metadata that is written in rust called rustac: https://github.com/stac-utils/rustac. That name sounds like the word "rustic", and is meant to envoke (sic) an image of "a cabin and a glass of neat whisky".

License

rustac-py is dual-licensed under both the MIT license and the Apache license (Version 2.0). See LICENSE-APACHE and LICENSE-MIT for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rustac-0.9.11.tar.gz (746.3 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

rustac-0.9.11-cp311-abi3-win_amd64.whl (26.5 MB view details)

Uploaded CPython 3.11+Windows x86-64

rustac-0.9.11-cp311-abi3-win32.whl (22.9 MB view details)

Uploaded CPython 3.11+Windows x86

rustac-0.9.11-cp311-abi3-musllinux_1_2_x86_64.whl (37.0 MB view details)

Uploaded CPython 3.11+musllinux: musl 1.2+ x86-64

rustac-0.9.11-cp311-abi3-musllinux_1_2_i686.whl (39.3 MB view details)

Uploaded CPython 3.11+musllinux: musl 1.2+ i686

rustac-0.9.11-cp311-abi3-musllinux_1_2_armv7l.whl (34.3 MB view details)

Uploaded CPython 3.11+musllinux: musl 1.2+ ARMv7l

rustac-0.9.11-cp311-abi3-musllinux_1_2_aarch64.whl (34.4 MB view details)

Uploaded CPython 3.11+musllinux: musl 1.2+ ARM64

rustac-0.9.11-cp311-abi3-manylinux_2_28_x86_64.whl (31.2 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.28+ x86-64

rustac-0.9.11-cp311-abi3-manylinux_2_28_ppc64le.whl (34.5 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.28+ ppc64le

rustac-0.9.11-cp311-abi3-manylinux_2_28_armv7l.whl (26.5 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.28+ ARMv7l

rustac-0.9.11-cp311-abi3-manylinux_2_28_aarch64.whl (27.8 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.28+ ARM64

rustac-0.9.11-cp311-abi3-macosx_11_0_arm64.whl (26.0 MB view details)

Uploaded CPython 3.11+macOS 11.0+ ARM64

rustac-0.9.11-cp311-abi3-macosx_10_12_x86_64.whl (27.8 MB view details)

Uploaded CPython 3.11+macOS 10.12+ x86-64

File details

Details for the file rustac-0.9.11.tar.gz.

File metadata

  • Download URL: rustac-0.9.11.tar.gz
  • Upload date:
  • Size: 746.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: maturin/1.13.1

File hashes

Hashes for rustac-0.9.11.tar.gz
Algorithm Hash digest
SHA256 f124c74602fee38e23db15715173d1c7561b321029b393881d577e36f1556cf4
MD5 eefb0df34b03b418131447ecfab5fadb
BLAKE2b-256 00a6bdaedfe610cb82b94e7cbd66ec19658476963f72fa711c6babb167aee9d5

See more details on using hashes here.

File details

Details for the file rustac-0.9.11-cp311-abi3-win_amd64.whl.

File metadata

  • Download URL: rustac-0.9.11-cp311-abi3-win_amd64.whl
  • Upload date:
  • Size: 26.5 MB
  • Tags: CPython 3.11+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: maturin/1.13.1

File hashes

Hashes for rustac-0.9.11-cp311-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 7296ce31158ca657759ab0925004590afc0fe49697c0ea94243f5b9951eb9bac
MD5 4e75ae36e917bce8fa223866b9d94307
BLAKE2b-256 35c52e81b9085dc6ef7e6edc508a01066b2ec0263e5cbdac78ac088ea40c098e

See more details on using hashes here.

File details

Details for the file rustac-0.9.11-cp311-abi3-win32.whl.

File metadata

  • Download URL: rustac-0.9.11-cp311-abi3-win32.whl
  • Upload date:
  • Size: 22.9 MB
  • Tags: CPython 3.11+, Windows x86
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: maturin/1.13.1

File hashes

Hashes for rustac-0.9.11-cp311-abi3-win32.whl
Algorithm Hash digest
SHA256 b68bc535af00ac655c22fec160ec4b6432a7410dc8c74ebfca5cb1a35b74afe6
MD5 d0673a23275f65aee1b9c0c38f9b36a4
BLAKE2b-256 78fb4c565c6236fec63694eeec9d23b5bd8198c18c4aa0b6c9b0d58259165c99

See more details on using hashes here.

File details

Details for the file rustac-0.9.11-cp311-abi3-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for rustac-0.9.11-cp311-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 e4a646cb5f4031506693a29ce02b82c8210c61424f24b919e26aa67f40290766
MD5 aa48c22e14e3192c57db56a17899473e
BLAKE2b-256 74e21bbfb9c477c488ef05f27a578208f941673b3559b01706486b5e462840c3

See more details on using hashes here.

File details

Details for the file rustac-0.9.11-cp311-abi3-musllinux_1_2_i686.whl.

File metadata

File hashes

Hashes for rustac-0.9.11-cp311-abi3-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 e41c527bde84d8a8e85464cf9fe91f927566008ce6bbae175541f872606fd3fa
MD5 0d402a4d46a4455ff2cfb55a31c66a69
BLAKE2b-256 b7fcb9efadb41cdbdfc98d3f1feb773a7ef92f8e3f43c0bace6ebe5068200d5c

See more details on using hashes here.

File details

Details for the file rustac-0.9.11-cp311-abi3-musllinux_1_2_armv7l.whl.

File metadata

File hashes

Hashes for rustac-0.9.11-cp311-abi3-musllinux_1_2_armv7l.whl
Algorithm Hash digest
SHA256 d338c6f564a9b91c476de7d643f93457fafd7c56d59ea1abf6d1732537304afa
MD5 6a6f85646741ea1684a3b57de343db1e
BLAKE2b-256 75e44537c827c9e9446b39f9af144aed81d07fc077b867cf221b2abde9021eff

See more details on using hashes here.

File details

Details for the file rustac-0.9.11-cp311-abi3-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for rustac-0.9.11-cp311-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 97d6d87c20a54fe8d70265775094d9076a6b9c3b467caedd102a900c4727c365
MD5 0567a76c996d04564d59aba693b7558c
BLAKE2b-256 afaf260d931ea816318582bf6b69b07d5fc4cf9a80620d2db87bf08f242259cb

See more details on using hashes here.

File details

Details for the file rustac-0.9.11-cp311-abi3-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for rustac-0.9.11-cp311-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 29c8ca1e528430c47ea255a22e6efaf2df9fd743a71c6cc64ca82bdd86e770f9
MD5 c9802fd2c19811d1bbed39eb0f572243
BLAKE2b-256 dc0517b7de22db8eb438cc114ac43c62323de612d5740648cf6a524fa2d2b9a9

See more details on using hashes here.

File details

Details for the file rustac-0.9.11-cp311-abi3-manylinux_2_28_ppc64le.whl.

File metadata

File hashes

Hashes for rustac-0.9.11-cp311-abi3-manylinux_2_28_ppc64le.whl
Algorithm Hash digest
SHA256 586e30f05b2244ff34187f1c6bcbabec3dd765e8fb2c51fa975fe646e7309305
MD5 c041050d8cb38f149ec6a4df46ea8452
BLAKE2b-256 8bfe58ae432dc5139847cacd068c8bdc382c0597b1c1b9cf758d2f5bf130d1e0

See more details on using hashes here.

File details

Details for the file rustac-0.9.11-cp311-abi3-manylinux_2_28_armv7l.whl.

File metadata

File hashes

Hashes for rustac-0.9.11-cp311-abi3-manylinux_2_28_armv7l.whl
Algorithm Hash digest
SHA256 e5ae59d77d3c627caef8ac05d1a3596ca75bbc16925532de053e2284d0c107d3
MD5 796d09e566bfac4514564c224974501b
BLAKE2b-256 c2cef1db347f8f6f46bb5cde1a01b0cfeed70101d6e71b8245d070a886fc6f10

See more details on using hashes here.

File details

Details for the file rustac-0.9.11-cp311-abi3-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for rustac-0.9.11-cp311-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 f4e7e069aee94760f61ce236d288618893e3f3032c49c6965c1c12370bd17ebb
MD5 e64aa47866bbb92e3abbe9b17ff12165
BLAKE2b-256 c6510cfd2e0e7a59c0e9ba524d7981e8c8da7c57bf130487c715c61792cd9286

See more details on using hashes here.

File details

Details for the file rustac-0.9.11-cp311-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for rustac-0.9.11-cp311-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4a9ff5c397f9cf4671e13082e269fce10a4775a9f99c41a947ec110a4bedc2e8
MD5 ae4864c3e3599332a883a8dd159c2ec8
BLAKE2b-256 04fa50c8992a649466dd2038098fc892153a0a76e11d13dd835cadf474cceda6

See more details on using hashes here.

File details

Details for the file rustac-0.9.11-cp311-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for rustac-0.9.11-cp311-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 9a4b53fcda85a650007e886096e8f3d3ede36f4ea0123277817aef87bbff87ff
MD5 1129dddac4037c4c1899cd9440df87b1
BLAKE2b-256 576f24c0049f5e47766260357e3c1ee3ff60fbb757b3f07b49c55dd88196f767

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page