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.3.tar.gz (737.8 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.3-cp311-abi3-musllinux_1_2_x86_64.whl (37.1 MB view details)

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

rustac-0.9.3-cp311-abi3-musllinux_1_2_i686.whl (39.1 MB view details)

Uploaded CPython 3.11+musllinux: musl 1.2+ i686

rustac-0.9.3-cp311-abi3-musllinux_1_2_armv7l.whl (34.0 MB view details)

Uploaded CPython 3.11+musllinux: musl 1.2+ ARMv7l

rustac-0.9.3-cp311-abi3-musllinux_1_2_aarch64.whl (34.7 MB view details)

Uploaded CPython 3.11+musllinux: musl 1.2+ ARM64

rustac-0.9.3-cp311-abi3-manylinux_2_28_x86_64.whl (31.3 MB view details)

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

rustac-0.9.3-cp311-abi3-manylinux_2_28_ppc64le.whl (34.6 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.28+ ppc64le

rustac-0.9.3-cp311-abi3-manylinux_2_28_armv7l.whl (26.4 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.28+ ARMv7l

rustac-0.9.3-cp311-abi3-manylinux_2_28_aarch64.whl (28.1 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.28+ ARM64

rustac-0.9.3-cp311-abi3-macosx_11_0_arm64.whl (24.1 MB view details)

Uploaded CPython 3.11+macOS 11.0+ ARM64

rustac-0.9.3-cp311-abi3-macosx_10_12_x86_64.whl (26.0 MB view details)

Uploaded CPython 3.11+macOS 10.12+ x86-64

File details

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

File metadata

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

File hashes

Hashes for rustac-0.9.3.tar.gz
Algorithm Hash digest
SHA256 427dc5325617d6c57f504318bc9f703763dc40df66d35a888d407d0ebc0f8c9f
MD5 693666d4fe2120a99855ef34f86baa61
BLAKE2b-256 b1dc0c0618f576119fe1ac7b5b03a968a4a825411b0460f748039210e98c1dcd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.3-cp311-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 d3f3bb74f49acfbbce42be113dab300e98226b763974f7bbe94835bb90e7dcd6
MD5 560b925cf8bff77ab026de3c02d17d95
BLAKE2b-256 567ee3390934aa0a85fb7044fe8ca9c53868b55c0c2e996236e074b7c51ff429

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.3-cp311-abi3-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 4b162fc0051dd440deb1bdfa4a9d3ea6726d0b3355f11c630a7528780178679a
MD5 b4da4574a3dbd20972dc20aeafe1cdd8
BLAKE2b-256 cc286606216351812a1bd9043dd6284216b3065af0a0f3d7deb00333ad4561db

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.3-cp311-abi3-musllinux_1_2_armv7l.whl
Algorithm Hash digest
SHA256 1a02d268580e7c6595563a2c3b3c8f12ee15411071ebcbd09f61f0325b64d46e
MD5 88a4ebda43c3261f2174b50fc5010688
BLAKE2b-256 141953c5cbb4b7daa46abbb4f3db01f9fba619b73c20600eab9fc10ddcaed19b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.3-cp311-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 8e8355fa226d109be2be7aed485034eb69851fb6b59a9ed47af9379356b75825
MD5 6ee8d496f8018ab9293a7058d4c789b5
BLAKE2b-256 a308479539289c0e0de5095a8fd42308aa0669c3413f7590c5907137fd1a1f48

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.3-cp311-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 df941bdbaedaf6bf0b51976c923642c9bab55ed5a8e25a56bc49b02a11887f28
MD5 13d299fa344a2551be68b9935f65d441
BLAKE2b-256 460fe41b599cd4f81e62b14b06b5c45b68ea52fb644f9e99d7791df5bd55bfc7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.3-cp311-abi3-manylinux_2_28_ppc64le.whl
Algorithm Hash digest
SHA256 288216ca0f96136afb8422e24728e19be535e6e34192b25763bfc374c98d72a9
MD5 995a18d0e939b3a310a889350bc0ed2c
BLAKE2b-256 821e1c6e8ab14ef6066991232e9338ae42cb824376d22291e3d3c9741274eaca

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.3-cp311-abi3-manylinux_2_28_armv7l.whl
Algorithm Hash digest
SHA256 be326379c3e2599e1e02e02ff2c56fc3b324a9afd30bed1f0abfb03b33f3e6d1
MD5 1d9cc6769f70ad94a76a215a1db6c870
BLAKE2b-256 ec46555e3fefe7f5775885e0d3765f10e035d0e540cc4253a493f29fda9da14b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.3-cp311-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 e1f6f94eaf0fd93d5f5f0687b73b43a9ada0e176eb6b4c8d279829892ccf9109
MD5 fef688ab090bdfe591fa74df7ed4bc54
BLAKE2b-256 0f2f07edacb1b1a82b08cdaf5691442076f5852e40979859b116eae8802acbc3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.3-cp311-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2f9cf5f1fe536bd88c1fe2ac26d9d22a55e5143ac76a8af6b1ee8534b99dd9b7
MD5 b2384c2d77253d1a0e9f58847632553e
BLAKE2b-256 c2626bebac90e854f008cf4b5788698d8c568fa4184fd77cb3b3f9f45cdac546

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.3-cp311-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 d3cc8bed80370b54450377a53ebc33980ae59ec4e5fc37aea01ff29dc9133400
MD5 9261326370b1c0a2d0a3d6e1ff931f29
BLAKE2b-256 49efd9698e162ffcbc47f172162d8f37a82f56c8afb7e3d48d10583952c6c29a

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