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.0.tar.gz (500.5 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.0-cp311-abi3-musllinux_1_2_x86_64.whl (29.3 MB view details)

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

rustac-0.8.0-cp311-abi3-musllinux_1_2_i686.whl (31.2 MB view details)

Uploaded CPython 3.11+musllinux: musl 1.2+ i686

rustac-0.8.0-cp311-abi3-musllinux_1_2_armv7l.whl (27.5 MB view details)

Uploaded CPython 3.11+musllinux: musl 1.2+ ARMv7l

rustac-0.8.0-cp311-abi3-musllinux_1_2_aarch64.whl (27.2 MB view details)

Uploaded CPython 3.11+musllinux: musl 1.2+ ARM64

rustac-0.8.0-cp311-abi3-manylinux_2_28_aarch64.whl (21.0 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.28+ ARM64

rustac-0.8.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (23.2 MB view details)

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

rustac-0.8.0-cp311-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl (24.5 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.17+ s390x

rustac-0.8.0-cp311-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (23.2 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.17+ ppc64le

rustac-0.8.0-cp311-abi3-manylinux_2_17_i686.manylinux2014_i686.whl (26.0 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.17+ i686

rustac-0.8.0-cp311-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (20.4 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.17+ ARMv7l

rustac-0.8.0-cp311-abi3-macosx_11_0_arm64.whl (19.2 MB view details)

Uploaded CPython 3.11+macOS 11.0+ ARM64

rustac-0.8.0-cp311-abi3-macosx_10_12_x86_64.whl (21.1 MB view details)

Uploaded CPython 3.11+macOS 10.12+ x86-64

File details

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

File metadata

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

File hashes

Hashes for rustac-0.8.0.tar.gz
Algorithm Hash digest
SHA256 ecb32635228bada364c4968822ae009d3cab4e2369746a9cc8c9cc6b20229950
MD5 de0e6e6c4eae786e27c0c5bd16bf3002
BLAKE2b-256 21fd5260490f2a39fa3f7b5391b194ecf985eb5883de88a64bed0389c5ea1a4a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.8.0-cp311-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 e6761c77515aca8ca7f14ad5f03b70906959fde610317c5f82df18c3518859b2
MD5 fd2fe9b4dad325153734e2268c8cfb81
BLAKE2b-256 e4284bfabf5ddc867b645eb2d3c0cc8658c740f340ef759781064ebcaf1d452f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.8.0-cp311-abi3-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 60248a84c4b6718d01864a7a9464bdaa6938a8c05eb7c988a654f6878785ec5a
MD5 d45215449e5f935dd3a227e5ad9fd0e1
BLAKE2b-256 09dc2da08115b8a204f0049e46cea3c0b14c5faab77636af056124be5779eca1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.8.0-cp311-abi3-musllinux_1_2_armv7l.whl
Algorithm Hash digest
SHA256 d8528fc3a327f8e2a1860f96b165b013fa7e59d98ff1767f36b0410f868694ce
MD5 3a5bbeb9851084ee3cb1e001b416698c
BLAKE2b-256 f2acc3538903d226672502223442ed29f331091dc3eb8fc42a5aaf4df622d3af

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.8.0-cp311-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 954b0b62003ba9ac464b89ec30fdf0c26e764f559f48ff620fffcdbf54ee735d
MD5 99c9c2f6f4717eb9d7586cc172e1ab54
BLAKE2b-256 af736f4782bde2190ac57a643d4c64a764f4d5acfdbfe0f591072ba938476f9d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.8.0-cp311-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 9e59b1119e6dc7397d7e367995e45232d533ad92bb3cef53a7fdd3cdab689d36
MD5 ef98177e3a72790048f2fd24a809bf64
BLAKE2b-256 e0e088b61e73f7410752a3e05e6588e3dc09b9cb003f477c062e60b77f2ee5f4

See more details on using hashes here.

File details

Details for the file rustac-0.8.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for rustac-0.8.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 19b713435141219f8c447c5d85c0dbaa88825135bd165066a8d81db3467f80e7
MD5 edc93535f246ebaa84819a39d5496a03
BLAKE2b-256 ac2e7c316f3d460cf44276eee478206070295f0171dbbc161b0d022a8d0edaba

See more details on using hashes here.

File details

Details for the file rustac-0.8.0-cp311-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl.

File metadata

File hashes

Hashes for rustac-0.8.0-cp311-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl
Algorithm Hash digest
SHA256 d1d7f2e5debe4437d752ac47ca8319d408ae8c174b8f975ef69f89ccb17acef2
MD5 26ac3866b504619f4298b17883b450cd
BLAKE2b-256 ddd5fef47d1f425007ad72abd85ab3a11a986f7f1cb707ee10a4ab2db954055f

See more details on using hashes here.

File details

Details for the file rustac-0.8.0-cp311-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl.

File metadata

File hashes

Hashes for rustac-0.8.0-cp311-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
Algorithm Hash digest
SHA256 cb7aab046fad6f83a3f0d809f5bc66116eaf4c05a08274ff006de784dadbfc2d
MD5 8c813df2b18c8026dea434be47fbc28d
BLAKE2b-256 a17ee26bd59d157e3b3097041d7c780691865e17ae4f22c2130a44211d91ea08

See more details on using hashes here.

File details

Details for the file rustac-0.8.0-cp311-abi3-manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for rustac-0.8.0-cp311-abi3-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 655a914f9fe0d9ab4a91eebd6963b763ccb806b6bd96330931f2d68f6e5a26a3
MD5 458ce0f8cf61d084b130c53d5397718d
BLAKE2b-256 220a9ac7b75f2d4d0a08ded07ef8d0caba99f93f296a9081116b051b0b064c36

See more details on using hashes here.

File details

Details for the file rustac-0.8.0-cp311-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl.

File metadata

File hashes

Hashes for rustac-0.8.0-cp311-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 a72300f3b7c547ac8b4d35526c3924229e41615faea0a628ad70e89d9345f2d6
MD5 4b13973e1b72f2a1cd5c2167491570a0
BLAKE2b-256 ade240e719c7b3d76a9cb5fe5ebb68e915c7ab8a7a82012e2183c87a470b1360

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.8.0-cp311-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c1bb284165fb5fa447178b344857626233c5b433737100ec97da538c1506fe0d
MD5 b7edf66c8eae58f7ff7ee290967af241
BLAKE2b-256 43e387810526a06a6e2555551f7c25a53e534822b8268ae7ef002ba62b6c88c1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.8.0-cp311-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 546253de3a416286fc0b29bb0c1dbc7a424804cbc7e9aec7ce108f6c5fbdc447
MD5 c2bb30e082a41408f696bbd9841891d9
BLAKE2b-256 4ccb4c4e10b4310309c1d0b2cc67b351f06bd7650614d37107721317ea79d42c

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