@@ -612,7 +612,7 @@ fn validate_possible_object_file(
612
612
Ok ( ( errors, seen_dylibs) )
613
613
}
614
614
615
- fn validate_json ( json : & PythonJsonMain , triple : & str ) -> Result < Vec < String > > {
615
+ fn validate_json ( json : & PythonJsonMain , triple : & str , is_debug : bool ) -> Result < Vec < String > > {
616
616
let mut errors = vec ! [ ] ;
617
617
618
618
if json. version != "7" {
@@ -650,6 +650,16 @@ fn validate_json(json: &PythonJsonMain, triple: &str) -> Result<Vec<String>> {
650
650
) ) ;
651
651
}
652
652
653
+ if is_debug
654
+ && !json
655
+ . python_config_vars
656
+ . get ( "abiflags" )
657
+ . unwrap ( )
658
+ . contains ( 'd' )
659
+ {
660
+ errors. push ( "abiflags does not contain 'd'" . to_string ( ) ) ;
661
+ }
662
+
653
663
for extension in json. build_info . extensions . keys ( ) {
654
664
if GLOBALLY_BANNED_EXTENSIONS . contains ( & extension. as_str ( ) ) {
655
665
errors. push ( format ! ( "banned extension detected: {}" , extension) ) ;
@@ -663,6 +673,7 @@ fn validate_distribution(dist_path: &Path) -> Result<Vec<String>> {
663
673
let mut errors = vec ! [ ] ;
664
674
let mut seen_dylibs = BTreeSet :: new ( ) ;
665
675
let mut seen_paths = BTreeSet :: new ( ) ;
676
+ let mut seen_symlink_targets = BTreeSet :: new ( ) ;
666
677
667
678
let dist_filename = dist_path
668
679
. file_name ( )
@@ -696,6 +707,8 @@ fn validate_distribution(dist_path: &Path) -> Result<Vec<String>> {
696
707
return Err ( anyhow ! ( "could not parse Python version from filename" ) ) ;
697
708
} ;
698
709
710
+ let is_debug = dist_filename. contains ( "-debug-" ) ;
711
+
699
712
let reader = std:: io:: BufReader :: new ( fh) ;
700
713
let dctx = zstd:: stream:: Decoder :: new ( reader) ?;
701
714
let mut tf = tar:: Archive :: new ( dctx) ;
@@ -707,10 +720,12 @@ fn validate_distribution(dist_path: &Path) -> Result<Vec<String>> {
707
720
708
721
let mut entry = entries. next ( ) . unwrap ( ) ?;
709
722
if entry. path ( ) ?. display ( ) . to_string ( ) == "python/PYTHON.json" {
723
+ seen_paths. insert ( entry. path ( ) ?. to_path_buf ( ) ) ;
724
+
710
725
let mut data = Vec :: new ( ) ;
711
726
entry. read_to_end ( & mut data) ?;
712
727
let json = parse_python_json ( & data) . context ( "parsing PYTHON.json" ) ?;
713
- errors. extend ( validate_json ( & json, triple) ?) ;
728
+ errors. extend ( validate_json ( & json, triple, is_debug ) ?) ;
714
729
715
730
wanted_python_paths. extend ( json. python_paths . values ( ) . map ( |x| format ! ( "python/{}" , x) ) ) ;
716
731
} else {
@@ -726,6 +741,10 @@ fn validate_distribution(dist_path: &Path) -> Result<Vec<String>> {
726
741
727
742
seen_paths. insert ( path. clone ( ) ) ;
728
743
744
+ if let Some ( link_name) = entry. link_name ( ) ? {
745
+ seen_symlink_targets. insert ( path. parent ( ) . unwrap ( ) . join ( link_name) ) ;
746
+ }
747
+
729
748
// If this path starts with a path referenced in wanted_python_paths,
730
749
// remove the prefix from wanted_python_paths so we don't error on it
731
750
// later.
@@ -773,7 +792,16 @@ fn validate_distribution(dist_path: &Path) -> Result<Vec<String>> {
773
792
774
793
if path == PathBuf :: from ( "python/PYTHON.json" ) {
775
794
let json = parse_python_json ( & data) . context ( "parsing PYTHON.json" ) ?;
776
- errors. extend ( validate_json ( & json, triple) ?) ;
795
+ errors. extend ( validate_json ( & json, triple, is_debug) ?) ;
796
+ }
797
+ }
798
+
799
+ for path in seen_symlink_targets {
800
+ if !seen_paths. contains ( & path) {
801
+ errors. push ( format ! (
802
+ "symlink target {} referenced in archive but not found" ,
803
+ path. display( )
804
+ ) ) ;
777
805
}
778
806
}
779
807
0 commit comments