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.10.tar.gz (745.8 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.10-cp311-abi3-musllinux_1_2_x86_64.whl (37.0 MB view details)

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

rustac-0.9.10-cp311-abi3-musllinux_1_2_i686.whl (39.3 MB view details)

Uploaded CPython 3.11+musllinux: musl 1.2+ i686

rustac-0.9.10-cp311-abi3-musllinux_1_2_armv7l.whl (34.3 MB view details)

Uploaded CPython 3.11+musllinux: musl 1.2+ ARMv7l

rustac-0.9.10-cp311-abi3-musllinux_1_2_aarch64.whl (34.4 MB view details)

Uploaded CPython 3.11+musllinux: musl 1.2+ ARM64

rustac-0.9.10-cp311-abi3-manylinux_2_28_x86_64.whl (31.2 MB view details)

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

rustac-0.9.10-cp311-abi3-manylinux_2_28_ppc64le.whl (34.5 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.28+ ppc64le

rustac-0.9.10-cp311-abi3-manylinux_2_28_armv7l.whl (26.6 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.28+ ARMv7l

rustac-0.9.10-cp311-abi3-manylinux_2_28_aarch64.whl (27.8 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.28+ ARM64

rustac-0.9.10-cp311-abi3-macosx_11_0_arm64.whl (26.1 MB view details)

Uploaded CPython 3.11+macOS 11.0+ ARM64

rustac-0.9.10-cp311-abi3-macosx_10_12_x86_64.whl (27.8 MB view details)

Uploaded CPython 3.11+macOS 10.12+ x86-64

File details

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

File metadata

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

File hashes

Hashes for rustac-0.9.10.tar.gz
Algorithm Hash digest
SHA256 86ff0774125350b3f5b6c17121c09607ff0adf65e7b953559738c2c91a695085
MD5 e85c2352a668a1a04fb34fe0d8b25802
BLAKE2b-256 7d23af2d360746f3b882b5df0b4f109a9910b51dac7bdb1eb5ef5dd77667a523

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.10-cp311-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 314a2aee967f8c55f33ad359c483dc0ccdbe2a7046b550feee32f9af9ac50915
MD5 c4e8c5db10b50ed1fa9cba39293d1889
BLAKE2b-256 933d11442fc1bdd0d4c7eca15f7c6f0ff4868945c1a9e016181ae07201954d1c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.10-cp311-abi3-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 e4e9e65c3adbcdf565563f98e08194895f8bcb61450c43d77f086aa9694e39e6
MD5 85e8a6c072fde4690ae6659b28aa6c81
BLAKE2b-256 9c042d8fa2f991416d4a255db5fb2d0a6f2c34aeea9a557aad1d1ce3086f31a1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.10-cp311-abi3-musllinux_1_2_armv7l.whl
Algorithm Hash digest
SHA256 f7d2ed10aaec229dfc6052897cbdd8c6f45ffcec4b8645f0deef0980f483aa55
MD5 f86241d70cdfd788c08983c8e3ae27a7
BLAKE2b-256 1eb454410068c06a039a40596a912e950b9225ea19d9e7f6111d01e376d83912

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.10-cp311-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 75c90cb5ea6391e1f01a882fd9fa8b65477cafdade4217880abb8031416c1611
MD5 9e48b153b986a796e6f636feff9a9847
BLAKE2b-256 48c16a292aae532a79c4caff81cd2e5db6b78a07951ecec828837c5f4c4b3631

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.10-cp311-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d2a10cdcd1382bc5f91c8d46f5a9be7ce5ae68a9a97c438ca2610a033fd1d82f
MD5 e4de6544931ec91a9317e8cc1cbb7681
BLAKE2b-256 746fdd2e2b3eb9a1784607b42063d0c9c1c0200d06aba034cf64f1d0faf81fe2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.10-cp311-abi3-manylinux_2_28_ppc64le.whl
Algorithm Hash digest
SHA256 f342e88eaaaa38c070d72c138324a930da2e51d094eac7c0eb7c5ffefd60ee33
MD5 4b0d664ca2e852992b3bad2ea8ef4f13
BLAKE2b-256 6ceeafe99469a6cc5523b050ab3dc433012bce8bf96587162363b9677a929871

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.10-cp311-abi3-manylinux_2_28_armv7l.whl
Algorithm Hash digest
SHA256 6d8716126a3f9cf6df754c186aec3889ae5d0a3287b9bf6a3c972da2fc63543f
MD5 77836e7e72ebe3206e52b4e18a0ace74
BLAKE2b-256 b36feaae405dde780ea8a0bca5843baaf7ca903df2cf172fd082b0466a0289fc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.10-cp311-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 aa85da1fc329597579e68ab3a14782b5b259f717d9ad40560d7491425eb95245
MD5 88f2f762f812a9b438984b3a7c680821
BLAKE2b-256 3b863839a4d9b35cb3f64213095d426eca682261d09ca8a00445f7149e62b0f5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.10-cp311-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b376b1205fe8ad4ba4b1ab1b6fb103b333caaa488d110c376f223ead8d48e5ff
MD5 2e543ee70669ea249d2f400fc79bb19e
BLAKE2b-256 44251bf94703221b3066fefd6d2df14daa25fdd2f1771c1f73ea66ce0e842801

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.10-cp311-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 643982fbf2a08860c5869e1182dabd61cae58d74d9eededca5877ff6c1808e08
MD5 d67c9aa5bf785e3008eff2bfc840f416
BLAKE2b-256 fa0d1b2849dec4308ed49f7df4ed5a9c36962d555a48be5306c826031b48d081

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