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

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

rustac-0.8.3-cp311-abi3-musllinux_1_2_i686.whl (34.4 MB view details)

Uploaded CPython 3.11+musllinux: musl 1.2+ i686

rustac-0.8.3-cp311-abi3-musllinux_1_2_armv7l.whl (30.2 MB view details)

Uploaded CPython 3.11+musllinux: musl 1.2+ ARMv7l

rustac-0.8.3-cp311-abi3-musllinux_1_2_aarch64.whl (29.8 MB view details)

Uploaded CPython 3.11+musllinux: musl 1.2+ ARM64

rustac-0.8.3-cp311-abi3-manylinux_2_28_x86_64.whl (26.7 MB view details)

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

rustac-0.8.3-cp311-abi3-manylinux_2_28_ppc64le.whl (30.2 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.28+ ppc64le

rustac-0.8.3-cp311-abi3-manylinux_2_28_armv7l.whl (23.1 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.28+ ARMv7l

rustac-0.8.3-cp311-abi3-manylinux_2_28_aarch64.whl (23.4 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.28+ ARM64

rustac-0.8.3-cp311-abi3-macosx_11_0_arm64.whl (21.6 MB view details)

Uploaded CPython 3.11+macOS 11.0+ ARM64

rustac-0.8.3-cp311-abi3-macosx_10_12_x86_64.whl (24.0 MB view details)

Uploaded CPython 3.11+macOS 10.12+ x86-64

File details

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

File metadata

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

File hashes

Hashes for rustac-0.8.3.tar.gz
Algorithm Hash digest
SHA256 f9a38df858fa22e25092230a520de22bf88f5eafb02417d0499659b877eb34de
MD5 cd11abc08fad3d18c5687d43d315147f
BLAKE2b-256 8205a577d3d40300cc44333efd77b0f9ca25b0cff2f72f84459386bf7dfe4714

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.8.3-cp311-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 c5559d397f418f921894f013cc5fc66149a21557265424e827dc953621432590
MD5 7554e362f0e71afeb1ee8e9be704c22b
BLAKE2b-256 4585012920de938e5c7b84b33776037b507d8eefe6a2aae769887fd7cdec0d2e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.8.3-cp311-abi3-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 c2e6dc04ff66200c9d8c46cf9907d1db333745c46d21450d9c3c1bc037520b25
MD5 c31ad116425259832f0593d284d290a9
BLAKE2b-256 62e795d07111037e8c6909fbff02ee1d45b1708c71b0042c09813b9a80021104

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.8.3-cp311-abi3-musllinux_1_2_armv7l.whl
Algorithm Hash digest
SHA256 173c70487cc39b2953097da4e6b5f5f86a0b2d33b7009ba9112c6e55008cf941
MD5 77c7535017a19e87eac37ebd6fad747e
BLAKE2b-256 da6c85755b549ffa34dcbebdf33866ed1061d5b572003bd0b4fc33ecd3feed1d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.8.3-cp311-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 b5649506f00dd08d0c81e739235a428c101bbe5b7ddf4e95959c541c097e97fd
MD5 487922667473e9101eb9c26fe51c95c3
BLAKE2b-256 a7a25e55473165bf079fccd26fd02bd28c8be82cc15f25eacd02d9522d029177

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.8.3-cp311-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 14cf367f76f9703177fb38e719acebe9a41f476917ed7f50c6b2ac9177bf1c1e
MD5 9b5b0275ff56738be423a8d6db77935a
BLAKE2b-256 1bbcae3679f4a737dadd915dc0fd249ea998c4b4783974d779a8124b6e636bc5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.8.3-cp311-abi3-manylinux_2_28_ppc64le.whl
Algorithm Hash digest
SHA256 f75458a2ef4f5b956ecc67a3a04a40f952b1e5915310e10981313118508be043
MD5 834ba3836f32b5d8899d9df8d2827302
BLAKE2b-256 7ec5728dfdea3dff2f379bcd55d7176468b85881f55fb59544ab437c709d3c16

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.8.3-cp311-abi3-manylinux_2_28_armv7l.whl
Algorithm Hash digest
SHA256 1be8fe8432168dc52876375855961b715cef44fe3cb4d3d8c329f87faa0d5713
MD5 a1a983830b226c541939f9d5496b7b3f
BLAKE2b-256 cb0aa7eaef46042c79b9a6d1dd51ee7de9bb41f93fd391e020fb5a8f51644995

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.8.3-cp311-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 8f5a646d6467a7f59b5a6b954b615639d10e3b2d099482bd48124bef463886b9
MD5 f993224504d33921f8108f2c408dc993
BLAKE2b-256 47bdca7f947fcac7f71cc7266a93e0e6b6900068159920585bafea1e9974af3f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.8.3-cp311-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d43704c699c021e54c5432705349c21f8ecab54b5aac398ad4052c0b9a1449b8
MD5 7198196c19b1a0a5602d5631064aafeb
BLAKE2b-256 b956e00ac6dac27cecc6fd589eb235a4eb2db9fe8119a02d39eba68653809d00

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.8.3-cp311-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 e395e52cca0bcee2b3b47e6a9a99e952133488e3c661a163eae6b2d129515876
MD5 ad8f0a9d28f77b3d79d6f4ab49fae9c2
BLAKE2b-256 e9a34bc645b2e40fb1aa6aef3e2f9b54245dbcba5f8a4d21e9a0a79b69bd67bb

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