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.6.tar.gz (739.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.9.6-cp311-abi3-musllinux_1_2_x86_64.whl (35.1 MB view details)

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

rustac-0.9.6-cp311-abi3-musllinux_1_2_i686.whl (37.2 MB view details)

Uploaded CPython 3.11+musllinux: musl 1.2+ i686

rustac-0.9.6-cp311-abi3-musllinux_1_2_armv7l.whl (32.5 MB view details)

Uploaded CPython 3.11+musllinux: musl 1.2+ ARMv7l

rustac-0.9.6-cp311-abi3-musllinux_1_2_aarch64.whl (32.6 MB view details)

Uploaded CPython 3.11+musllinux: musl 1.2+ ARM64

rustac-0.9.6-cp311-abi3-manylinux_2_28_x86_64.whl (29.3 MB view details)

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

rustac-0.9.6-cp311-abi3-manylinux_2_28_ppc64le.whl (32.6 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.28+ ppc64le

rustac-0.9.6-cp311-abi3-manylinux_2_28_armv7l.whl (25.0 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.28+ ARMv7l

rustac-0.9.6-cp311-abi3-manylinux_2_28_aarch64.whl (26.0 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.28+ ARM64

rustac-0.9.6-cp311-abi3-macosx_11_0_arm64.whl (24.2 MB view details)

Uploaded CPython 3.11+macOS 11.0+ ARM64

rustac-0.9.6-cp311-abi3-macosx_10_12_x86_64.whl (26.0 MB view details)

Uploaded CPython 3.11+macOS 10.12+ x86-64

File details

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

File metadata

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

File hashes

Hashes for rustac-0.9.6.tar.gz
Algorithm Hash digest
SHA256 dca3a6ec066a3881c52211d5074a1bdfde4f40c4a987bc5241ed7540cab5b443
MD5 ac9ac91b1c7357d33c5c4b83795ac469
BLAKE2b-256 45a19d3de05e6811af2ecfb3d8c5897ee44b7fcf8cc38fb50654ccc4e6015feb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.6-cp311-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 131825cd08535b35ce8013540dc9b3e1df77c591ffe047ffd3e18efe6260057c
MD5 3020664a741185b49f2d2e4f1f006a21
BLAKE2b-256 f89c132a5f5faddf0137fc2ae104eccd35fc9ed075bedca5b4ee2a643abfaa2e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.6-cp311-abi3-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 fe40e14fa586b3e01c577fcb371128c76ff3e58cd875d2825083c263f26ff4b2
MD5 560ee2f8174e488b20cb257507563612
BLAKE2b-256 a6fc8881f65b266cf0a0d8174c694663fead869cd7f237502bfc74d27db850db

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.6-cp311-abi3-musllinux_1_2_armv7l.whl
Algorithm Hash digest
SHA256 f476c326a8ba72c859a47e4da6ad7cdb1be0860f534ce0c32b7679808f31f28d
MD5 c3fdf7aab3e0689e5465e1c642009b71
BLAKE2b-256 a390907562309ae45205f19b802ef9b44b900730c27219760957e227c5776ae2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.6-cp311-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 b936bfb486f977b4c3bd20841e398469c2175fff6179f55e4adb43a87a2f2667
MD5 5ef7d38f0ed130c4775c128a1d1f1794
BLAKE2b-256 e337fc94dcd49f6eec17b3f77782ae3b96fcd38386155439bab913da7dafcec8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.6-cp311-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 743d2f3ffa01c5c4c7dab7693ea5d0bb7ebd565df7767e595d2789e21b20a85f
MD5 869d4d8159468c927fbb792e42ec261f
BLAKE2b-256 96a4f3949d90dcefd84df1ad11dfdcdc722e4fe18a49aa1ceac603eca8773c36

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.6-cp311-abi3-manylinux_2_28_ppc64le.whl
Algorithm Hash digest
SHA256 b61b8bc6882279479fd6cf76a0e3fb01c64c55e513af09abebadfe08651367f4
MD5 31b9df4244076c1c7b86c70d5b7a9c4a
BLAKE2b-256 d4d1fb158c7bd652eebae5ae4e73a724154d2dd00b941c543b6c17159533f28e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.6-cp311-abi3-manylinux_2_28_armv7l.whl
Algorithm Hash digest
SHA256 2b00621e0d4b1ed4f07c4c86617e5a2737c09873b8fb706c7d83a0c019abfcf2
MD5 9f5392e66e364fbd14baa50ab3a74f99
BLAKE2b-256 764988c1994114d7e45d7198b9929269d0b4768cf5b88f2e7fd3677b25cfe2c6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.6-cp311-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 389d278d7d410e3579b63c2a1748b3da35b63a040bfbdd55db3fd0456b8ae6a6
MD5 311f2a24c2afbe46902c736efface8f7
BLAKE2b-256 14d57b7d9b7be067d8d90ffd52901d173bc2cf6ef3def81abc77bbeab5994212

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.6-cp311-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 85b7a7a37826d0c924e52bf49db78057c4cef4b53b4f78a91b355584309d6ba1
MD5 da14473f81b48d8b59697d4cd1a0dbde
BLAKE2b-256 c6dc60c00db99a21cea9f606bad47ac66c1f8e41f185b7edcc18cf3b9f68cd60

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.6-cp311-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 2e1df6e2fbf98e6c77a4f4d106ba83cf66fa878d85ecd99aed29f16d16ae911f
MD5 4429e2848d96506899b459a8da14cf94
BLAKE2b-256 59c730a76de60a3aa677bc9d76510abd5c7c27c867113c4127e202c9fc504c91

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