Skip to content

Commit

Permalink
chore: upgrade pyo3 to 0.21.0
Browse files Browse the repository at this point in the history
  • Loading branch information
messense committed Mar 28, 2024
1 parent c04d471 commit 3aecbf5
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 27 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected].3
- uses: mozilla-actions/[email protected].4

- run: cargo test
working-directory: pyo3-polars
Expand Down
10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
2 changes: 1 addition & 1 deletion example/derive_expression/expression_lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion example/derive_expression/expression_lib/src/distances.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use polars::datatypes::PlHashSet;
use polars::export::arrow::array::PrimitiveArray;
use polars::export::num::Float;
use polars::prelude::*;
Expand Down
8 changes: 3 additions & 5 deletions example/derive_expression/expression_lib/src/expressions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,7 @@ fn convert_timezone(input_fields: &[Field], kwargs: TimeZone) -> PolarsResult<Fi
#[polars_expr(output_type_func_with_kwargs=convert_timezone)]
fn change_time_zone(input: &[Series], kwargs: TimeZone) -> PolarsResult<Series> {
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())
}
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Original file line number Diff line number Diff line change
Expand Up @@ -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)?)?;
Expand Down
2 changes: 1 addition & 1 deletion pyo3-polars/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
2 changes: 1 addition & 1 deletion pyo3-polars/src/ffi/to_py.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<PyObject> {
pub(crate) fn to_py_array(array: ArrayRef, py: Python, pyarrow: &Bound<'_, PyModule>) -> PyResult<PyObject> {
let schema = Box::new(ffi::export_field_to_c(&ArrowField::new(
"",
array.data_type().clone(),
Expand Down
14 changes: 7 additions & 7 deletions pyo3-polars/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -162,7 +162,7 @@ impl<'a> FromPyObject<'a> for PyLazyFrame {

impl IntoPy<PyObject> 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
Expand Down Expand Up @@ -208,9 +208,9 @@ impl IntoPy<PyObject> 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)
Expand All @@ -228,7 +228,7 @@ impl IntoPy<PyObject> for PyDataFrame {
.map(|s| PySeries(s.clone()).into_py(py))
.collect::<Vec<_>>();

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)
}
Expand All @@ -237,9 +237,9 @@ impl IntoPy<PyObject> for PyDataFrame {
#[cfg(feature = "lazy")]
impl IntoPy<PyObject> 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<u8> = vec![];
ciborium::ser::into_writer(&self.0.logical_plan, &mut writer).unwrap();

Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[toolchain]
channel = "nightly-2023-10-12"
channel = "nightly-2024-02-23"

0 comments on commit 3aecbf5

Please sign in to comment.