Skip to content

Commit

Permalink
Migrate to the new bound API of pyo3 0.23
Browse files Browse the repository at this point in the history
  • Loading branch information
redmie committed Jan 7, 2025
1 parent 0c71144 commit 7005322
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
macro_rules! pyo3_built {
($py: ident, $info: ident, $dict: ident, "build") => {
// Rustc
let build = PyDict::new_bound($py);
let build = PyDict::new($py);
build.set_item("rustc", $info::RUSTC)?;
build.set_item("rustc-version", $info::RUSTC_VERSION)?;
build.set_item("opt-level", $info::OPT_LEVEL)?;
Expand All @@ -14,13 +14,13 @@ macro_rules! pyo3_built {
};
($py: ident, $info: ident, $dict: ident, "time") => {
let dt = $py
.import_bound("email.utils")?
.import("email.utils")?
.call_method1("parsedate_to_datetime", ($info::BUILT_TIME_UTC,))?;
$dict.set_item("info-time", dt)?;
};
($py: ident, $info: ident, $dict: ident, "deps") => {
// info dependencies
let deps = PyDict::new_bound($py);
let deps = PyDict::new($py);
for (name, version) in $info::DEPENDENCIES.iter() {
deps.set_item(name, version)?;
}
Expand All @@ -30,19 +30,19 @@ macro_rules! pyo3_built {
// Features
let features = $info::FEATURES
.iter()
.map(|feat| PyString::new_bound($py, feat))
.map(|feat| PyString::new($py, feat))
.collect::<Vec<_>>();
$dict.set_item("features", features)?;
};
($py: ident, $info: ident, $dict: ident, "host") => {
// Host
let host = PyDict::new_bound($py);
let host = PyDict::new($py);
host.set_item("triple", $info::HOST)?;
$dict.set_item("host", host)?;
};
($py: ident, $info: ident, $dict: ident, "target") => {
// Target
let target = PyDict::new_bound($py);
let target = PyDict::new($py);
target.set_item("arch", $info::CFG_TARGET_ARCH)?;
target.set_item("os", $info::CFG_OS)?;
target.set_item("family", $info::CFG_FAMILY)?;
Expand All @@ -54,7 +54,7 @@ macro_rules! pyo3_built {
$dict.set_item("target", target)?;
};
($py: ident, $info: ident, $dict: ident, "git") => {
let git = PyDict::new_bound($py);
let git = PyDict::new($py);
git.set_item("version", $info::GIT_VERSION)?;
git.set_item("dirty", $info::GIT_DIRTY)?;
git.set_item("hash", $info::GIT_COMMIT_HASH)?;
Expand All @@ -70,7 +70,7 @@ macro_rules! pyo3_built {
($py: ident, $info: ident, $($i:tt ),+ ) => {{
use pyo3::types::PyDict;
use pyo3::types::PyString;
let info = PyDict::new_bound($py);
let info = PyDict::new($py);
$(
pyo3_built!{$py,$info, info, $i}
)+
Expand Down

0 comments on commit 7005322

Please sign in to comment.