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.2.tar.gz (730.6 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.2-cp311-abi3-musllinux_1_2_x86_64.whl (35.2 MB view details)

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

rustac-0.9.2-cp311-abi3-musllinux_1_2_i686.whl (37.5 MB view details)

Uploaded CPython 3.11+musllinux: musl 1.2+ i686

rustac-0.9.2-cp311-abi3-musllinux_1_2_armv7l.whl (32.8 MB view details)

Uploaded CPython 3.11+musllinux: musl 1.2+ ARMv7l

rustac-0.9.2-cp311-abi3-musllinux_1_2_aarch64.whl (33.3 MB view details)

Uploaded CPython 3.11+musllinux: musl 1.2+ ARM64

rustac-0.9.2-cp311-abi3-manylinux_2_28_x86_64.whl (29.7 MB view details)

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

rustac-0.9.2-cp311-abi3-manylinux_2_28_ppc64le.whl (33.2 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.28+ ppc64le

rustac-0.9.2-cp311-abi3-manylinux_2_28_armv7l.whl (25.5 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.28+ ARMv7l

rustac-0.9.2-cp311-abi3-manylinux_2_28_aarch64.whl (26.7 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.28+ ARM64

rustac-0.9.2-cp311-abi3-macosx_11_0_arm64.whl (22.7 MB view details)

Uploaded CPython 3.11+macOS 11.0+ ARM64

rustac-0.9.2-cp311-abi3-macosx_10_12_x86_64.whl (24.4 MB view details)

Uploaded CPython 3.11+macOS 10.12+ x86-64

File details

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

File metadata

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

File hashes

Hashes for rustac-0.9.2.tar.gz
Algorithm Hash digest
SHA256 d04097a9d558506688fcddd477c58b2f9102066ca866f043d9d429d397fc2850
MD5 1e54d4b7b7d50339265c89d4c9a42c10
BLAKE2b-256 81abfcd3e86a2787ae79ed67381cbaa3747fe8d1e91ac0ea1de8731f6d749424

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.2-cp311-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 0aa0529a0b30943f065afe1bb15098f3a9c89e1124b0790d55b17102165ab867
MD5 927ad836b3ec407a3f815f680cea0759
BLAKE2b-256 7a77fe07f1a78a8ea3e450e29df290f09497076494116972027261c13cc8a3a7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.2-cp311-abi3-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 3ca32206fdd0b8982067304e726422cc7d70a1f676eb6468be069e0ba0cfb5b4
MD5 99c52d801c02cdcd5c0d2ee25d687737
BLAKE2b-256 f66d533f589da97b576efb2985142ee11d8db23b0375139a26b9ac2ebc455c7e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.2-cp311-abi3-musllinux_1_2_armv7l.whl
Algorithm Hash digest
SHA256 53a12372cb8308e41d80bfd9a7a8a330426992d70ff62160c497219f80659e70
MD5 73fcd7850318ba14e4fd57c979302caf
BLAKE2b-256 2dab954057314bbe82f416f565d8bd404dee495bf7133ad03c288c9444c4fe09

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.2-cp311-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 4376f7010e47371d0145ccf374fcf0b4a2c7ef1915a246d405152c8cb7925796
MD5 90a8a4061ab1958cd06b80f3e91ee005
BLAKE2b-256 ea7db72fbd4e9d8606dc6c823b62ac890fdcaa3e85edb54dd876f86ec9088f26

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.2-cp311-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 948942bda293b97c9c54903f45b40c58cfe501add7af46cf7b5928d5a490d7ad
MD5 4a88d346ec77e59622e470ca7e73dc50
BLAKE2b-256 7d07b8352c245968dea5b5ca5aff3ef7889b597f50b77befb8231451e4ed25c2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.2-cp311-abi3-manylinux_2_28_ppc64le.whl
Algorithm Hash digest
SHA256 0bf2efac6b6d211131bc30b5fa6f46fd51270be090f5b0c868fd4588902861f3
MD5 f090b5a5b73bc19a733ba6e19c43bfec
BLAKE2b-256 b8977405440cff8359197ab7ab9d582036eac1003dce83e455b06fdeaceeb60c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.2-cp311-abi3-manylinux_2_28_armv7l.whl
Algorithm Hash digest
SHA256 8e8386343ff7e4ccfed992e914f9e0f32ab7db5ddd9caa69dc9223dce1bec043
MD5 7333e6ef7f29f828363e0df5e0f67f86
BLAKE2b-256 5f0e7f5c28b9edcb59de81039e5a166f1209ee2b71d70298606f5cfebab5de46

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.2-cp311-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 38e38595bb7c1ad9b29a64632b39f2f8c106bb70f64fd9b2dca882ab71aed78d
MD5 9ca9b1d361e532ab13f339aa5a82a6ea
BLAKE2b-256 b318a5d90cdf0bda3b5323c86ae6152ff4d952a0f51f97576e27c6724525e32a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.2-cp311-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3dc0ddc0e07145cd6265c6e2d7ea3f426cfd77075b05550cae588f4ffc4179f7
MD5 a92dfaf16bafaa9d3928468c6a48a761
BLAKE2b-256 31fa6e76d679b54a608ae5a65e52426ff3fdc2e8b6dc01cb61fede3394d07530

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.2-cp311-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 be71cd3f4524616d476e90d77a206dfa682eea9123a041fe818092a8c8634d5e
MD5 d8081a178c818cb1ece16e5f6448e1c3
BLAKE2b-256 c34b639152b0f8662c4d92d381c319c7863df87a354a8e5994249d6e5e0dc428

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