Skip to content

Commit 756ac44

Browse files
authored
pyo3: upgrade to v0.28.3 (#23230)
Upgrade to [PyO3 v0.28.3](https://github.com/PyO3/pyo3/releases/tag/v0.28.3). The main change affecting Pants source is the need to now explicitly opt-in to [the generation of `FromPyObject` on pyclass-types which are `Clone`](https://pyo3.rs/v0.28.3/migration.html#deprecation-of-automatic-frompyobject-for-pyclass-types-which-implement-clone).
1 parent ebbf7ff commit 756ac44

File tree

9 files changed

+40
-44
lines changed

9 files changed

+40
-44
lines changed

docs/notes/2.32.x.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,8 @@ When generating lockfiles, the new `python.resolves_to_uploaded_prior_to` option
150150

151151
### Plugin API changes
152152

153+
PyO3, the interface crate between Rust and Python, has been upgraded to v0.28.3.
154+
153155
## Full Changelog
154156

155157
For the full changelog, see the individual GitHub Releases for this series: <https://github.com/pantsbuild/pants/releases>

src/rust/Cargo.lock

Lines changed: 13 additions & 31 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/rust/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,8 @@ prodash = { git = "https://github.com/stuhood/prodash", rev = "stuhood/raw-messa
194194
prost = "0.13"
195195
prost-build = "0.13"
196196
prost-types = "0.13"
197-
pyo3 = { version = "0.27.2", features = ["parking_lot"] }
198-
pyo3-build-config = "0.27.2"
197+
pyo3 = { version = "0.28.3", features = ["parking_lot"] }
198+
pyo3-build-config = "0.28.3"
199199
rand = "0.10.0"
200200
regex = "1.12.3"
201201
reqwest = { version = "0.12", default-features = false }

src/rust/engine/src/externs/address.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ fn split_on_longest_dir_prefix<'a, 'b>(
437437
matched
438438
}
439439

440-
#[pyclass(name = "Address")]
440+
#[pyclass(name = "Address", from_py_object)]
441441
#[derive(Clone, Hash, Eq, PartialEq, Ord, PartialOrd)]
442442
pub struct Address {
443443
// NB: Field ordering is deliberate, so that Ord will roughly match `self.spec`.

src/rust/engine/src/externs/dep_inference.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ pub(crate) fn register(m: &Bound<'_, PyModule>) -> PyResult<()> {
2020
m.add_class::<PyInferenceMetadata>()
2121
}
2222

23-
#[pyclass(name = "InferenceMetadata")]
23+
#[pyclass(name = "InferenceMetadata", from_py_object)]
2424
#[derive(Clone, Debug, PartialEq)]
2525
pub struct PyInferenceMetadata(pub dependency_inference_request::Metadata);
2626

@@ -78,7 +78,7 @@ impl PyInferenceMetadata {
7878
}
7979
}
8080

81-
#[pyclass(name = "NativeDependenciesRequest")]
81+
#[pyclass(name = "NativeDependenciesRequest", from_py_object)]
8282
#[derive(Clone, Debug, PartialEq)]
8383
pub struct PyNativeDependenciesRequest {
8484
pub directory_digest: DirectoryDigest,

src/rust/engine/src/externs/fs.rs

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ pub fn possible_store_missing_digest(e: store::StoreError) -> PyErr {
5656
failure.into()
5757
}
5858

59-
#[pyclass(name = "Digest")]
59+
#[pyclass(name = "Digest", from_py_object)]
6060
#[derive(Clone, Debug, PartialEq, Eq)]
6161
pub struct PyDigest(pub DirectoryDigest);
6262

@@ -114,7 +114,7 @@ impl PyDigest {
114114
}
115115
}
116116

117-
#[pyclass(name = "FileDigest")]
117+
#[pyclass(name = "FileDigest", from_py_object)]
118118
#[derive(Debug, Clone, PartialEq, Eq)]
119119
pub struct PyFileDigest(pub Digest);
120120

@@ -501,7 +501,12 @@ impl PyFilespecMatcher {
501501
// -----------------------------------------------------------------------------
502502

503503
/// The kind of path (e.g., file, directory, symlink) as identified in `PathMetadata`
504-
#[pyclass(name = "PathMetadataKind", rename_all = "UPPERCASE", eq)]
504+
#[pyclass(
505+
name = "PathMetadataKind",
506+
rename_all = "UPPERCASE",
507+
eq,
508+
from_py_object
509+
)]
505510
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
506511
pub enum PyPathMetadataKind {
507512
File,
@@ -530,7 +535,7 @@ impl From<PyPathMetadataKind> for fs::PathMetadataKind {
530535
}
531536

532537
/// Expanded version of `Stat` when access to additional filesystem attributes is necessary.
533-
#[pyclass(name = "PathMetadata")]
538+
#[pyclass(name = "PathMetadata", from_py_object)]
534539
#[derive(Clone, Debug, Eq, PartialEq)]
535540
pub struct PyPathMetadata(pub fs::PathMetadata);
536541

@@ -652,7 +657,14 @@ impl PyPathMetadata {
652657
}
653658

654659
/// The path's namespace (to separate buildroot and system paths)
655-
#[pyclass(name = "PathNamespace", rename_all = "UPPERCASE", frozen, eq, hash)]
660+
#[pyclass(
661+
name = "PathNamespace",
662+
rename_all = "UPPERCASE",
663+
frozen,
664+
eq,
665+
hash,
666+
from_py_object
667+
)]
656668
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)]
657669
pub enum PyPathNamespace {
658670
Workspace,

src/rust/engine/src/externs/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ create_exception!(native_engine, EngineError, PyException);
6565
create_exception!(native_engine, IntrinsicError, EngineError);
6666
create_exception!(native_engine, IncorrectProductError, EngineError);
6767

68+
#[pyclass(from_py_object)]
6869
#[derive(Clone)]
69-
#[pyclass]
7070
pub struct PyFailure(pub Failure);
7171

7272
#[pymethods]

src/rust/engine/src/externs/process.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub(crate) fn register(m: &Bound<'_, PyModule>) -> PyResult<()> {
1717
Ok(())
1818
}
1919

20-
#[pyclass(name = "ProcessExecutionEnvironment")]
20+
#[pyclass(name = "ProcessExecutionEnvironment", from_py_object)]
2121
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
2222
pub struct PyProcessExecutionEnvironment {
2323
pub environment: ProcessExecutionEnvironment,

src/rust/engine/src/externs/target.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ fn validate_choices(
118118
Ok(())
119119
}
120120

121-
#[pyclass(name = "_NoValue")]
121+
#[pyclass(name = "_NoValue", from_py_object)]
122122
#[derive(Clone)]
123123
struct NoFieldValue;
124124

0 commit comments

Comments
 (0)