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.8.tar.gz (743.4 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.8-cp311-abi3-musllinux_1_2_x86_64.whl (36.0 MB view details)

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

rustac-0.9.8-cp311-abi3-musllinux_1_2_i686.whl (38.1 MB view details)

Uploaded CPython 3.11+musllinux: musl 1.2+ i686

rustac-0.9.8-cp311-abi3-musllinux_1_2_armv7l.whl (33.3 MB view details)

Uploaded CPython 3.11+musllinux: musl 1.2+ ARMv7l

rustac-0.9.8-cp311-abi3-musllinux_1_2_aarch64.whl (33.4 MB view details)

Uploaded CPython 3.11+musllinux: musl 1.2+ ARM64

rustac-0.9.8-cp311-abi3-manylinux_2_28_x86_64.whl (30.1 MB view details)

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

rustac-0.9.8-cp311-abi3-manylinux_2_28_ppc64le.whl (33.4 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.28+ ppc64le

rustac-0.9.8-cp311-abi3-manylinux_2_28_armv7l.whl (25.7 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.28+ ARMv7l

rustac-0.9.8-cp311-abi3-manylinux_2_28_aarch64.whl (26.9 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.28+ ARM64

rustac-0.9.8-cp311-abi3-macosx_11_0_arm64.whl (25.0 MB view details)

Uploaded CPython 3.11+macOS 11.0+ ARM64

rustac-0.9.8-cp311-abi3-macosx_10_12_x86_64.whl (26.8 MB view details)

Uploaded CPython 3.11+macOS 10.12+ x86-64

File details

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

File metadata

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

File hashes

Hashes for rustac-0.9.8.tar.gz
Algorithm Hash digest
SHA256 0c88e736de57160e32ce627d0fb65330eac5efc2314166e13c32ba388077b7f2
MD5 953366f55048ab6e83ee4b679048752f
BLAKE2b-256 9506afd549aa2554fd19c7bd5125e147214f89e18a6215649144cb12f1b23bf9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.8-cp311-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 f6a5840aa2e07ec2932b5b56d4848cc2b47ff19c20db16a9a7411c24ce531b56
MD5 f0b5883f17d47e46e5c799d368bd9064
BLAKE2b-256 db86f6e43339115f7a553e68ecf36d514ba3d7c1bc65e65ef7f8ee6216529369

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.8-cp311-abi3-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 4093e2f3bc5719f0ff4eabf5e16ecd1062ec6163c1aba36e9c59eee48a78636e
MD5 4ecc2968aa1ad61cb9041ee64d1bdbbd
BLAKE2b-256 18f50faffc71b4361cb96561ecc006a82075fa7a170b50610484e8d904becfcf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.8-cp311-abi3-musllinux_1_2_armv7l.whl
Algorithm Hash digest
SHA256 1bfdbf764715cfe6937e48adf45550e09e10891e9246c76f2a553c81f4d65212
MD5 8c51676e165d05f2317ff9d842818f57
BLAKE2b-256 de6aae576a391b5abdf986e7d22655320a3ce31aba2fe850e9d851e75504d5b8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.8-cp311-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 955e5b1f6902e033a86f7967cb01427d5734fa2a2d080b4e39d570642137dad8
MD5 b75e2423d9fdd3d5438975f16890d0fb
BLAKE2b-256 9158173d3097a362dcd1e33bf3f5d576ba8b3155f2bc11c7aad8be70fc78ff3f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.8-cp311-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 53aad9c5faf24d43aa666e59014237ce5ab4c22a016402e5ea3aaaefb66aff56
MD5 59d34c5a8bc9fbaacf9ca672b66203fe
BLAKE2b-256 44fa15886b0b1c2a02a7d6f41969bb79fee07f782901625306538dba7ed0c0bf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.8-cp311-abi3-manylinux_2_28_ppc64le.whl
Algorithm Hash digest
SHA256 0d5ec0fe9471ba0b6ba53e76117c66c16a8cbf2bea08c26531bf3d1381a12ba8
MD5 97f2d960eb7b8dc6f80150f072c30210
BLAKE2b-256 8c76af4a44543c1beae65ac5079c41cda7506a3feb61efe8b7d185c649730c4a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.8-cp311-abi3-manylinux_2_28_armv7l.whl
Algorithm Hash digest
SHA256 6b4616b93b18456cbb26526b0d1bc4aac342a620772314c272e0bc5ec267ecfa
MD5 c3ad23e9f08b0f1753d04fbf65575b2b
BLAKE2b-256 a236edb13fdc27d77b8da42307a1d2aa9dde964ca9da4f32d83378e8b7de14d1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.8-cp311-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 73443b29c6b69d76fd5f09fa5dfc1d645b716ca40dd6046b6f49fb9b1566ba59
MD5 ccb3751128fef09100a9650006276062
BLAKE2b-256 d2aac0a73d4099bbf601e7ada7eb76d8337dae2965a4153f3c860b3bd45fa4c2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.8-cp311-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 81c0a75533f6fc3b3b5a71b1b6c5dc4538c89a6d407717081b5b3c80dc9704cb
MD5 4bbc45463228d94b026882cd8f1fbb1a
BLAKE2b-256 db1ffe7fc7cfd186cb9cc039e50737efe856af5f9dd1477419a3abce5c8cfe91

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.8-cp311-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 6dcb5e71549d76fec31b5d2b8ecb9ae13b20491d77968970b6d5c6dc2cfa55a9
MD5 5a09e1f1ecf46de25802af8bb20f9225
BLAKE2b-256 fedf4cc4792cad0698e17f3efc093f84380f598165cfed3937eb7964fcb2fb89

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