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
6 changes: 5 additions & 1 deletion crates/polars-python/src/c_api/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#[cfg(feature = "allocator")]
pub mod allocator;

// Since Python Polars cannot share its version into here and we need to be able to build this
// package correctly without `py-polars`, we need to mirror the version here.
pub static PYPOLARS_VERSION: &str = "1.32.1";

use pyo3::prelude::*;
use pyo3::{wrap_pyfunction, wrap_pymodule};

Expand Down Expand Up @@ -414,7 +418,7 @@ pub fn polars(py: Python, m: &Bound<PyModule>) -> PyResult<()> {
.unwrap();

// Build info
m.add("__version__", env!("CARGO_PKG_VERSION"))?;
m.add("__version__", PYPOLARS_VERSION)?;

// Plugins
#[cfg(feature = "ffi_plugin")]
Expand Down
22 changes: 22 additions & 0 deletions py-polars/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1 +1,23 @@
const fn _const_str_equality(l: &str, r: &str) -> bool {
if l.len() != r.len() {
return false;
}

let mut i = 0;
while i < l.len() {
if l.as_bytes()[i] != r.as_bytes()[i] {
return false;
}
i += 1;
}

true
}
const _CORRECT_VERSION_SET: () = const {
let module_version = polars_python::c_api::PYPOLARS_VERSION;
let package_version = env!("CARGO_PKG_VERSION");

// You probably need to update the PYPOLARS_VERSION, to match the package version.
assert!(_const_str_equality(module_version, package_version));
};
pub use polars_python::c_api::polars;
7 changes: 7 additions & 0 deletions py-polars/tests/unit/test_init.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import importlib

import pytest

import polars as pl
Expand Down Expand Up @@ -41,3 +43,8 @@ def test_type_aliases_deprecated() -> None:

def test_import_all() -> None:
exec("from polars import *")


def test_version() -> None:
# This has already gone wrong once (#23940), preventing future problems.
assert pl.__version__ == importlib.metadata.version("polars")
Loading