diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index da9d92f..be85786 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -22,16 +22,16 @@ jobs: matrix: os: [ubuntu-latest, macos-latest] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - - uses: actions/setup-python@v4 + - uses: actions/setup-python@v5 with: python-version: '3.11' - name: Set up Rust run: rustup show - - uses: mozilla-actions/sccache-action@v0.0.3 + - uses: mozilla-actions/sccache-action@v0.0.4 - run: cargo test working-directory: pyo3-polars diff --git a/Cargo.toml b/Cargo.toml index 7e99523..d775a00 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,8 +8,8 @@ members = [ ] [workspace.dependencies] -polars = { version = "0.38.0", default-features = false } -polars-core = { version = "0.38.0", default-features = false } -polars-ffi = { version = "0.38.0", default-features = false } -polars-plan = { version = "0.38.0", default-feautres = false } -polars-lazy = { version = "0.38.0", default-features = false } +polars = { version = "0.38.2", default-features = false } +polars-core = { version = "0.38.2", default-features = false } +polars-ffi = { version = "0.38.2", default-features = false } +polars-plan = { version = "0.38.2", default-feautres = false } +polars-lazy = { version = "0.38.2", default-features = false } diff --git a/example/derive_expression/expression_lib/Cargo.toml b/example/derive_expression/expression_lib/Cargo.toml index 75ea2d5..d5f5054 100644 --- a/example/derive_expression/expression_lib/Cargo.toml +++ b/example/derive_expression/expression_lib/Cargo.toml @@ -10,7 +10,7 @@ crate-type = ["cdylib"] [dependencies] polars = { workspace = true, features = ["fmt", "dtype-date", "timezones"], default-features = false } -pyo3 = { version = "0.20", features = ["abi3-py38"] } +pyo3 = { version = "0.21.0", features = ["abi3-py38"] } pyo3-polars = { version = "*", path = "../../../pyo3-polars", features = ["derive"] } serde = { version = "1", features = ["derive"] } rayon = "1.7.0" diff --git a/example/derive_expression/expression_lib/src/distances.rs b/example/derive_expression/expression_lib/src/distances.rs index 943aa4a..beabf73 100644 --- a/example/derive_expression/expression_lib/src/distances.rs +++ b/example/derive_expression/expression_lib/src/distances.rs @@ -1,4 +1,3 @@ -use polars::datatypes::PlHashSet; use polars::export::arrow::array::PrimitiveArray; use polars::export::num::Float; use polars::prelude::*; diff --git a/example/derive_expression/expression_lib/src/expressions.rs b/example/derive_expression/expression_lib/src/expressions.rs index c41640e..d6ad507 100644 --- a/example/derive_expression/expression_lib/src/expressions.rs +++ b/example/derive_expression/expression_lib/src/expressions.rs @@ -199,9 +199,7 @@ fn convert_timezone(input_fields: &[Field], kwargs: TimeZone) -> PolarsResult PolarsResult { let input = &input[0]; - let ca = input.datetime()?; - - ca.clone() - .convert_time_zone(kwargs.tz) - .map(|ca| ca.into_series()) + let mut ca = input.datetime()?.clone(); + ca.set_time_zone(kwargs.tz)?; + Ok(ca.into_series()) } diff --git a/example/extend_polars_python_dispatch/extend_polars/Cargo.toml b/example/extend_polars_python_dispatch/extend_polars/Cargo.toml index aea69da..3dd6b56 100644 --- a/example/extend_polars_python_dispatch/extend_polars/Cargo.toml +++ b/example/extend_polars_python_dispatch/extend_polars/Cargo.toml @@ -12,6 +12,6 @@ crate-type = ["cdylib"] polars = { workspace = true, features = ["fmt"] } polars-core = { workspace = true } polars-lazy = { workspace = true } -pyo3 = { version = "0.20", features = ["extension-module"] } +pyo3 = { version = "0.21.0", features = ["extension-module"] } pyo3-polars = { version = "*", path = "../../../pyo3-polars", features = ["lazy"] } rayon = "1.6" diff --git a/example/extend_polars_python_dispatch/extend_polars/src/lib.rs b/example/extend_polars_python_dispatch/extend_polars/src/lib.rs index 1bc0ff6..e69ebc4 100644 --- a/example/extend_polars_python_dispatch/extend_polars/src/lib.rs +++ b/example/extend_polars_python_dispatch/extend_polars/src/lib.rs @@ -31,7 +31,7 @@ fn lazy_parallel_jaccard(pydf: PyLazyFrame, col_a: &str, col_b: &str) -> PyResul /// A Python module implemented in Rust. #[pymodule] -fn extend_polars(_py: Python, m: &PyModule) -> PyResult<()> { +fn extend_polars(_py: Python, m: &Bound<'_, PyModule>) -> PyResult<()> { m.add_function(wrap_pyfunction!(parallel_jaccard, m)?)?; m.add_function(wrap_pyfunction!(lazy_parallel_jaccard, m)?)?; m.add_function(wrap_pyfunction!(debug, m)?)?; diff --git a/pyo3-polars/Cargo.toml b/pyo3-polars/Cargo.toml index 6071faa..213ede7 100644 --- a/pyo3-polars/Cargo.toml +++ b/pyo3-polars/Cargo.toml @@ -16,7 +16,7 @@ polars-core = { workspace = true, default-features = false } polars-ffi = { workspace = true, optional = true } polars-lazy = { workspace = true, optional = true } polars-plan = { workspace = true, optional = true } -pyo3 = "0.20.0" +pyo3 = "0.21.0" pyo3-polars-derive = { version = "0.6.0", path = "../pyo3-polars-derive", optional = true } serde = { version = "1", optional = true } serde-pickle = { version = "1", optional = true } diff --git a/pyo3-polars/src/ffi/to_py.rs b/pyo3-polars/src/ffi/to_py.rs index 9b4fa3a..62b5883 100644 --- a/pyo3-polars/src/ffi/to_py.rs +++ b/pyo3-polars/src/ffi/to_py.rs @@ -4,7 +4,7 @@ use pyo3::ffi::Py_uintptr_t; use pyo3::prelude::*; /// Arrow array to Python. -pub(crate) fn to_py_array(array: ArrayRef, py: Python, pyarrow: &PyModule) -> PyResult { +pub(crate) fn to_py_array(array: ArrayRef, py: Python, pyarrow: &Bound<'_, PyModule>) -> PyResult { let schema = Box::new(ffi::export_field_to_c(&ArrowField::new( "", array.data_type().clone(), diff --git a/pyo3-polars/src/lib.rs b/pyo3-polars/src/lib.rs index 3e4479b..bc1710f 100644 --- a/pyo3-polars/src/lib.rs +++ b/pyo3-polars/src/lib.rs @@ -52,8 +52,8 @@ use crate::error::PyPolarsErr; use crate::ffi::to_py::to_py_array; use polars::export::arrow; use polars::prelude::*; +use pyo3::prelude::*; use pyo3::ffi::Py_uintptr_t; -use pyo3::{FromPyObject, IntoPy, PyAny, PyObject, PyResult, Python, ToPyObject}; #[cfg(feature = "lazy")] use {polars_lazy::frame::LazyFrame, polars_plan::logical_plan::LogicalPlan}; @@ -162,7 +162,7 @@ impl<'a> FromPyObject<'a> for PyLazyFrame { impl IntoPy for PySeries { fn into_py(self, py: Python<'_>) -> PyObject { - let polars = py.import("polars").expect("polars not installed"); + let polars = py.import_bound("polars").expect("polars not installed"); let s = polars.getattr("Series").unwrap(); match s.getattr("_import_from_c") { // Go via polars @@ -208,9 +208,9 @@ impl IntoPy for PySeries { let s = self.0.rechunk(); let name = s.name(); let arr = s.to_arrow(0, false); - let pyarrow = py.import("pyarrow").expect("pyarrow not installed"); + let pyarrow = py.import_bound("pyarrow").expect("pyarrow not installed"); - let arg = to_py_array(arr, py, pyarrow).unwrap(); + let arg = to_py_array(arr, py, &pyarrow).unwrap(); let s = polars.call_method1("from_arrow", (arg,)).unwrap(); let s = s.call_method1("rename", (name,)).unwrap(); s.to_object(py) @@ -228,7 +228,7 @@ impl IntoPy for PyDataFrame { .map(|s| PySeries(s.clone()).into_py(py)) .collect::>(); - let polars = py.import("polars").expect("polars not installed"); + let polars = py.import_bound("polars").expect("polars not installed"); let df_object = polars.call_method1("DataFrame", (pyseries,)).unwrap(); df_object.into_py(py) } @@ -237,9 +237,9 @@ impl IntoPy for PyDataFrame { #[cfg(feature = "lazy")] impl IntoPy for PyLazyFrame { fn into_py(self, py: Python<'_>) -> PyObject { - let polars = py.import("polars").expect("polars not installed"); + let polars = py.import_bound("polars").expect("polars not installed"); let cls = polars.getattr("LazyFrame").unwrap(); - let instance = cls.call_method1("__new__", (cls,)).unwrap(); + let instance = cls.call_method1("__new__", (cls.clone(),)).unwrap(); let mut writer: Vec = vec![]; ciborium::ser::into_writer(&self.0.logical_plan, &mut writer).unwrap(); diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 4a5741c..5f75e2c 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,2 +1,2 @@ [toolchain] -channel = "nightly-2023-10-12" +channel = "nightly-2024-02-23"