@@ -457,7 +457,7 @@ def parse_metadata(location, datasource_id, package_type):
457
457
name = name ,
458
458
version = version ,
459
459
description = get_description (metainfo = meta , location = str (location )),
460
- #TODO: https://github.com/aboutcode-org/scancode-toolkit/issues/3014
460
+ # TODO: https://github.com/aboutcode-org/scancode-toolkit/issues/3014
461
461
declared_license = get_declared_license (meta ),
462
462
keywords = get_keywords (meta ),
463
463
parties = get_parties (meta ),
@@ -521,19 +521,25 @@ class PypiWheelHandler(BasePypiHandler):
521
521
522
522
@classmethod
523
523
def parse (cls , location ):
524
- with zipfile .ZipFile (location ) as zf :
525
- for path in ZipPath (zf ).iterdir ():
526
- if not path .name .endswith (META_DIR_SUFFIXES ):
527
- continue
528
- for metapath in path .iterdir ():
529
- if not metapath .name .endswith ('METADATA' ):
530
- continue
531
524
532
- yield parse_metadata (
533
- location = metapath ,
534
- datasource_id = cls .datasource_id ,
535
- package_type = cls .default_package_type ,
536
- )
525
+ from python_inspector import lockfile
526
+ from python_inspector .utils_pypi import PYINSP_CACHE_LOCK_TIMEOUT
527
+ lock_file = os .path .join (f"{ location } .lockfile" )
528
+ with lockfile .FileLock (lock_file ).locked (timeout = PYINSP_CACHE_LOCK_TIMEOUT ):
529
+
530
+ with zipfile .ZipFile (location ) as zf :
531
+ for path in ZipPath (zf ).iterdir ():
532
+ if not path .name .endswith (META_DIR_SUFFIXES ):
533
+ continue
534
+ for metapath in path .iterdir ():
535
+ if not metapath .name .endswith ('METADATA' ):
536
+ continue
537
+
538
+ yield parse_metadata (
539
+ location = metapath ,
540
+ datasource_id = cls .datasource_id ,
541
+ package_type = cls .default_package_type ,
542
+ )
537
543
538
544
539
545
class PypiEggHandler (BasePypiHandler ):
@@ -547,20 +553,26 @@ class PypiEggHandler(BasePypiHandler):
547
553
548
554
@classmethod
549
555
def parse (cls , location ):
550
- with zipfile .ZipFile (location ) as zf :
551
- for path in ZipPath (zf ).iterdir ():
552
- if not path .name .endswith (META_DIR_SUFFIXES ):
553
- continue
554
556
555
- for metapath in path .iterdir ():
556
- if not metapath .name .endswith ('PKG-INFO' ):
557
+ from python_inspector import lockfile
558
+ from python_inspector .utils_pypi import PYINSP_CACHE_LOCK_TIMEOUT
559
+ lock_file = os .path .join (f"{ location } .lockfile" )
560
+ with lockfile .FileLock (lock_file ).locked (timeout = PYINSP_CACHE_LOCK_TIMEOUT ):
561
+
562
+ with zipfile .ZipFile (location ) as zf :
563
+ for path in ZipPath (zf ).iterdir ():
564
+ if not path .name .endswith (META_DIR_SUFFIXES ):
557
565
continue
558
566
559
- yield parse_metadata (
560
- location = metapath ,
561
- datasource_id = cls .datasource_id ,
562
- package_type = cls .default_package_type ,
563
- )
567
+ for metapath in path .iterdir ():
568
+ if not metapath .name .endswith ('PKG-INFO' ):
569
+ continue
570
+
571
+ yield parse_metadata (
572
+ location = metapath ,
573
+ datasource_id = cls .datasource_id ,
574
+ package_type = cls .default_package_type ,
575
+ )
564
576
565
577
566
578
class PypiSdistArchiveHandler (BasePypiHandler ):
@@ -765,7 +777,6 @@ def parse(cls, location):
765
777
)
766
778
]
767
779
768
-
769
780
yield models .PackageData (
770
781
datasource_id = cls .datasource_id ,
771
782
type = cls .default_package_type ,
@@ -818,6 +829,7 @@ def get_resolved_purl(purl: PackageURL, specifiers: SpecifierSet):
818
829
is_resolved = is_resolved ,
819
830
)
820
831
832
+
821
833
class PipfileHandler (BaseDependencyFileHandler ):
822
834
datasource_id = 'pipfile'
823
835
path_patterns = ('*Pipfile' ,)
0 commit comments