Skip to content

Commit d1b86fd

Browse files
authored
Upgrade pyo3 to v0.22 and bump to v0.2.0 (#5)
* Upgrade pyo3 to v0.22 and bump to v0.2.0 * Fix deprecation in wasm guest * Handle unevaluatedProperties in JSON schema parsing * Upgrade to numpy v0.22
1 parent 67701b4 commit d1b86fd

File tree

26 files changed

+96
-76
lines changed

26 files changed

+96
-76
lines changed

Cargo.toml

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -31,48 +31,49 @@ rust-version = "1.76"
3131

3232
[workspace.dependencies]
3333
# workspace-internal numcodecs crates
34-
numcodecs = { version = "0.1", path = "crates/numcodecs", default-features = false }
35-
numcodecs-python = { version = "0.2", path = "crates/numcodecs-python", default-features = false }
36-
numcodecs-wasm-guest = { version = "0.1", path = "crates/numcodecs-wasm-guest", default-features = false }
34+
numcodecs = { version = "0.2", path = "crates/numcodecs", default-features = false }
35+
numcodecs-python = { version = "0.3", path = "crates/numcodecs-python", default-features = false }
36+
numcodecs-wasm-guest = { version = "0.2", path = "crates/numcodecs-wasm-guest", default-features = false }
3737

3838
# workspace-internal codecs crates
39-
numcodecs-asinh = { version = "0.1", path = "codecs/asinh", default-features = false }
40-
numcodecs-bit-round = { version = "0.1", path = "codecs/bit-round", default-features = false }
41-
numcodecs-fixed-offset-scale = { version = "0.1", path = "codecs/fixed-offset-scale", default-features = false }
42-
numcodecs-identity = { version = "0.1", path = "codecs/identity", default-features = false }
43-
numcodecs-linear-quantize = { version = "0.2", path = "codecs/linear-quantize", default-features = false }
44-
numcodecs-log = { version = "0.2", path = "codecs/log", default-features = false }
45-
numcodecs-reinterpret = { version = "0.1", path = "codecs/reinterpret", default-features = false }
46-
numcodecs-round = { version = "0.1", path = "codecs/round", default-features = false }
47-
numcodecs-swizzle-reshape = { version = "0.1", path = "codecs/swizzle-reshape", default-features = false }
48-
numcodecs-sz3 = { version = "0.1", path = "codecs/sz3", default-features = false }
49-
numcodecs-uniform-noise = { version = "0.1", path = "codecs/uniform-noise", default-features = false }
50-
numcodecs-zfp = { version = "0.1", path = "codecs/zfp", default-features = false }
51-
numcodecs-zlib = { version = "0.1", path = "codecs/zlib", default-features = false }
52-
numcodecs-zstd = { version = "0.1", path = "codecs/zstd", default-features = false }
39+
numcodecs-asinh = { version = "0.2", path = "codecs/asinh", default-features = false }
40+
numcodecs-bit-round = { version = "0.2", path = "codecs/bit-round", default-features = false }
41+
numcodecs-fixed-offset-scale = { version = "0.2", path = "codecs/fixed-offset-scale", default-features = false }
42+
numcodecs-identity = { version = "0.2", path = "codecs/identity", default-features = false }
43+
numcodecs-linear-quantize = { version = "0.3", path = "codecs/linear-quantize", default-features = false }
44+
numcodecs-log = { version = "0.3", path = "codecs/log", default-features = false }
45+
numcodecs-random-projection = { version = "0.2", path = "codecs/random-projection", default-features = false }
46+
numcodecs-reinterpret = { version = "0.2", path = "codecs/reinterpret", default-features = false }
47+
numcodecs-round = { version = "0.2", path = "codecs/round", default-features = false }
48+
numcodecs-swizzle-reshape = { version = "0.2", path = "codecs/swizzle-reshape", default-features = false }
49+
numcodecs-sz3 = { version = "0.2", path = "codecs/sz3", default-features = false }
50+
numcodecs-uniform-noise = { version = "0.2", path = "codecs/uniform-noise", default-features = false }
51+
numcodecs-zfp = { version = "0.2", path = "codecs/zfp", default-features = false }
52+
numcodecs-zlib = { version = "0.2", path = "codecs/zlib", default-features = false }
53+
numcodecs-zstd = { version = "0.2", path = "codecs/zstd", default-features = false }
5354

5455
# crates.io third-party dependencies
5556
convert_case = { version = "0.6", default-features = false }
5657
format_serde_error = { version = "0.3", default-features = false }
5758
miniz_oxide = { version = "0.8", default-features = false }
58-
ndarray = { version = "0.15", default-features = false } # keep in sync with numpy
59-
ndarray-rand = { version = "0.14", default-features = false }
60-
numpy = { version = "0.21", default-features = false }
59+
ndarray = { version = "0.16", default-features = false } # keep in sync with numpy
60+
ndarray-rand = { version = "0.15", default-features = false }
61+
numpy = { version = "0.22", default-features = false }
6162
num-traits = { version = "0.2", default-features = false }
6263
postcard = { version = "1.0", default-features = false }
63-
pyo3 = { version = "0.21", default-features = false }
64-
pyo3-error = { version = "0.1", default-features = false }
65-
pythonize = { version = "0.21", default-features = false }
64+
pyo3 = { version = "0.22", default-features = false }
65+
pyo3-error = { version = "0.2", default-features = false }
66+
pythonize = { version = "0.22", default-features = false }
6667
rand = { version = "0.8", default-features = false }
67-
schemars = { version = "=1.0.0-alpha.9", default-features = false }
68+
schemars = { version = "=1.0.0-alpha.15", default-features = false }
6869
serde = { version = "1.0", default-features = false }
6970
serde-transcode = { version = "1.1", default-features = false }
7071
serde_json = { version = "1.0", default-features = false }
7172
serde_repr = { version = "0.1", default-features = false }
7273
sz3 = { version = "0.1.1", default-features = false }
7374
thiserror = { version = "1.0", default-features = false }
7475
twofloat = { version = "0.7", default-features = false }
75-
wit-bindgen = { version = "0.32", default-features = false }
76+
wit-bindgen = { version = "0.34", default-features = false }
7677
wyhash = { version = "0.5", default-features = false }
7778
zfp-sys = { version = "0.1.15", default-features = false }
7879
zstd = { version = "0.13", default-features = false }

codecs/asinh/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "numcodecs-asinh"
3-
version = "0.1.0"
3+
version = "0.2.0"
44
edition = { workspace = true }
55
authors = { workspace = true }
66
repository = { workspace = true }

codecs/bit-round/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "numcodecs-bit-round"
3-
version = "0.1.0"
3+
version = "0.2.0"
44
edition = { workspace = true }
55
authors = { workspace = true }
66
repository = { workspace = true }

codecs/fixed-offset-scale/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "numcodecs-fixed-offset-scale"
3-
version = "0.1.1"
3+
version = "0.2.0"
44
edition = { workspace = true }
55
authors = { workspace = true }
66
repository = { workspace = true }

codecs/identity/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "numcodecs-identity"
3-
version = "0.1.0"
3+
version = "0.2.0"
44
edition = { workspace = true }
55
authors = { workspace = true }
66
repository = { workspace = true }

codecs/linear-quantize/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "numcodecs-linear-quantize"
3-
version = "0.2.0"
3+
version = "0.3.0"
44
edition = { workspace = true }
55
authors = { workspace = true }
66
repository = { workspace = true }

codecs/log/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "numcodecs-log"
3-
version = "0.2.0"
3+
version = "0.3.0"
44
edition = { workspace = true }
55
authors = { workspace = true }
66
repository = { workspace = true }

codecs/random-projection/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "numcodecs-random-projection"
3-
version = "0.1.0"
3+
version = "0.2.0"
44
edition = { workspace = true }
55
authors = { workspace = true }
66
repository = { workspace = true }

codecs/reinterpret/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "numcodecs-reinterpret"
3-
version = "0.1.0"
3+
version = "0.2.0"
44
edition = { workspace = true }
55
authors = { workspace = true }
66
repository = { workspace = true }

codecs/reinterpret/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ pub fn reinterpret_array<T: Copy, U, S: Data<Elem = T>, D: Dimension>(
394394
reinterpret: impl Fn(T) -> U,
395395
) -> Array<U, D> {
396396
let array = array.into_owned();
397-
let (shape, data) = (array.raw_dim(), array.into_raw_vec());
397+
let (shape, data) = (array.raw_dim(), array.into_raw_vec_and_offset().0);
398398

399399
let data = data.into_iter().map(reinterpret).collect();
400400

codecs/round/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "numcodecs-round"
3-
version = "0.1.0"
3+
version = "0.2.0"
44
edition = { workspace = true }
55
authors = { workspace = true }
66
repository = { workspace = true }

codecs/swizzle-reshape/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "numcodecs-swizzle-reshape"
3-
version = "0.1.0"
3+
version = "0.2.0"
44
edition = { workspace = true }
55
authors = { workspace = true }
66
repository = { workspace = true }

codecs/sz3/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "numcodecs-sz3"
3-
version = "0.1.1"
3+
version = "0.2.0"
44
edition = { workspace = true }
55
authors = { workspace = true }
66
repository = { workspace = true }

codecs/uniform-noise/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "numcodecs-uniform-noise"
3-
version = "0.1.0"
3+
version = "0.2.0"
44
edition = { workspace = true }
55
authors = { workspace = true }
66
repository = { workspace = true }

codecs/zfp/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "numcodecs-zfp"
3-
version = "0.1.0"
3+
version = "0.2.0"
44
edition = { workspace = true }
55
authors = { workspace = true }
66
repository = { workspace = true }

codecs/zlib/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "numcodecs-zlib"
3-
version = "0.1.0"
3+
version = "0.2.0"
44
edition = { workspace = true }
55
authors = { workspace = true }
66
repository = { workspace = true }

codecs/zstd/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "numcodecs-zstd"
3-
version = "0.1.0"
3+
version = "0.2.0"
44
edition = { workspace = true }
55
authors = { workspace = true }
66
repository = { workspace = true }

crates/numcodecs-python/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "numcodecs-python"
3-
version = "0.2.2"
3+
version = "0.3.0"
44
edition = { workspace = true }
55
authors = { workspace = true }
66
repository = { workspace = true }

crates/numcodecs-python/src/adapter.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ impl PyCodecAdapter {
4747
) -> Result<Self, D::Error> {
4848
Python::with_gil(|py| {
4949
let config = transcode(config, Pythonizer::new(py))?;
50-
let config: Bound<PyDict> = config.extract(py)?;
50+
let config: Bound<PyDict> = config.extract()?;
5151

5252
let codec = PyCodecRegistry::get_codec(config.as_borrowed())?;
5353

@@ -310,7 +310,12 @@ impl PyCodecAdapter {
310310
view_mut: &mut AnyArrayViewMut,
311311
array_like: Bound<PyAny>,
312312
) -> Result<(), PyErr> {
313-
fn shape_checked_assign<T: Element, S2: DataMut<Elem = T>, D1: Dimension, D2: Dimension>(
313+
fn shape_checked_assign<
314+
T: Copy + Element,
315+
S2: DataMut<Elem = T>,
316+
D1: Dimension,
317+
D2: Dimension,
318+
>(
314319
src: &Bound<PyArray<T, D1>>,
315320
dst: &mut ArrayBase<S2, D2>,
316321
) -> Result<(), PyErr> {
@@ -417,10 +422,7 @@ impl DynCodec for PyCodecAdapter {
417422
.get_config()
418423
.map_err(serde::ser::Error::custom)?;
419424

420-
transcode(
421-
&mut Depythonizer::from_object_bound(config.into_any()),
422-
serializer,
423-
)
425+
transcode(&mut Depythonizer::from_object(config.as_any()), serializer)
424426
})
425427
}
426428
}
@@ -509,7 +511,7 @@ impl DynCodecType for PyCodecClassAdapter {
509511
Python::with_gil(|py| {
510512
let config =
511513
transcode(config, Pythonizer::new(py)).map_err(serde::de::Error::custom)?;
512-
let config: Bound<PyDict> = config.extract(py).map_err(serde::de::Error::custom)?;
514+
let config: Bound<PyDict> = config.extract().map_err(serde::de::Error::custom)?;
513515

514516
let codec = self
515517
.class

crates/numcodecs-python/src/codec.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,6 @@ impl<'py> Sealed for Bound<'py, PyCodec> {}
118118
#[doc(hidden)]
119119
impl DerefToPyAny for PyCodec {}
120120

121-
#[doc(hidden)]
122-
#[allow(unsafe_code)]
123-
unsafe impl PyNativeType for PyCodec {
124-
type AsRefSource = Self;
125-
}
126-
127121
#[doc(hidden)]
128122
#[allow(unsafe_code)]
129123
unsafe impl PyTypeInfo for PyCodec {

crates/numcodecs-python/src/codec_class.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,6 @@ impl<'py> Sealed for Bound<'py, PyCodecClass> {}
7777
#[doc(hidden)]
7878
impl DerefToPyAny for PyCodecClass {}
7979

80-
#[doc(hidden)]
81-
#[allow(unsafe_code)]
82-
unsafe impl PyNativeType for PyCodecClass {
83-
type AsRefSource = Self;
84-
}
85-
8680
#[doc(hidden)]
8781
#[allow(unsafe_code)]
8882
unsafe impl PyTypeInfo for PyCodecClass {

crates/numcodecs-python/src/export.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ pub fn export_codec_class<'py, T: DynCodecType>(
6666
),
6767
(
6868
intern!(py, RustCodec::SCHEMA_ATTRIBUTE),
69-
pythonize(py, &codec_config_schema)?.into_bound(py),
69+
pythonize(py, &codec_config_schema)?,
7070
),
7171
(
7272
intern!(py, "__init__"),
@@ -139,7 +139,7 @@ impl<T: DynCodec> AnyCodec for T {
139139
}
140140

141141
fn get_config<'py>(&self, py: Python<'py>) -> Result<Bound<'py, PyDict>, PyErr> {
142-
<T as DynCodec>::get_config(self, Pythonizer::new(py))?.extract(py)
142+
<T as DynCodec>::get_config(self, Pythonizer::new(py))?.extract()
143143
}
144144

145145
fn as_any(&self) -> &dyn Any {
@@ -163,7 +163,7 @@ impl<T: DynCodecType> AnyCodecType for T {
163163
) -> Result<Box<dyn 'static + Send + Sync + AnyCodec>, PyErr> {
164164
match <T as DynCodecType>::codec_from_config(
165165
self,
166-
&mut Depythonizer::from_object_bound(config.into_any()),
166+
&mut Depythonizer::from_object(config.as_any()),
167167
) {
168168
Ok(codec) => Ok(Box::new(codec)),
169169
Err(err) => Err(err.into()),
@@ -240,6 +240,7 @@ impl RustCodec {
240240
)
241241
}
242242

243+
#[pyo3(signature = (buf, out=None))]
243244
fn decode<'py>(
244245
&self,
245246
py: Python<'py>,
@@ -280,7 +281,7 @@ impl RustCodec {
280281
let config = this.get_config(py)?;
281282
let py_this: Py<PyAny> = this.into_py(py);
282283

283-
let mut repr = py_this.bind(py).get_type().name()?.into_owned();
284+
let mut repr = py_this.bind(py).get_type().name()?.to_cow()?.into_owned();
284285
repr.push('(');
285286

286287
let mut first = true;

0 commit comments

Comments
 (0)