Skip to main content

polars_utils/
version.rs

1use std::sync::{Arc, LazyLock, Mutex};
2
3static POLARS_NAME: LazyLock<Mutex<Arc<String>>> =
4    LazyLock::new(|| Mutex::new(Arc::new(String::from("Polars (standalone)"))));
5
6static POLARS_VERSION: LazyLock<Mutex<Arc<String>>> =
7    LazyLock::new(|| Mutex::new(Arc::new(String::from(env!("CARGO_PKG_VERSION")))));
8
9static POLARS_BUILD_COMMIT: LazyLock<Mutex<Arc<String>>> =
10    LazyLock::new(|| Mutex::new(Arc::new(String::from("<unknown>"))));
11
12/// Set the name Polars uses for e.g. file metadata.
13pub fn set_polars_lib_name(name: &str) {
14    *POLARS_NAME.lock().unwrap() = Arc::new(name.into());
15}
16
17/// Set the version Polars uses for e.g. file metadata.
18pub fn set_polars_lib_version(version: &str) {
19    *POLARS_VERSION.lock().unwrap() = Arc::new(version.into());
20}
21
22/// Set the build SHA Polars uses for e.g. file metadata.
23pub fn set_polars_lib_build_commit(sha: &str) {
24    *POLARS_BUILD_COMMIT.lock().unwrap() = Arc::new(sha.into());
25}
26
27/// Get the name Polars uses for e.g. file metadata.
28pub fn get_polars_lib_name() -> Arc<String> {
29    POLARS_NAME.lock().unwrap().clone()
30}
31
32/// Get the version Polars uses for e.g. file metadata.
33pub fn get_polars_lib_version() -> Arc<String> {
34    POLARS_VERSION.lock().unwrap().clone()
35}
36
37/// Get the build SHA Polars uses for e.g. file metadata.
38pub fn get_polars_lib_build_commit() -> Arc<String> {
39    POLARS_BUILD_COMMIT.lock().unwrap().clone()
40}