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.1.tar.gz (704.7 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.1-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.1-cp311-abi3-musllinux_1_2_i686.whl (31.3 MB view details)

Uploaded CPython 3.11+musllinux: musl 1.2+ i686

rustac-0.8.1-cp311-abi3-musllinux_1_2_armv7l.whl (27.6 MB view details)

Uploaded CPython 3.11+musllinux: musl 1.2+ ARMv7l

rustac-0.8.1-cp311-abi3-musllinux_1_2_aarch64.whl (27.3 MB view details)

Uploaded CPython 3.11+musllinux: musl 1.2+ ARM64

rustac-0.8.1-cp311-abi3-manylinux_2_28_x86_64.whl (23.8 MB view details)

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

rustac-0.8.1-cp311-abi3-manylinux_2_28_s390x.whl (22.5 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.28+ s390x

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

Uploaded CPython 3.11+manylinux: glibc 2.28+ ppc64le

rustac-0.8.1-cp311-abi3-manylinux_2_28_armv7l.whl (20.5 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.28+ ARMv7l

rustac-0.8.1-cp311-abi3-manylinux_2_28_aarch64.whl (21.1 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.28+ ARM64

rustac-0.8.1-cp311-abi3-macosx_11_0_arm64.whl (19.3 MB view details)

Uploaded CPython 3.11+macOS 11.0+ ARM64

rustac-0.8.1-cp311-abi3-macosx_10_12_x86_64.whl (21.3 MB view details)

Uploaded CPython 3.11+macOS 10.12+ x86-64

File details

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

File metadata

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

File hashes

Hashes for rustac-0.8.1.tar.gz
Algorithm Hash digest
SHA256 2a3c3e7609d6bda7f961e6a269732747e9a7b9239aef4e057a5b0781dc951449
MD5 deb4b1e6ea89c4e213a52edf99c4e226
BLAKE2b-256 6d383d2509c337e9e1ef6b117292e53a5436c3e0a8f3b933657bac320f5bf49f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.8.1-cp311-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 e93e7cc81bb2cc7d9d6aa6057abc50af5bdde0f9150b2d2a2f7d1503bbdd45f5
MD5 c3a4b57dafeeeb3648ec27e813f9760a
BLAKE2b-256 0ed187eeac07555d71643452462cf220bb07035c61ba38f433016dbfd0682071

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.8.1-cp311-abi3-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 7941455c8f2933375ac18474e8ae041283262eaa64f620b048e2c53db05bbe38
MD5 ab5d45242bbd47a3bd2909f4e5588cf3
BLAKE2b-256 8f403026983166d99c6250b84a62969c38cbe362b9a5872e37e232e02c95b813

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.8.1-cp311-abi3-musllinux_1_2_armv7l.whl
Algorithm Hash digest
SHA256 b9a7b5bba202dcb2315bab647a80dd28f616ea8f6bf02514f4240edab2d0410c
MD5 f0347c44c673dd69848d1f2374b475e8
BLAKE2b-256 9090c38dedf2fc50a03011dca1f799b61a8db89a66ddb99cafcfe9e8c9be6822

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.8.1-cp311-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 f0c0b5bd400c3b1871f100945ec44e1fa01d641fca3cfec39f904c0be2717c3d
MD5 de6f0ac979ad8b4c04ba1cf22cdd240e
BLAKE2b-256 59d312d45c8b89fc67a705f4705d3490710a87e98340989dc3e0861578e6ab91

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.8.1-cp311-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 7c304e01b8e81aaa78a9141f30ec2c01bc4d5a8b81b62b120214f623eef89f06
MD5 724ec7822cb8904c92948f62ac20b35c
BLAKE2b-256 dcf8f7c9302fe539a3c1fe67cb794e08f028aef74f4146e50e01ab5b8b632da5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.8.1-cp311-abi3-manylinux_2_28_s390x.whl
Algorithm Hash digest
SHA256 baa8e992b22c5567a34690c91d27bc639b1970282f7177733d551a733d81156f
MD5 bc619a1828108186ff770c9bb641e511
BLAKE2b-256 e7b45980197d03499789a0c508355338899e7789d871606ab83211de7e990ff3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.8.1-cp311-abi3-manylinux_2_28_ppc64le.whl
Algorithm Hash digest
SHA256 1845a123cae04a66ed6d98c0709cb749ab2e118a15089570c319ad03460e4e65
MD5 6ce83a85bcb943c15600eddf1457d2f7
BLAKE2b-256 42eadf6185af8df32835d1a5dad1f22605c0b7b508232d2771005393dc4901c1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.8.1-cp311-abi3-manylinux_2_28_armv7l.whl
Algorithm Hash digest
SHA256 aca2b3946f887e4716fe0fc6f91f200be364caa6038d077e1e5b151f32a23930
MD5 abb25f0085814475b6718ece584664e1
BLAKE2b-256 bb85c7f80ad9229ada445a78af50f6d8ba296e84686bee7b4dc509c6efe011da

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.8.1-cp311-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 a937d92d616393f33ac27a2cfcdd5ed3a4c7e03462789ad1f27eefdd01421c6a
MD5 cf1c5b8342058ace579d8952b95ca98f
BLAKE2b-256 ab5be2057f3df860214f7a3150ff0da4d1221f26aff3c3ea1230d22e1b0d6b8b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.8.1-cp311-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0b6608a920a2d254fc2bfca65c912c76866bd85f26a718ace156ba1f2647d492
MD5 ba7113b7f7a506a4315d5ea88f4e5967
BLAKE2b-256 647f18d0b5f56ef35dc7eb7379acea42458b1c74061eab724e511bdda62b6c07

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.8.1-cp311-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 ab413453030bddb7d2769d814d6ad2c0123bf41a8d8a717e98995bd3bf67515b
MD5 fb0a40bc0c630c359f3e46eff92f8641
BLAKE2b-256 9508ab76c32d560cedcca382542722efa50dda3c708dd0482d66a52761b0d53b

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