Skip to main content

The power of Rust for the Python STAC ecosystem

Project description

rustac

GitHub Workflow Status GitHub Workflow Status PyPI - Version PyPI - License Contributor Covenant

A Python package for STAC using Rust under the hood.

[!TIP] While you can pronounce "rustac" however you'd like, we like "ruh-stac".

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

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

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

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.7.0b0.tar.gz (377.4 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.7.0b0-cp311-abi3-manylinux_2_28_aarch64.whl (20.8 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.28+ ARM64

rustac-0.7.0b0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (22.9 MB view details)

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

rustac-0.7.0b0-cp311-abi3-macosx_11_0_arm64.whl (19.0 MB view details)

Uploaded CPython 3.11+macOS 11.0+ ARM64

rustac-0.7.0b0-cp311-abi3-macosx_10_12_x86_64.whl (20.8 MB view details)

Uploaded CPython 3.11+macOS 10.12+ x86-64

rustac-0.7.0b0-cp310-cp310-manylinux_2_28_aarch64.whl (20.8 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

rustac-0.7.0b0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (22.9 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

rustac-0.7.0b0-cp310-cp310-macosx_11_0_arm64.whl (19.0 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

rustac-0.7.0b0-cp310-cp310-macosx_10_12_x86_64.whl (20.8 MB view details)

Uploaded CPython 3.10macOS 10.12+ x86-64

File details

Details for the file rustac-0.7.0b0.tar.gz.

File metadata

  • Download URL: rustac-0.7.0b0.tar.gz
  • Upload date:
  • Size: 377.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: maturin/1.8.3

File hashes

Hashes for rustac-0.7.0b0.tar.gz
Algorithm Hash digest
SHA256 741e72759d44225e5ec6b879bd1579d3ba47dea9cf3d8ae5824c78b7211d4cad
MD5 a83b062c5c21ce8c56676c95c0523e6e
BLAKE2b-256 993acd4357f1fb1ae23cfc7cc2c3e1627c596344ce7e6ef089ecfddff81bf33b

See more details on using hashes here.

File details

Details for the file rustac-0.7.0b0-cp311-abi3-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for rustac-0.7.0b0-cp311-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 cfd0613fbd16497db26ebd32aa5a684be54029f772ef9ad2cd75e6b7bfd9f060
MD5 b36a802f70e8b09d99dd33e7e4dce9c6
BLAKE2b-256 63736f146b60403d4e77d8adc4a7d7e18e47b1e55686cc890929932297a23503

See more details on using hashes here.

File details

Details for the file rustac-0.7.0b0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for rustac-0.7.0b0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 eba41463b0a70fe74a393f8801da5ad88f3cf50419a55815f50b178fb2de1028
MD5 3cfdd083881d5e1929769a2ecb5ec1fe
BLAKE2b-256 49dcbefafee343940031dd73bc3e8810b922d922f387d8b626c5444487bb2379

See more details on using hashes here.

File details

Details for the file rustac-0.7.0b0-cp311-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for rustac-0.7.0b0-cp311-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 609cc299839842f13901c10b84a7c6105240ba50a1d2f2dc5c076cf7fc32e421
MD5 e34ed6975f7922db6aa1b291236b0271
BLAKE2b-256 a105d920e7e372a6d903425715e90f22e55f1a366a2f039a3ef17ca9d99bbc36

See more details on using hashes here.

File details

Details for the file rustac-0.7.0b0-cp311-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for rustac-0.7.0b0-cp311-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 6d87f241d9db9b1edf62ddd36bc60aadf6dafc04c25945c7fee3e51776f62aae
MD5 9bb188fe708b5809b75eed4b2d979c8e
BLAKE2b-256 b284c097d121254be68e95f75521ffd6285bd9455c4c9816ac7b0e789be9dc16

See more details on using hashes here.

File details

Details for the file rustac-0.7.0b0-cp310-cp310-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for rustac-0.7.0b0-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 a03cc8b4b9210b934d08184c975cde16f62e311dc47340b6f40fd28c1d3d28c2
MD5 621d33abc0225c33767da0ad5b929a10
BLAKE2b-256 01ea49a3539bb9f185955af236eaefbc5b37a2a9f5a4125bd684d0be3920ec75

See more details on using hashes here.

File details

Details for the file rustac-0.7.0b0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for rustac-0.7.0b0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 45df90d9ff82c2aaac285bacc3a12cae8b77e627b369747636a286db8fa0ab98
MD5 673563c636f7527450919619c5e6b36a
BLAKE2b-256 20ba4555fb06cc2b58d7e18cb9f43dc7cabbdbd4191e32205d998eea62f607d2

See more details on using hashes here.

File details

Details for the file rustac-0.7.0b0-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for rustac-0.7.0b0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 20d65665a1c0eb2cdb40f2a17c56c67bed5eb17e4b29c454432481f28d9b2ffb
MD5 14ddbfafe90a631ab0d1146b77202cae
BLAKE2b-256 7f7f13ba85e3a9067f9c6ec7c34cc17a5f19f722850312bced063ddde5840ab4

See more details on using hashes here.

File details

Details for the file rustac-0.7.0b0-cp310-cp310-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for rustac-0.7.0b0-cp310-cp310-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 073b58a5efaee72124a15b19d7457d81153e7e06ffb7851583419698518afff0
MD5 f1f7b73c8b3c5566f28122ef6a120264
BLAKE2b-256 4eaf390f4d3c16a0b6d1f35b140ef7121b8da328ddba00ea403baa2fab85cdbd

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