1313import json
1414import logging
1515import os
16+ import posixpath
1617import re
1718import sys
1819import tempfile
@@ -395,8 +396,9 @@ def assign_package_to_resources(cls, package, resource, codebase, package_adder)
395396 return
396397
397398 site_packages = dist_info_dir .parent (codebase )
398- if not site_packages :
399+ if not ( site_packages and site_packages . name == "site-packages" ) :
399400 return
401+
400402 package_data = resource .package_data
401403 assert len (resource .package_data ) == 1 , (
402404 f'Unsupported Pypi METADATA wheel structure: { resource .path !r} '
@@ -417,6 +419,7 @@ def assign_package_to_resources(cls, package, resource, codebase, package_adder)
417419 # most of thense are references to bin ../../../bin/wheel
418420 cannot_resolve = False
419421 ref_resource = site_packages
422+ # note that resolving leading ".." always stays in the codebase
420423 while path_ref .startswith ('..' ):
421424 _ , _ , path_ref = path_ref .partition ('../' )
422425 ref_resource = ref_resource .parent (codebase )
@@ -429,14 +432,14 @@ def assign_package_to_resources(cls, package, resource, codebase, package_adder)
429432 continue
430433 else :
431434 ref_resource = codebase .get_resource (
432- path = os . path .join (ref_resource .path , path_ref )
435+ path = posixpath .join (ref_resource .path , path_ref )
433436 )
434437 if ref_resource and package_uid :
435438 package_adder (package_uid , ref_resource , codebase )
436439 else :
437440 # These are absolute paths from the site-packages directory
438441 ref_resource = codebase .get_resource (
439- path = os . path .join (site_packages .path , path_ref )
442+ path = posixpath .join (site_packages .path , path_ref )
440443 )
441444 if ref_resource and package_uid :
442445 package_adder (package_uid , ref_resource , codebase )
0 commit comments