Skip to content

Commit 647ccec

Browse files
authored
Update cargo_metadata to 0.20.0 (#2864)
1 parent b42de5e commit 647ccec

File tree

6 files changed

+128
-21
lines changed

6 files changed

+128
-21
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ anyhow = "1.0.80"
4343
base64 = "0.22.0"
4444
glob = "0.3.0"
4545
cargo-config2 = "0.1.24"
46-
cargo_metadata = "0.19.0"
46+
cargo_metadata = "0.20.0"
4747
cargo-options = "0.7.2"
4848
cbindgen = { version = "0.29.0", default-features = false }
4949
flate2 = "1.0.18"

src/build_options.rs

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -946,16 +946,16 @@ fn filter_cargo_targets(
946946
config_targets: Option<&[crate::pyproject_toml::CargoTarget]>,
947947
) -> Result<Vec<CompileTarget>> {
948948
let root_pkg = cargo_metadata.root_package().unwrap();
949-
let resolved_features = cargo_metadata
949+
let resolved_features: Vec<String> = cargo_metadata
950950
.resolve
951951
.as_ref()
952-
.and_then(|resolve| resolve.nodes.iter().find(|node| node.id == root_pkg.id))
953-
.map(|node| node.features.clone())
952+
.and_then(|resolve| resolve.nodes.iter().find(|&node| node.id == root_pkg.id))
953+
.map(|node| node.features.iter().map(|f| f.to_string()).collect())
954954
.unwrap_or_default();
955955
let mut targets: Vec<_> = root_pkg
956956
.targets
957957
.iter()
958-
.filter(|target| match bridge {
958+
.filter(|&target| match bridge {
959959
BridgeModel::Bin(_) => {
960960
let is_bin = target.is_bin();
961961
if target.required_features.is_empty() {
@@ -1028,15 +1028,19 @@ fn filter_cargo_targets(
10281028
fn has_abi3(deps: &HashMap<&str, &Node>) -> Result<Option<Abi3Version>> {
10291029
for &lib in PYO3_BINDING_CRATES.iter() {
10301030
let lib = lib.as_str();
1031-
if let Some(pyo3_crate) = deps.get(lib) {
1031+
if let Some(&pyo3_crate) = deps.get(lib) {
10321032
// Find the minimal abi3 python version. If there is none, abi3 hasn't been selected
10331033
// This parser abi3-py{major}{minor} and returns the minimal (major, minor) tuple
1034-
let abi3_selected = pyo3_crate.features.iter().any(|x| x == "abi3");
1034+
let abi3_selected = pyo3_crate
1035+
.features
1036+
.iter()
1037+
.map(AsRef::as_ref)
1038+
.any(|x| x == "abi3");
10351039

10361040
let min_abi3_version = pyo3_crate
10371041
.features
10381042
.iter()
1039-
.filter(|x| x.starts_with("abi3-py") && x.len() >= "abi3-pyxx".len())
1043+
.filter(|&x| x.starts_with("abi3-py") && x.len() >= "abi3-pyxx".len())
10401044
.map(|x| {
10411045
Ok((
10421046
(x.as_bytes()[7] as char).to_string().parse::<u8>()?,
@@ -1072,10 +1076,11 @@ fn is_generating_import_lib(cargo_metadata: &Metadata) -> Result<bool> {
10721076
.filter(|package| cargo_metadata[&package.id].name.as_str() == lib)
10731077
.collect::<Vec<_>>();
10741078
match pyo3_packages.as_slice() {
1075-
[pyo3_crate] => {
1079+
&[pyo3_crate] => {
10761080
let generate_import_lib = pyo3_crate
10771081
.features
10781082
.iter()
1083+
.map(AsRef::as_ref)
10791084
.any(|x| x == "generate-import-lib" || x == "generate-abi3-import-lib");
10801085
return Ok(generate_import_lib);
10811086
}
@@ -1176,9 +1181,9 @@ pub fn find_bridge(cargo_metadata: &Metadata, bridge: Option<&str>) -> Result<Br
11761181
.packages
11771182
.iter()
11781183
.filter_map(|pkg| {
1179-
let name = &pkg.name;
1184+
let name = pkg.name.as_ref();
11801185
if name == "pyo3" || name == "pyo3-ffi" || name == "cpython" || name == "uniffi" {
1181-
Some((name.as_ref(), pkg))
1186+
Some((name, pkg))
11821187
} else {
11831188
None
11841189
}
@@ -1251,7 +1256,12 @@ pub fn find_bridge(cargo_metadata: &Metadata, bridge: Option<&str>) -> Result<Br
12511256
if !bridge.is_bin() && bridge.is_pyo3_crate(lib) {
12521257
let lib_name = lib.as_str();
12531258
let pyo3_node = deps[lib_name];
1254-
if !pyo3_node.features.contains(&"extension-module".to_string()) {
1259+
if !pyo3_node
1260+
.features
1261+
.iter()
1262+
.map(AsRef::as_ref)
1263+
.any(|f| f == "extension-module")
1264+
{
12551265
let version = &cargo_metadata[&pyo3_node.id].version;
12561266
if (version.major, version.minor) < (0, 26) {
12571267
// pyo3 0.26+ will use the `PYO3_BUILD_EXTENSION_MODULE` env var instead

src/compile.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ fn compile_target(
532532
};
533533

534534
// Extract the location of the .so/.dll/etc. from cargo's json output
535-
if crate_name == &context.crate_name {
535+
if crate_name.as_ref() == context.crate_name {
536536
let tuples = artifact
537537
.target
538538
.crate_types
@@ -677,9 +677,9 @@ fn pyo3_version(cargo_metadata: &cargo_metadata::Metadata) -> Option<(u64, u64,
677677
.packages
678678
.iter()
679679
.filter_map(|pkg| {
680-
let name = &pkg.name;
680+
let name = pkg.name.as_ref();
681681
if name == "pyo3" || name == "pyo3-ffi" {
682-
Some((name.as_ref(), pkg))
682+
Some((name, pkg))
683683
} else {
684684
None
685685
}

src/metadata.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ impl Metadata24 {
536536
license: package.license.clone(),
537537
license_files,
538538
project_url,
539-
..Metadata24::new(name, version)
539+
..Metadata24::new(name.to_string(), version)
540540
};
541541
Ok(metadata)
542542
}

src/source_distribution.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -343,15 +343,15 @@ pub fn find_path_deps(cargo_metadata: &Metadata) -> Result<HashMap<String, PathD
343343
let dependency = top
344344
.dependencies
345345
.iter()
346-
.find(|package| {
346+
.find(|&package| {
347347
// Package ids are opaque and there seems to be no way to query their name.
348348
let dep_name = &cargo_metadata
349349
.packages
350350
.iter()
351351
.find(|package| &package.id == dep_id)
352352
.unwrap()
353353
.name;
354-
&package.name == dep_name
354+
package.name == dep_name.as_ref()
355355
})
356356
.unwrap();
357357
if let Some(path) = &dependency.path {

0 commit comments

Comments
 (0)