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

Uploaded CPython 3.11+manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.11+macOS 11.0+ ARM64

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

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

rustac-0.7.0b2-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.0b2.tar.gz.

File metadata

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

File hashes

Hashes for rustac-0.7.0b2.tar.gz
Algorithm Hash digest
SHA256 e7e24ffed234b4ce8935fdde760ea91ce5f15b663673bd21e8036b02a6297df7
MD5 1bf89697cdb970caf5983803eee4297b
BLAKE2b-256 e490050ab22046ab2a72a21827756ae7d0de40b05b21452be6f6be466e3d4bbf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.7.0b2-cp311-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 54af9656231c3a390321920d52213f775854e084bac8db8b45eaaafe684dcd0d
MD5 f1d9a245b5252fb85e086035d7a58ca0
BLAKE2b-256 40c9cd29d8e7f4645b347558692636e08cb84853c650a0079c04fcec66902da2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.7.0b2-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4abf1f87f6b958a92a4a1ff919e1bffcad63f6176626bb8f7d5e1bac56b176f3
MD5 00d933bef4e81ae59d78b4e9bf8688fd
BLAKE2b-256 c8a68c9417c633c0de052f096e40401864ab452dd152c5d30c9cd3580987d89b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.7.0b2-cp311-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 24b4c1e8fb00024d47dadd9c7aa5487184e329badd07800316a3c8607d0d17ab
MD5 e487cbdeb74c7898880880f7a11135a8
BLAKE2b-256 674de60d9e03ca031844de584d27925334ba87b520210e6e13c13ac5b9e43542

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.7.0b2-cp311-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 50d11629850e235e06e62d6aeba1b8f04c2703acc9593bec04efba70a5c99d18
MD5 d837993a3928c57de290531d15972d37
BLAKE2b-256 938beab16d1676881d0d374c377ee2a75612dedc8f3be47dcd973285f0d467e5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.7.0b2-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 1246684c1141095d0694f13405f7671f790e92b52603e032d438e55679e59717
MD5 ed2caf0e1dc968461d50c1d993f366b0
BLAKE2b-256 afa1c2bff801c3ef1fc63ec9f54a8f2d0391375057b27b8fcad0104e38044c03

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.7.0b2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 13ce5648f7ed9293025f4da9d61fc555102371eca8489431ae62b0a26a7a8a65
MD5 34aef29355354d0238fc8e8a9c99b34a
BLAKE2b-256 4d8513aa5d92c64c4700596a8f3574854534663222bf2e544f2353af3d401b0f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.7.0b2-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 eea21ea5fa693b224441dcdcfb9b21d8817e65fe367d163f1dd5f02e51ab16a9
MD5 2a65928eccc1ae97c7ef1d4263fc7fd0
BLAKE2b-256 c595a6200b88ff06a1c0c4beb869b20a338383af0cf335bd6bd913b66831d7ef

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rustac-0.7.0b2-cp310-cp310-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 68cbd25a86e25429130b3bec4e2f8a8350bc8e5b38aa5b4c403b289cfaf1c093
MD5 94b95aef49b5a81555bb577895732999
BLAKE2b-256 03275fa228c2164a87cb58d4aadf6c68ad4275ff8c1f452a0ee6ef003b795a13

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