Skip to content

Commit

Permalink
support python 3.13
Browse files Browse the repository at this point in the history
  • Loading branch information
wangxiaoying committed Nov 4, 2024
1 parent e471ea9 commit b648113
Show file tree
Hide file tree
Showing 13 changed files with 856 additions and 699 deletions.
34 changes: 20 additions & 14 deletions connectorx-python/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions connectorx-python/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ connectorx = {path = "../connectorx", default-features = false}
env_logger = "0.9"
fehler = "1"
itertools = "0.10"
lazy_static = "1.4.0"
lazy_static = "1.4"
libc = "0.2"
log = "0.4"
ndarray = "0.15"
numpy = "0.21"
numpy = {version = "0.22", features = ["gil-refs"]}
openssl = {version = "0.10", features = ["vendored"]}
postgres = {version = "0.19", features = ["with-chrono-0_4", "with-uuid-0_8", "with-serde_json-1"]}
postgres-native-tls = {version = "0.5"}
postgres-openssl = {version = "0.5.0"}
pyo3 = {version = "0.21", default-features = false, features = ["macros"]}
pyo3 = {version = "0.22", default-features = false, features = ["macros", "gil-refs", "py-clone"]}
pyo3-built = "0.5"
rust_decimal = {version = "1", features = ["db-postgres"]}
serde_json = "1"
Expand All @@ -46,7 +46,7 @@ rayon = "1"

[build-dependencies]
built = {version = "0.5", features = ["chrono"]}
pyo3-build-config = {version = "0.21", features = ["resolve-config"]}
pyo3-build-config = {version = "0.22", features = ["resolve-config"]}

[dev-dependencies]
criterion = "0.3"
Expand Down
1,456 changes: 776 additions & 680 deletions connectorx-python/poetry.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion connectorx-python/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ numpy = ">=1.26"
pandas = {version = "^2", optional = true}
polars = {version = ">=0.8", optional = true}
pyarrow = {version = ">=4", optional = true}
python = ">=3.9,<3.13"
python = ">=3.9,<3.14"

[tool.poetry.extras]
all = ["dask", "pandas", "modin", "polars", "pyarrow"]
Expand Down
8 changes: 8 additions & 0 deletions connectorx-python/src/pandas/pandas_columns/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ unsafe impl Element for PyList {
fn get_dtype_bound(py: Python<'_>) -> Bound<'_, PyArrayDescr> {
PyArrayDescr::object_bound(py)
}

fn clone_ref(&self, _py: Python<'_>) -> Self {
Self(self.0.clone())
}
}

pub struct ArrayBlock<'a, V> {
Expand All @@ -37,6 +41,10 @@ impl<'a, V> FromPyObject<'a> for ArrayBlock<'a, V> {
_value_type: PhantomData,
})
}

fn extract_bound(ob: &pyo3::Bound<'a, PyAny>) -> PyResult<Self> {
Self::extract(ob.clone().into_gil_ref())
}
}

impl<'a, V> ArrayBlock<'a, V> {
Expand Down
4 changes: 4 additions & 0 deletions connectorx-python/src/pandas/pandas_columns/boolean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ impl<'a> FromPyObject<'a> for BooleanBlock<'a> {
))
}
}

fn extract_bound(ob: &pyo3::Bound<'a, PyAny>) -> PyResult<Self> {
Self::extract(ob.clone().into_gil_ref())
}
}

impl<'a> BooleanBlock<'a> {
Expand Down
8 changes: 8 additions & 0 deletions connectorx-python/src/pandas/pandas_columns/bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ unsafe impl Element for PyBytes {
fn get_dtype_bound(py: Python<'_>) -> Bound<'_, PyArrayDescr> {
PyArrayDescr::object_bound(py)
}

fn clone_ref(&self, _py: Python<'_>) -> Self {
Self(self.0.clone())
}
}

pub struct BytesBlock<'a> {
Expand All @@ -34,6 +38,10 @@ impl<'a> FromPyObject<'a> for BytesBlock<'a> {
buf_size_mb: 16, // in MB
})
}

fn extract_bound(ob: &pyo3::Bound<'a, PyAny>) -> PyResult<Self> {
Self::extract(ob.clone().into_gil_ref())
}
}

impl<'a> BytesBlock<'a> {
Expand Down
4 changes: 4 additions & 0 deletions connectorx-python/src/pandas/pandas_columns/datetime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ impl<'a> FromPyObject<'a> for DateTimeBlock<'a> {
let data = unsafe { array.as_array_mut() };
Ok(DateTimeBlock { data })
}

fn extract_bound(ob: &pyo3::Bound<'a, PyAny>) -> PyResult<Self> {
Self::extract(ob.clone().into_gil_ref())
}
}

impl<'a> DateTimeBlock<'a> {
Expand Down
4 changes: 4 additions & 0 deletions connectorx-python/src/pandas/pandas_columns/float64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ impl<'a> FromPyObject<'a> for Float64Block<'a> {
let data = unsafe { array.as_array_mut() };
Ok(Float64Block { data })
}

fn extract_bound(ob: &pyo3::Bound<'a, PyAny>) -> PyResult<Self> {
Self::extract(ob.clone().into_gil_ref())
}
}

impl<'a> Float64Block<'a> {
Expand Down
4 changes: 4 additions & 0 deletions connectorx-python/src/pandas/pandas_columns/int64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ impl<'a> FromPyObject<'a> for Int64Block<'a> {
))
}
}

fn extract_bound(ob: &pyo3::Bound<'a, PyAny>) -> PyResult<Self> {
Self::extract(ob.clone().into_gil_ref())
}
}

impl<'a> Int64Block<'a> {
Expand Down
15 changes: 15 additions & 0 deletions connectorx-python/src/pandas/pandas_columns/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,18 @@ pub fn check_dtype(ob: &PyAny, expected_dtype: &str) -> PyResult<()> {
}
Ok(())
}

// pub fn check_bound_dtype<'py>(ob: &pyo3::Bound<'py, PyAny>, expected_dtype: &str) -> PyResult<()> {
// let dtype = ob.getattr(intern!(ob.py(), "dtype"))?.str()?;
// // https://pyo3.rs/main/doc/pyo3/types/struct.pystring#equality
// if dtype != expected_dtype {
// throw!(PyRuntimeError::new_err(format!(
// "expecting ndarray to be '{}' found '{}' at {}:{}",
// expected_dtype,
// dtype,
// file!(),
// line!()
// )));
// }
// Ok(())
// }
4 changes: 4 additions & 0 deletions connectorx-python/src/pandas/pandas_columns/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ impl<'a> FromPyObject<'a> for StringBlock<'a> {
buf_size_mb: PYSTRING_BUFFER_SIZE, // in MB
})
}

fn extract_bound(ob: &pyo3::Bound<'a, PyAny>) -> PyResult<Self> {
Self::extract(ob.clone().into_gil_ref())
}
}

impl<'a> StringBlock<'a> {
Expand Down
4 changes: 4 additions & 0 deletions connectorx-python/src/pandas/pystring.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ unsafe impl Element for PyString {
fn get_dtype_bound(py: Python<'_>) -> Bound<'_, PyArrayDescr> {
PyArrayDescr::object_bound(py)
}

fn clone_ref(&self, _py: Python<'_>) -> Self {
Self(self.0.clone())
}
}

#[derive(Clone, Copy, Debug)]
Expand Down

0 comments on commit b648113

Please sign in to comment.