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

Uploaded CPython 3.11+manylinux: glibc 2.28+ ARM64

rustac-0.7.0b1-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.0b1-cp311-abi3-macosx_11_0_arm64.whl (19.0 MB view details)

Uploaded CPython 3.11+macOS 11.0+ ARM64

rustac-0.7.0b1-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.0b1-cp310-cp310-manylinux_2_28_aarch64.whl (20.8 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

rustac-0.7.0b1-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.0b1-cp310-cp310-macosx_11_0_arm64.whl (19.0 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

rustac-0.7.0b1-cp310-cp310-macosx_10_12_x86_64.whl (20.9 MB view details)

Uploaded CPython 3.10macOS 10.12+ x86-64

File details

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

File metadata

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

File hashes

Hashes for rustac-0.7.0b1.tar.gz
Algorithm Hash digest
SHA256 db73b350f220b4caec27cdfccb073d869f2c156f7a5d38af2c104824108f43d3
MD5 8cfc348d597832920cf701ae59064597
BLAKE2b-256 c236300fd6f5dd9e4d804f08aa235f23dc348f44355fed61452f61df38e0ca31

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.7.0b1-cp311-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 2f72921a39d706e6762a43f4d023b25086a66dcfe4710ef6bbf4a2ba709194bc
MD5 5123351251e390d18d860a9a327d5b5f
BLAKE2b-256 8284bff7f6bcba475d430ed31877e4298b06cb74fc870cae0aed662604945370

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.7.0b1-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a1a3f807b9ddc7763fea910397f78dbd23f9bcae4b3fa84cc827b39d1c0be15d
MD5 b8535a00a3db7900c5c0c439e821441f
BLAKE2b-256 64461281a71d3c5b4107263b8bdd0d87bcc8ed358d96f0fdfebd14440d30fffb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.7.0b1-cp311-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 74a45ac4aaf204d615fa152c76974c12d1cb3638dfc80ff0317e0c3e7096e6da
MD5 4c0b53cd01b19cfd20a1dfce92fc1c99
BLAKE2b-256 3e0af52adb6ced47b56dd8c366c945e677895879790e4d3ccdb84f405f57dee3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.7.0b1-cp311-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 c5abeff6307beef5e31f241dafb04c282a6b264251dfe76371bdd75acdde0994
MD5 0cf60c2e89fcd6d4e314ca0b40ae5d67
BLAKE2b-256 7b686b259935a2841ed091262373abab046ed789046012f2669439639e1d65b7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.7.0b1-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 e09fdfe77324379c6ebf159a2ac7543b8cb692f2ebcc2db37f9abd45df94f8d8
MD5 a756f403d76c70e120bf69508cec0bf9
BLAKE2b-256 d11b90160873948d8c443b376449a1d590c3ed17fe3ce980e66dc273325e56fb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.7.0b1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 680a6c853adacc39eaedd5aff21d63061f29bff1fa09df132d71df63330df123
MD5 f1bb1774be4dc2ff555d23cbc8b1ce85
BLAKE2b-256 8e048368146df9b23d803c8ceb9f4599040d92f578e061bd12b82ef1f011532f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.7.0b1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 db9930cffe8694cb9366f4c46a70d4342e52dcb909d3fa653488e0a171ef4953
MD5 e6629f56960c45a8ffd8950c28075d28
BLAKE2b-256 c18a684dd0c3ce727cebfbf221ecbd621e58989a13c620a1c1f8f374cc9656c9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.7.0b1-cp310-cp310-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 d1406eba3ea842fcba177ff18cbcdd5206357fabb2285d9f6be42ace07aa0578
MD5 704afbe8982dc6c97f6ef21f87833547
BLAKE2b-256 c2d250c35304f1506f4d766646908d2cb74992779d7f7a84239a7e5bdbcdd023

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