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.14.tar.gz (765.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.14-cp311-abi3-win_amd64.whl (26.5 MB view details)

Uploaded CPython 3.11+Windows x86-64

rustac-0.9.14-cp311-abi3-win32.whl (23.8 MB view details)

Uploaded CPython 3.11+Windows x86

rustac-0.9.14-cp311-abi3-musllinux_1_2_x86_64.whl (37.3 MB view details)

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

rustac-0.9.14-cp311-abi3-musllinux_1_2_i686.whl (39.5 MB view details)

Uploaded CPython 3.11+musllinux: musl 1.2+ i686

rustac-0.9.14-cp311-abi3-musllinux_1_2_armv7l.whl (34.5 MB view details)

Uploaded CPython 3.11+musllinux: musl 1.2+ ARMv7l

rustac-0.9.14-cp311-abi3-musllinux_1_2_aarch64.whl (34.6 MB view details)

Uploaded CPython 3.11+musllinux: musl 1.2+ ARM64

rustac-0.9.14-cp311-abi3-manylinux_2_28_x86_64.whl (31.5 MB view details)

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

rustac-0.9.14-cp311-abi3-manylinux_2_28_ppc64le.whl (34.7 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.28+ ppc64le

rustac-0.9.14-cp311-abi3-manylinux_2_28_armv7l.whl (26.8 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.28+ ARMv7l

rustac-0.9.14-cp311-abi3-manylinux_2_28_aarch64.whl (28.1 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.28+ ARM64

rustac-0.9.14-cp311-abi3-macosx_11_0_arm64.whl (26.2 MB view details)

Uploaded CPython 3.11+macOS 11.0+ ARM64

rustac-0.9.14-cp311-abi3-macosx_10_12_x86_64.whl (28.0 MB view details)

Uploaded CPython 3.11+macOS 10.12+ x86-64

File details

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

File metadata

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

File hashes

Hashes for rustac-0.9.14.tar.gz
Algorithm Hash digest
SHA256 6a0c4ec02cd489f5f5a7d77bc2659f77f0a0955ded47d89cf7eef950ce2f94c1
MD5 69c7ac49c1ea980ece5c50ceadbfb3b3
BLAKE2b-256 3458b59976d05d01eb3f5aab7b0c4ed3db4456844935fa27b396de5a879f0fa0

See more details on using hashes here.

File details

Details for the file rustac-0.9.14-cp311-abi3-win_amd64.whl.

File metadata

  • Download URL: rustac-0.9.14-cp311-abi3-win_amd64.whl
  • Upload date:
  • Size: 26.5 MB
  • Tags: CPython 3.11+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: maturin/1.14.1

File hashes

Hashes for rustac-0.9.14-cp311-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 81f3b2312b611a5004cb8aa01812ef6840ec3d52a1d907794e75718e3364894f
MD5 47c9d9e3c35b446f54f58eb4eac80cc6
BLAKE2b-256 e4d2c8ae4d8186901b9cf7c387ca1efd0729e74e39d130dfb51ff2f7883217c4

See more details on using hashes here.

File details

Details for the file rustac-0.9.14-cp311-abi3-win32.whl.

File metadata

  • Download URL: rustac-0.9.14-cp311-abi3-win32.whl
  • Upload date:
  • Size: 23.8 MB
  • Tags: CPython 3.11+, Windows x86
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: maturin/1.14.1

File hashes

Hashes for rustac-0.9.14-cp311-abi3-win32.whl
Algorithm Hash digest
SHA256 bf4b2cfa883e3f1f2a859b38f199e5ff0fe6a5c18c56ec9bd97141148dfead69
MD5 ae87293b62ab34ac46d029f7711a9500
BLAKE2b-256 5d2526b5e081de47a20d9a1a92718f2c73a80bc9da8db1c81e8e9e8e233b5878

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.14-cp311-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 3500af9debac75ba1e6c6a48f9ffb72551aae2821bd67f05460f4914bf96cbf9
MD5 a355083b583f4193a38c1f27f713fc96
BLAKE2b-256 eceeaae417b2793d706cc9bce3d2f7d6f19968026e6faea34deac6d989175d93

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.14-cp311-abi3-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 5a6b9944e3b2134e6e1a9cb5c2c1ab86af3843ec913cc38833972e6eff353e74
MD5 e69fef3d245d3ca5094be266d496d000
BLAKE2b-256 cb126eb52451018baa68362d9ca7ec38d01e0f1efe1e92f7fe6e4a2fd59170f7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.14-cp311-abi3-musllinux_1_2_armv7l.whl
Algorithm Hash digest
SHA256 aac8bfe941585f9f0418c0879a8d5c478235c86b681124875b208d5d036074eb
MD5 cbb3c2868e922db3c687d6d5db02205a
BLAKE2b-256 2fe27648e12eef7af2129a5a8a601d29d028deeda2f932919b8820fddc1f61cb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.14-cp311-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 872dc108e16050023d0388b3a73bcc36c9a8ba3b96aca8c20632f587a7e12960
MD5 dc64bf737a23b967169223e704555853
BLAKE2b-256 a545d8ff38790bb559ba800e7d444157a64e36bbb9ae80c0b855f0f441f25feb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.14-cp311-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 8aa1170dd7dd0ef08b5d2a040506de3b5fd480b193d739b2ed246bf20d32a034
MD5 ec34f2f47b6bb936d42732742245169b
BLAKE2b-256 b4a0defd29260e619fd96ce4b18f0d0064a77dee3d49975fd28d0798c1c63bf0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.14-cp311-abi3-manylinux_2_28_ppc64le.whl
Algorithm Hash digest
SHA256 e92b525ce3a502a5ba4d90be43c966c1e4117fa598fc4792366b5161df02daa1
MD5 353003749c521793d84e9c88cadb26ea
BLAKE2b-256 ea3aa1b760a214445adbc7c0d241f5b844c5de3898146b93e84a26260d6adaf1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.14-cp311-abi3-manylinux_2_28_armv7l.whl
Algorithm Hash digest
SHA256 b233fab201dfc43ca9cbf5a90aaa81d5e5b833011fe73ab3584a6234b097d6e7
MD5 151ffacfd38ed7a3bc5a2a9aac40e1ac
BLAKE2b-256 4ba985fa21fa805a7aa6e1d1ba0f9005a7fc3b8d5322bfc2784166b64073ced7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.14-cp311-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 e751b5fed1b086843be226fe9f3fabf84518b4e8c82f7e8626cda866d219f5dc
MD5 e3a1551d1005e3d41ef847b2a3f3c9a4
BLAKE2b-256 80710c8b1d6043871d3ed2aced05a9326daa3f32bb7ff147944d71374723f8da

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.14-cp311-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 29c92fd2bb40ffeb95cbb306b96fefc07444c99bf7e52b1a4a369528f092784f
MD5 70552e8e2ca0727a4fba6c7fd3ca018a
BLAKE2b-256 371965e52c31fb2ce2d5cfd5704289d6bbe5aea404b10b3ead6797ec6d662dc0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.14-cp311-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 0eda5b46e435159668e3e88791bda467111ff56d16b57bc69d6ed82190d05abc
MD5 c3f4aa3f19cdb587f649e8305e9f4563
BLAKE2b-256 388fbeb3bc6617feedb7dd1fbcb03f5faeae5743f7a731e1c07f6fa0adecf9e9

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