Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
### Added

- Source distribution to PyPI publish ([#92](https://github.com/stac-utils/rustac-py/pull/92))
- `rustac.sha` ([#99](https://github.com/stac-utils/rustac-py/pull/99))

### Fixed

Expand Down
42 changes: 42 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ tokio = { version = "1.44.0", features = ["rt-multi-thread"] }
pyo3-log = "0.12.1"
tracing = "0.1.41"

[build-dependencies]
cargo-lock = "10"

[patch.crates-io]
# TODO unpatch cql2 when we upgrade geoarrow to use geo v0.30
cql2 = { git = "https://github.com/gadomski/cql2-rs", branch = "geo-v0.29" }
12 changes: 12 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
use cargo_lock::Lockfile;

fn main() {
let lockfile = Lockfile::load("Cargo.lock").unwrap();
let package = lockfile
.packages
.into_iter()
.find(|package| package.name.as_str() == "rustac")
.unwrap();
let precise = package.source.unwrap().precise().unwrap().to_string();
println!("cargo:rustc-env=RUSTAC_SHA={}", precise);
}
1 change: 1 addition & 0 deletions docs/api/version.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ description: Return this package's version or the version of an upstream

# Version

::: rustac.sha
::: rustac.version
9 changes: 9 additions & 0 deletions rustac.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -453,3 +453,12 @@ def version(
>>> rustac.version("duckdb")
"1.0.0"
"""

def sha() -> str:
"""
Returns the SHA of the underlying rustac crate.

Examples:
>>> rustac.sha()
"4d6a60a3df1386922285191aba95a76ec704a8b4"
"""
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ fn rustac(py: Python<'_>, m: &Bound<'_, PyModule>) -> PyResult<()> {
m.add_function(wrap_pyfunction!(read::read, m)?)?;
m.add_function(wrap_pyfunction!(search::search, m)?)?;
m.add_function(wrap_pyfunction!(search::search_to, m)?)?;
m.add_function(wrap_pyfunction!(version::sha, m)?)?;
m.add_function(wrap_pyfunction!(version::version, m)?)?;
m.add_function(wrap_pyfunction!(walk::walk, m)?)?;
m.add_function(wrap_pyfunction!(write::write, m)?)?;
Expand Down
6 changes: 6 additions & 0 deletions src/version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,9 @@ pub fn version(name: Option<String>) -> Option<String> {
Some(env!("CARGO_PKG_VERSION").to_string())
}
}

#[pyfunction]
pub fn sha() -> String {
// This environment variable is set in the build script
env!("RUSTAC_SHA").to_string()
}
4 changes: 4 additions & 0 deletions tests/test_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@ def test_version() -> None:
assert rustac.version("stac") is not None
assert rustac.version("stac-api") is not None
assert rustac.version("stac-duckdb") is not None


def test_sha() -> None:
assert rustac.sha() is not None
Loading