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.8.2.tar.gz (708.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.8.2-cp311-abi3-musllinux_1_2_x86_64.whl (29.5 MB view details)

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

rustac-0.8.2-cp311-abi3-musllinux_1_2_i686.whl (31.5 MB view details)

Uploaded CPython 3.11+musllinux: musl 1.2+ i686

rustac-0.8.2-cp311-abi3-musllinux_1_2_armv7l.whl (27.7 MB view details)

Uploaded CPython 3.11+musllinux: musl 1.2+ ARMv7l

rustac-0.8.2-cp311-abi3-musllinux_1_2_aarch64.whl (27.4 MB view details)

Uploaded CPython 3.11+musllinux: musl 1.2+ ARM64

rustac-0.8.2-cp311-abi3-manylinux_2_28_x86_64.whl (23.9 MB view details)

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

rustac-0.8.2-cp311-abi3-manylinux_2_28_s390x.whl (22.6 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.28+ s390x

rustac-0.8.2-cp311-abi3-manylinux_2_28_ppc64le.whl (26.0 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.28+ ppc64le

rustac-0.8.2-cp311-abi3-manylinux_2_28_armv7l.whl (20.6 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.28+ ARMv7l

rustac-0.8.2-cp311-abi3-manylinux_2_28_aarch64.whl (21.3 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.28+ ARM64

rustac-0.8.2-cp311-abi3-macosx_11_0_arm64.whl (19.5 MB view details)

Uploaded CPython 3.11+macOS 11.0+ ARM64

rustac-0.8.2-cp311-abi3-macosx_10_12_x86_64.whl (21.4 MB view details)

Uploaded CPython 3.11+macOS 10.12+ x86-64

File details

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

File metadata

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

File hashes

Hashes for rustac-0.8.2.tar.gz
Algorithm Hash digest
SHA256 3e52f6afa0a65c05fda1fe3bcb76e185acda59dea568a374c040d52945053f68
MD5 b68457c3d8c48122a5ebce0a856fef14
BLAKE2b-256 68b44332bfe75b79e1b6cd042275a6aeddae58d44dce19556968bdabd1258a3b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.8.2-cp311-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 f186dce7d4f4b5131b0c6be30af4cc354ebf0d51cb2227be8d304a1de1889a6b
MD5 5abf1a3b089859c44ddaafb21ec7fbc8
BLAKE2b-256 b199a4c787e25e268d4e3378a16c6583b3497a45b4ec98593f28212f29ce20f0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.8.2-cp311-abi3-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 2d6882c708db546b1fc252c6aab418ecb7f31eacc2711de121a0d15faea7979c
MD5 00c3cb12382801e28e8d85f669b635e3
BLAKE2b-256 4ff98214d8d7fffbee5f3935591ec4d2e1eab7f01631727e340da402c0099eff

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.8.2-cp311-abi3-musllinux_1_2_armv7l.whl
Algorithm Hash digest
SHA256 ba28c12b8270aadba1d9372bae17cfc80a81f61ad4fc5aed99eaa9cc3b14013f
MD5 20c85c6374515d362a4efb5c2ceaf4b9
BLAKE2b-256 6922828378d1e778c5e2d35e67c46b91e5ebe3383a0285543be40ac14502c12e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.8.2-cp311-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 baeefc0cd7bd465c9f9a728c5a0b5eba8639c99bcf1a0418435b742c6e761325
MD5 62699e29dc2fc76acd26a87228f716fc
BLAKE2b-256 bcf30b81df054d7f3ed7429d5711ad1e160660a599ffe5d155ce7c56d4810194

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.8.2-cp311-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 6f38bd931202e6b6c1deec2cc3ca2cf112488d5591b03448ae350fcbb69671ca
MD5 70a38a8721292893ecf1f2c1e6e589db
BLAKE2b-256 10e98550f2da371e040a8437efa47dc176a8073c912304436038337bd48d4475

See more details on using hashes here.

File details

Details for the file rustac-0.8.2-cp311-abi3-manylinux_2_28_s390x.whl.

File metadata

File hashes

Hashes for rustac-0.8.2-cp311-abi3-manylinux_2_28_s390x.whl
Algorithm Hash digest
SHA256 4e665a922a973b0fc2edcda202c34f7036319712ec5438fa50b28024288042b1
MD5 a8e0ac0bfd47f5ac7fc8eff6d508a525
BLAKE2b-256 308bd27bb7c95a13184cd7b1a03aef1830228725c5d3b196b71bcff118dfbd3e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.8.2-cp311-abi3-manylinux_2_28_ppc64le.whl
Algorithm Hash digest
SHA256 192b0b545cf75b005b3d23b135472f63258b812079b0d86b341d1943aede4a8f
MD5 49b4309a609e99376c8636d271e80cd9
BLAKE2b-256 ae22e18b4b2b73247253442c55d6dd48c5bed42e5d27beba62a2975037698665

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.8.2-cp311-abi3-manylinux_2_28_armv7l.whl
Algorithm Hash digest
SHA256 b6ca984cf3fd58e16f0006c3eca8538a71b788b605e761fd269aae238bfe3d5c
MD5 3173fbaf6d50fefa22c1c15af04431d0
BLAKE2b-256 81ff42b86385d43f11aed9fff2e3acf4c614a5f3a324b8a7cdfd8c4537641968

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.8.2-cp311-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 c68b058af930b1890f1cf7277bcf637fa75c49f2e3485a14421b9ff822d5ea81
MD5 2780fcbdd52ca7bfb681503c78816392
BLAKE2b-256 e018812908da5a4b1df40831a80bb4e88064a9d6cd2678c900b6ca2bbd0d6672

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.8.2-cp311-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3b320b74d6f913b9d2347db5c79694431fa029649ade9f33a2437fdcb42a0114
MD5 7eadbda5b2e78e3a64045af0d210e3e2
BLAKE2b-256 8a03470b9937f578855c3f1e786ef4ca61f471c44a39df9073ad5e9d6f9f68aa

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.8.2-cp311-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 349f4c7ca2bb08f1ce79f47c72e136b1f69c3f79a5e479c8bdb315a1baf46e43
MD5 cc697c49d5a28cca1ecf62618108626e
BLAKE2b-256 7e286ab6c5397a8c580e16968e20017973c65797f5a1f6cc3f7b71afb6b6fd20

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