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.4.tar.gz (710.2 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.4-cp311-abi3-musllinux_1_2_x86_64.whl (34.0 MB view details)

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

rustac-0.8.4-cp311-abi3-musllinux_1_2_i686.whl (36.3 MB view details)

Uploaded CPython 3.11+musllinux: musl 1.2+ i686

rustac-0.8.4-cp311-abi3-musllinux_1_2_armv7l.whl (31.7 MB view details)

Uploaded CPython 3.11+musllinux: musl 1.2+ ARMv7l

rustac-0.8.4-cp311-abi3-musllinux_1_2_aarch64.whl (32.0 MB view details)

Uploaded CPython 3.11+musllinux: musl 1.2+ ARM64

rustac-0.8.4-cp311-abi3-manylinux_2_28_x86_64.whl (28.6 MB view details)

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

rustac-0.8.4-cp311-abi3-manylinux_2_28_ppc64le.whl (31.5 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.28+ ppc64le

rustac-0.8.4-cp311-abi3-manylinux_2_28_armv7l.whl (24.5 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.28+ ARMv7l

rustac-0.8.4-cp311-abi3-manylinux_2_28_aarch64.whl (25.6 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.28+ ARM64

rustac-0.8.4-cp311-abi3-macosx_11_0_arm64.whl (21.7 MB view details)

Uploaded CPython 3.11+macOS 11.0+ ARM64

rustac-0.8.4-cp311-abi3-macosx_10_12_x86_64.whl (24.1 MB view details)

Uploaded CPython 3.11+macOS 10.12+ x86-64

File details

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

File metadata

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

File hashes

Hashes for rustac-0.8.4.tar.gz
Algorithm Hash digest
SHA256 8ea3abdc74921e48eebedfb6954b070fa172851d780c9bcd1407863f796b08cc
MD5 7eff857c0d0efdf2b4faf67f2531dd2c
BLAKE2b-256 64e5adf0f8048580dc56c6212cf61ffa7d12fdbcc96d7b9820395b8323e526ee

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.8.4-cp311-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 c25ed734b38f18c520bcd8d1f12fe61d3bc662ed7aeac6ccdd868a60219cffee
MD5 a8fbe9d5abb054f0fbcb2a097f054aae
BLAKE2b-256 0b23b4e27f7aaa066bc10b72ccc64e644cd12c6877fc0663d647df4145e113be

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.8.4-cp311-abi3-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 6168b1f0744405b1e7159dafe160932b47df87454e9b5bc63a7b98b91d54359a
MD5 a011deb8083272703eff46408bb47452
BLAKE2b-256 cf0040e321934cb12784dde2968480e517d0c5fff8622e79174553279ca02529

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.8.4-cp311-abi3-musllinux_1_2_armv7l.whl
Algorithm Hash digest
SHA256 fbddb2bfba313800edebc188a4011558808e917bb58ba1bf99dd25d49a7a48ec
MD5 7ba1daee25c993f22944939cb3cecd2f
BLAKE2b-256 e47a7bfdedf44e31ab1257f54ccd05a7fbc7e1c8dee94834fc553a481be4b84a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.8.4-cp311-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 4bde46e59f5802abcea19a9c15195b49c3ffe0bfddee30d3c99f185d8d31289b
MD5 9747c4518499db4e6116aeb6e810953e
BLAKE2b-256 96ef6867a53eecf9cde770df87c4a76a3331f3cced6982101fb4ff879d42c3ee

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.8.4-cp311-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 870f02839364d94ec85e1dba1c6140126e029a9acd3c185015032487e32e00c5
MD5 5ded553546eb0517783af67fe58f70ec
BLAKE2b-256 48151ae2ec9c9f5637b3148546e1b1f01469df4222e3a4222d0bb67068732630

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.8.4-cp311-abi3-manylinux_2_28_ppc64le.whl
Algorithm Hash digest
SHA256 a883a1670486e87e3971244d93926473bd27bd7731f3908d2ce3790fa9716f2b
MD5 f8d8f2a5a107bb9ca0978fd1e0ad6ed2
BLAKE2b-256 88906b6554c9abc803344c77352535d5aa0fc77a653aae3f245ea26cd3ead3e9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.8.4-cp311-abi3-manylinux_2_28_armv7l.whl
Algorithm Hash digest
SHA256 4f9ba177d114428eafab8dcec1a77beb06626f203c4305c273547f7c27141364
MD5 7d727a45aa5f004cdb19a4ca717cc64d
BLAKE2b-256 b4e2e80fed2e92dd8458bed7557d721032260e365d19fbc01dd0fbb30885d4f5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.8.4-cp311-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 b8e8627c81d922eb36b1b12e41618e95359a498e86a2ddbe8d45554d44a7cda5
MD5 562e0b4a553c7a03918b6076f907c276
BLAKE2b-256 32217ea12b96f791c17b937b6dd231abfccb570bccf6f90a4c584f3dc27da3ae

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.8.4-cp311-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 56bc8948139c5abaea2b45663f88ce1714ad9311915cee8ffa9587b983e0242f
MD5 dd020bf91e47c42753c8bf83aa081c30
BLAKE2b-256 09d54f9941c641e9ecaefbf8dd5c89615e827472e3dced4442f7a22992c0161e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.8.4-cp311-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 123ca4e012588856cb469c392bb35eae95220d598cf6d7d2f5eb3f12f06006a7
MD5 29ef02ddae2a2fed21d12438a038c571
BLAKE2b-256 e24c5b54c932f86fc9fa56a26bebb83a7179f927f72869ba44df5864976f4c88

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