From e1dfcdd186f2ddcc120a1e71bb14b90018c6dd89 Mon Sep 17 00:00:00 2001 From: Stijn de Gooijer Date: Wed, 23 Oct 2024 08:45:18 +0200 Subject: [PATCH] build: Revert PyO3 version back to `0.21` (#19376) --- Cargo.lock | 31 +++++++++---------- Cargo.toml | 3 +- crates/polars-python/Cargo.toml | 4 ++- crates/polars-python/src/conversion/mod.rs | 10 +----- crates/polars-python/src/file.rs | 9 +----- .../src/lazyframe/visitor/expr_nodes.rs | 16 +++++----- crates/polars-utils/src/python_function.rs | 8 +---- 7 files changed, 30 insertions(+), 51 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 88e3aca9fe4b..6c5dd1cf83f5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2102,7 +2102,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4979f22fdb869068da03c9f7528f8297c6fd2606bc3a4affe42e6a823fdb8da4" dependencies = [ "cfg-if", - "windows-targets 0.48.5", + "windows-targets 0.52.6", ] [[package]] @@ -2370,9 +2370,8 @@ dependencies = [ [[package]] name = "numpy" -version = "0.22.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf314fca279e6e6ac2126a4ff98f26d88aa4ad06bc68fb6ae5cf4bd706758311" +version = "0.21.0" +source = "git+https://github.com/stinodego/rust-numpy.git?rev=9ba9962ae57ba26e35babdce6f179edf5fe5b9c8#9ba9962ae57ba26e35babdce6f179edf5fe5b9c8" dependencies = [ "libc", "ndarray", @@ -3396,9 +3395,9 @@ dependencies = [ [[package]] name = "pyo3" -version = "0.22.4" +version = "0.21.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00e89ce2565d6044ca31a3eb79a334c3a79a841120a98f64eea9f579564cb691" +checksum = "a5e00b96a521718e08e03b1a622f01c8a8deb50719335de3f60b3b3950f069d8" dependencies = [ "cfg-if", "chrono", @@ -3406,7 +3405,7 @@ dependencies = [ "inventory", "libc", "memoffset", - "once_cell", + "parking_lot", "portable-atomic", "pyo3-build-config", "pyo3-ffi", @@ -3416,9 +3415,9 @@ dependencies = [ [[package]] name = "pyo3-build-config" -version = "0.22.4" +version = "0.21.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8afbaf3abd7325e08f35ffb8deb5892046fcb2608b703db6a583a5ba4cea01e" +checksum = "7883df5835fafdad87c0d888b266c8ec0f4c9ca48a5bed6bbb592e8dedee1b50" dependencies = [ "once_cell", "target-lexicon", @@ -3426,9 +3425,9 @@ dependencies = [ [[package]] name = "pyo3-ffi" -version = "0.22.4" +version = "0.21.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec15a5ba277339d04763f4c23d85987a5b08cbb494860be141e6a10a8eb88022" +checksum = "01be5843dc60b916ab4dad1dca6d20b9b4e6ddc8e15f50c47fe6d85f1fb97403" dependencies = [ "libc", "pyo3-build-config", @@ -3436,9 +3435,9 @@ dependencies = [ [[package]] name = "pyo3-macros" -version = "0.22.4" +version = "0.21.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15e0f01b5364bcfbb686a52fc4181d412b708a68ed20c330db9fc8d2c2bf5a43" +checksum = "77b34069fc0682e11b31dbd10321cbf94808394c56fd996796ce45217dfac53c" dependencies = [ "proc-macro2", "pyo3-macros-backend", @@ -3448,11 +3447,11 @@ dependencies = [ [[package]] name = "pyo3-macros-backend" -version = "0.22.4" +version = "0.21.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a09b550200e1e5ed9176976d0060cbc2ea82dc8515da07885e7b8153a85caacb" +checksum = "08260721f32db5e1a5beae69a55553f56b99bd0e1c3e6e0a5e8851a9d0f5a85c" dependencies = [ - "heck 0.5.0", + "heck 0.4.1", "proc-macro2", "pyo3-build-config", "quote", diff --git a/Cargo.toml b/Cargo.toml index 473ab2e49b0f..64637e51efd8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -60,13 +60,12 @@ memmap = { package = "memmap2", version = "0.7" } multiversion = "0.7" ndarray = { version = "0.15", default-features = false } num-traits = "0.2" -numpy = "0.22" object_store = { version = "0.10", default-features = false } once_cell = "1" parking_lot = "0.12" percent-encoding = "2.3" pin-project-lite = "0.2" -pyo3 = "0.22" +pyo3 = "0.21" rand = "0.8" rand_distr = "0.4" raw-cpuid = "11" diff --git a/crates/polars-python/Cargo.toml b/crates/polars-python/Cargo.toml index 0bb9f3424edc..8078e919c38e 100644 --- a/crates/polars-python/Cargo.toml +++ b/crates/polars-python/Cargo.toml @@ -34,7 +34,9 @@ itoa = { workspace = true } libc = { workspace = true } ndarray = { workspace = true } num-traits = { workspace = true } -numpy = { workspace = true } +# TODO: Pin to released version once NumPy 2.0 support is merged +# https://github.com/PyO3/rust-numpy/issues/409 +numpy = { git = "https://github.com/stinodego/rust-numpy.git", rev = "9ba9962ae57ba26e35babdce6f179edf5fe5b9c8", default-features = false } once_cell = { workspace = true } pyo3 = { workspace = true, features = ["abi3-py39", "chrono", "multiple-pymethods"] } recursive = { workspace = true } diff --git a/crates/polars-python/src/conversion/mod.rs b/crates/polars-python/src/conversion/mod.rs index ac3286aaab36..16abea471d7f 100644 --- a/crates/polars-python/src/conversion/mod.rs +++ b/crates/polars-python/src/conversion/mod.rs @@ -604,20 +604,12 @@ impl IntoPy for Wrap<&Schema> { } } -#[derive(Debug)] +#[derive(Clone, Debug)] #[repr(transparent)] pub struct ObjectValue { pub inner: PyObject, } -impl Clone for ObjectValue { - fn clone(&self) -> Self { - Python::with_gil(|py| Self { - inner: self.inner.clone_ref(py), - }) - } -} - impl Hash for ObjectValue { fn hash(&self, state: &mut H) { let h = Python::with_gil(|py| self.inner.bind(py).hash().expect("should be hashable")); diff --git a/crates/polars-python/src/file.rs b/crates/polars-python/src/file.rs index 074e06115993..1aab5d9c5829 100644 --- a/crates/polars-python/src/file.rs +++ b/crates/polars-python/src/file.rs @@ -17,18 +17,11 @@ use pyo3::types::{PyBytes, PyString, PyStringMethods}; use crate::error::PyPolarsErr; use crate::prelude::resolve_homedir; +#[derive(Clone)] pub struct PyFileLikeObject { inner: PyObject, } -impl Clone for PyFileLikeObject { - fn clone(&self) -> Self { - Python::with_gil(|py| Self { - inner: self.inner.clone_ref(py), - }) - } -} - /// Wraps a `PyObject`, and implements read, seek, and write for it. impl PyFileLikeObject { /// Creates an instance of a `PyFileLikeObject` from a `PyObject`. diff --git a/crates/polars-python/src/lazyframe/visitor/expr_nodes.rs b/crates/polars-python/src/lazyframe/visitor/expr_nodes.rs index 32e99edb3e69..4798c257ec82 100644 --- a/crates/polars-python/src/lazyframe/visitor/expr_nodes.rs +++ b/crates/polars-python/src/lazyframe/visitor/expr_nodes.rs @@ -56,8 +56,8 @@ impl IntoPy for Wrap { } } -#[pyclass(name = "Operator", eq)] -#[derive(Copy, Clone, PartialEq)] +#[pyclass(name = "Operator")] +#[derive(Copy, Clone)] pub enum PyOperator { Eq, EqValidity, @@ -129,8 +129,8 @@ impl IntoPy for Wrap { } } -#[pyclass(name = "StringFunction", eq)] -#[derive(Copy, Clone, PartialEq)] +#[pyclass(name = "StringFunction")] +#[derive(Copy, Clone)] pub enum PyStringFunction { ConcatHorizontal, ConcatVertical, @@ -184,8 +184,8 @@ impl PyStringFunction { } } -#[pyclass(name = "BooleanFunction", eq)] -#[derive(Copy, Clone, PartialEq)] +#[pyclass(name = "BooleanFunction")] +#[derive(Copy, Clone)] pub enum PyBooleanFunction { Any, All, @@ -213,8 +213,8 @@ impl PyBooleanFunction { } } -#[pyclass(name = "TemporalFunction", eq)] -#[derive(Copy, Clone, PartialEq)] +#[pyclass(name = "TemporalFunction")] +#[derive(Copy, Clone)] pub enum PyTemporalFunction { Millennium, Century, diff --git a/crates/polars-utils/src/python_function.rs b/crates/polars-utils/src/python_function.rs index f3b8f2d5fa8c..178f89aa2ca1 100644 --- a/crates/polars-utils/src/python_function.rs +++ b/crates/polars-utils/src/python_function.rs @@ -10,15 +10,9 @@ pub use serde_wrap::{ use crate::flatten; -#[derive(Debug)] +#[derive(Clone, Debug)] pub struct PythonFunction(pub PyObject); -impl Clone for PythonFunction { - fn clone(&self) -> Self { - Python::with_gil(|py| Self(self.0.clone_ref(py))) - } -} - impl From for PythonFunction { fn from(value: PyObject) -> Self { Self(value)