Skip to content

Commit bf6a740

Browse files
committed
rust: validate python_paths exist
This currently fails in cross builds due to sysconfig wonkiness.
1 parent 29994d0 commit bf6a740

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/main.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -703,12 +703,16 @@ fn validate_distribution(dist_path: &Path) -> Result<Vec<String>> {
703703
// First entry in archive should be python/PYTHON.json.
704704
let mut entries = tf.entries()?;
705705

706+
let mut wanted_python_paths = BTreeSet::new();
707+
706708
let mut entry = entries.next().unwrap()?;
707709
if entry.path()?.display().to_string() == "python/PYTHON.json" {
708710
let mut data = Vec::new();
709711
entry.read_to_end(&mut data)?;
710712
let json = parse_python_json(&data).context("parsing PYTHON.json")?;
711713
errors.extend(validate_json(&json, triple)?);
714+
715+
wanted_python_paths.extend(json.python_paths.values().map(|x| format!("python/{}", x)));
712716
} else {
713717
errors.push(format!(
714718
"1st archive entry should be for python/PYTHON.json; got {}",
@@ -722,6 +726,18 @@ fn validate_distribution(dist_path: &Path) -> Result<Vec<String>> {
722726

723727
seen_paths.insert(path.clone());
724728

729+
// If this path starts with a path referenced in wanted_python_paths,
730+
// remove the prefix from wanted_python_paths so we don't error on it
731+
// later.
732+
let removals = wanted_python_paths
733+
.iter()
734+
.filter(|prefix| path.starts_with(prefix))
735+
.map(|x| x.to_string())
736+
.collect::<Vec<_>>();
737+
for p in removals {
738+
wanted_python_paths.remove(&p);
739+
}
740+
725741
let mut data = Vec::new();
726742
entry.read_to_end(&mut data)?;
727743

@@ -761,6 +777,13 @@ fn validate_distribution(dist_path: &Path) -> Result<Vec<String>> {
761777
}
762778
}
763779

780+
for path in wanted_python_paths {
781+
errors.push(format!(
782+
"path prefix {} seen in python_paths does not appear in archive",
783+
path
784+
));
785+
}
786+
764787
let wanted_dylibs = BTreeSet::from_iter(
765788
allowed_dylibs_for_triple(triple)
766789
.iter()

0 commit comments

Comments
 (0)