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.5.tar.gz (738.2 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.5-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.5-cp311-abi3-musllinux_1_2_i686.whl (37.2 MB view details)

Uploaded CPython 3.11+musllinux: musl 1.2+ i686

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

Uploaded CPython 3.11+musllinux: musl 1.2+ ARMv7l

rustac-0.9.5-cp311-abi3-musllinux_1_2_aarch64.whl (32.5 MB view details)

Uploaded CPython 3.11+musllinux: musl 1.2+ ARM64

rustac-0.9.5-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.5-cp311-abi3-manylinux_2_28_ppc64le.whl (32.6 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.28+ ppc64le

rustac-0.9.5-cp311-abi3-manylinux_2_28_armv7l.whl (24.9 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.28+ ARMv7l

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

Uploaded CPython 3.11+manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.11+macOS 11.0+ ARM64

rustac-0.9.5-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.5.tar.gz.

File metadata

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

File hashes

Hashes for rustac-0.9.5.tar.gz
Algorithm Hash digest
SHA256 775db537741cd1644edf2e411ebd0197f0f39f571311de1b6b96dba786090f93
MD5 5a5faeb80b6cd5c395a5af6fa62a68b5
BLAKE2b-256 1a7fc839074260494deb7ccd5deb503225198368849dfc5d614b8860c152cc89

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.5-cp311-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 56905434b34dd4b061f1afe07ff534cb91160648e9da1b8d47386f7d1bf821b7
MD5 b85cd13eadd10332edde764385b72103
BLAKE2b-256 ad9f371563ba34f85bdf9f636a488c4f0e7838c1a31f23d4ef024005962328ff

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.5-cp311-abi3-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 994993626e7ed1d970fa62eec67a90eea9981f2372ca3449e062ca4071bfe3aa
MD5 d145569391c576dcf7f01a3454006105
BLAKE2b-256 981480a97777a79a773ec39eb791a1ddb43c011e6b5558b44f07b6c1ddcf3d05

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.5-cp311-abi3-musllinux_1_2_armv7l.whl
Algorithm Hash digest
SHA256 432886395d5c6a955abe3039c11ebb2e44bc3bdcfe44fccfdf83b3590ee4637d
MD5 44a141ab888078a636284ab1db139ea7
BLAKE2b-256 c7e719688b60caf9742534f3a422b39d6a01b96a88f1d1e3784c0f061d7ebacc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.5-cp311-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 c2cf15ba98f39761a00fd12ae916288618477a18678d30d4ffefdbe0a8a54777
MD5 0bed94dac8dece00804ae01eed88d3ec
BLAKE2b-256 8f2d0effea93416023cdab70619966ab7fc72d8884f967c6e3c7b0bc9c717d65

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.5-cp311-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 63177d1ab8c1f3db12c1b94c8f332ec813eb98a1bf98e3aad82e408f993fb985
MD5 d39a67ddc91013eb3f1197cf0f8dd498
BLAKE2b-256 356a0ae185d80f9af83be19028e03c0f6f528148161e19ba1da3d11d04eaccac

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.5-cp311-abi3-manylinux_2_28_ppc64le.whl
Algorithm Hash digest
SHA256 dca523bd9addbe222f36913e0c26c7455b8261794f9083d693a7d3b2686df923
MD5 474ac1bcecfeebbc4f2fe3954158b72c
BLAKE2b-256 f34ea74a30f04bc89e710c9b4a9ce6d2363cce8923313aef8f14398e03ca4aa0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.5-cp311-abi3-manylinux_2_28_armv7l.whl
Algorithm Hash digest
SHA256 07ca4216b8f6ea89157fd6c466d0791aa4b36644969aa3f76d3ea6e05f0ba328
MD5 49af57a830f8401b8bc9f0f5f4fee178
BLAKE2b-256 a72abc61154359f8c8bdc007e84da3a54a9e33116bc7c76d11a675db29350d7a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.5-cp311-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 b51aa75dd2701f2d89c3046b4f15620d7f9cda4e522c655f3880950c13ff1c84
MD5 dad55b37e016cf0e258ee219e28a50ec
BLAKE2b-256 c57ec64d4cb369f49cc0e2db5a307c436e5fbb8eac4f8044c8fa19b7ea7cd670

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.5-cp311-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f16973fbab1b20d19dd72ac440c6abc3073d80c314ecc6a8b22fb8903d716117
MD5 6dd04d897353f19540f2123647b4ce9c
BLAKE2b-256 829e84a2c7273f23c334edf495d8d81913ef0a9df8704ca153dc99382f8ac923

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.9.5-cp311-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 2a343a83769c274cef299f9a9e23671180fe317e2b142305f5a67fae796fbf89
MD5 db05bd752b74f1e371c3bd936a09d20d
BLAKE2b-256 c3d68c43d5c478903a31b1980b5fc1151c5f8dc9b363d8e99f1b5e9809260ae2

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