@@ -540,17 +540,26 @@ private void initEntries() {
540
540
checkPlatform ();
541
541
}
542
542
if (extractFilter != null ) {
543
- String wheelMetadataSuffix = ".dist-info" + getSeparator () + "RECORD" ;
544
543
for (BaseEntry entry : vfsEntries .values ()) {
545
- if (entry instanceof FileEntry fileEntry && fileEntry .getPlatformPath ().endsWith (wheelMetadataSuffix )) {
546
- Path baseDir = Paths .get (fileEntry .getPlatformPath ()).getParent ().getParent ();
547
- try (BufferedReader is = new BufferedReader (new InputStreamReader (getResourceUrl (fileEntry .getResourcePath ()).openStream ()))) {
544
+ Path baseDir = null ;
545
+ if (entry instanceof FileEntry fileEntry ) {
546
+ Path path = Paths .get (fileEntry .getPlatformPath ());
547
+ Path name = path .getFileName ();
548
+ if (name != null && name .endsWith ("RECORD" )) {
549
+ Path distInfo = path .getParent ();
550
+ if (distInfo != null && distInfo .toString ().endsWith (".dist-info" )) {
551
+ baseDir = distInfo .getParent ();
552
+ }
553
+ }
554
+ }
555
+ if (baseDir != null ) {
556
+ try (BufferedReader is = new BufferedReader (new InputStreamReader (getResourceUrl (entry .getResourcePath ()).openStream ()))) {
548
557
String line ;
549
558
List <FileEntry > extractedTogether = new ArrayList <>();
550
559
while ((line = is .readLine ()) != null ) {
551
560
int commaIndex = line .indexOf (',' );
552
561
if (commaIndex < 0 ) {
553
- warn ("Failed to parse wheel entry in record file %s: %s" , fileEntry .getPlatformPath (), line );
562
+ warn ("Failed to parse wheel entry in record file %s: %s" , entry .getPlatformPath (), line );
554
563
continue ;
555
564
}
556
565
Path platformPath = baseDir .resolve (line .substring (0 , commaIndex ).replace ("/" , PLATFORM_SEPARATOR ));
@@ -559,7 +568,7 @@ private void initEntries() {
559
568
if (extractableEntry instanceof FileEntry extractableFileEntry ) {
560
569
extractedTogether .add (extractableFileEntry );
561
570
} else {
562
- warn ("Could not find file referred from wheel record file %s: %s" , fileEntry .getPlatformPath (), platformPath );
571
+ warn ("Could not find file referred from wheel record file %s: %s" , entry .getPlatformPath (), platformPath );
563
572
}
564
573
}
565
574
}
@@ -571,7 +580,7 @@ private void initEntries() {
571
580
} catch (IOException ex ) {
572
581
// This is just best-effort attempt at guessing which libraries to extract
573
582
// together, ignore errors
574
- warn ("Exception when reading wheel record file %s: %s" , fileEntry .getPlatformPath (), ex );
583
+ warn ("Exception when reading wheel record file %s: %s" , entry .getPlatformPath (), ex );
575
584
}
576
585
}
577
586
}
0 commit comments