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.4.tar.gz (737.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.4-cp311-abi3-musllinux_1_2_x86_64.whl (35.0 MB view details)

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

rustac-0.9.4-cp311-abi3-musllinux_1_2_i686.whl (37.1 MB view details)

Uploaded CPython 3.11+musllinux: musl 1.2+ i686

rustac-0.9.4-cp311-abi3-musllinux_1_2_armv7l.whl (32.4 MB view details)

Uploaded CPython 3.11+musllinux: musl 1.2+ ARMv7l

rustac-0.9.4-cp311-abi3-musllinux_1_2_aarch64.whl (32.4 MB view details)

Uploaded CPython 3.11+musllinux: musl 1.2+ ARM64

rustac-0.9.4-cp311-abi3-manylinux_2_28_x86_64.whl (29.2 MB view details)

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

rustac-0.9.4-cp311-abi3-manylinux_2_28_ppc64le.whl (32.5 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.28+ ppc64le

rustac-0.9.4-cp311-abi3-manylinux_2_28_armv7l.whl (24.8 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.28+ ARMv7l

rustac-0.9.4-cp311-abi3-manylinux_2_28_aarch64.whl (25.9 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.28+ ARM64

rustac-0.9.4-cp311-abi3-macosx_11_0_arm64.whl (24.1 MB view details)

Uploaded CPython 3.11+macOS 11.0+ ARM64

rustac-0.9.4-cp311-abi3-macosx_10_12_x86_64.whl (25.9 MB view details)

Uploaded CPython 3.11+macOS 10.12+ x86-64

File details

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

File metadata

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

File hashes

Hashes for rustac-0.9.4.tar.gz
Algorithm Hash digest
SHA256 f32cfbe157dd2390ac7ba24a09997fecd28a94d2fc04d75ca2d3bef9f9a5eb70
MD5 573d29fab52fa5ebf4de7abccf5bda64
BLAKE2b-256 fd143ac908df8229ad4910d3b6f9501f66b6d255af3deaab4df1f7264b187bd9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.4-cp311-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 e195d8f8e285c4a88c89e2e9a3e73ebb6f87e00439802840f25b72011b0a0862
MD5 fc1bec76ec4809249295e3b437a0c438
BLAKE2b-256 696059851aa4b02aeabce4a642d3a93439b7f56686d3d21f095d130ed50648e2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.4-cp311-abi3-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 2d55242da92eab8a2140e1b28e2f04bb804d2cf4c56c7d582773a20fc941e202
MD5 afa621952f6122f68ec93b881fc13f25
BLAKE2b-256 3c9e1ae08837259119730afec1205952822520f9dda61aeca67c4b347a8908d7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.4-cp311-abi3-musllinux_1_2_armv7l.whl
Algorithm Hash digest
SHA256 d8f39a6780ab0fe6ee4a3a999ea01cd90f0ddb2f897dee17f8a0b1aa9935b0e5
MD5 dd5f737a11edcfd3d8525a1b131f0586
BLAKE2b-256 2b08691e7e62ffe589fe46d2381dbaf81494f8894c1c9a4c9ae486f9598254e1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.4-cp311-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 7a7b951c9bd96dbc890c5a4024d701440c2622bdb17739edf9684454206e9efe
MD5 e94827f0477cf822dd333b423d49140b
BLAKE2b-256 51b7ddee6660d667039e3cc6b5ebfa93bbe0c2255247a54e37e32797f2b97718

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.4-cp311-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 ff94bec516ea831f4936ef4e5dc85f173f0a7357a3b7337befb81b7d4469275d
MD5 a29a015bfc7c494f09ad3b7a9ce3d05e
BLAKE2b-256 54fed8d5baffeb1025797b445d3de9a215e03ead3a7ff4e903ae55b272fd1cb7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.4-cp311-abi3-manylinux_2_28_ppc64le.whl
Algorithm Hash digest
SHA256 68cfcfec847bd15497ec72157458cdc749143ab40edb612e4dc7ae76a98bce61
MD5 0c45389223f4a40afe150a57ae3634cb
BLAKE2b-256 4b01573f24919ad5eb480980655d40bdb2613e99aab823347ddc740f50aae959

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.4-cp311-abi3-manylinux_2_28_armv7l.whl
Algorithm Hash digest
SHA256 ad18ae539c28ab01dd0613b318f7217080eaae7a619bcf92cc131fddffda586b
MD5 e65b071b7e12d8ac98d08f442af27080
BLAKE2b-256 781035d5a91440bb273e71e40bbc0f1db4e7825ba5fa12ca35ed588867dbd4eb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.4-cp311-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 e8850e7c647ac1f397efdfe94b5cf05d76174a9e155fd55528f8f0bff71f01ab
MD5 4d1364a39d0d29e291a23814388e16a0
BLAKE2b-256 cd95741df1403627d310cc1e6b787410e722ffd551adcab9c3ca7761e21d0200

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.4-cp311-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 57560be6f26885315c83c817db0cf80cc0245db9645c431526bd7e0496ed5450
MD5 d5caca65ea16f1183685cbfc6730666f
BLAKE2b-256 6bbc1cba877a86f803ce6a3db71001c79b63506237c5e1ffba410c8e3fca3379

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.4-cp311-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 cb88de1a0effe0bdfb9d0835ac713ab663f083e49ea001f1f13e21782c930f2c
MD5 fcb911267cae82a285cc8cc98e215cba
BLAKE2b-256 6ea23ca8e91b4a74533de89ae7a62c2cc5a223b563b9368c8cdec346733fb577

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