@@ -112,7 +112,6 @@ def get_available_package_parsers(docs=False):
112112 return all_data_packages
113113
114114
115-
116115@scan_impl
117116class PackageScanner (ScanPlugin ):
118117 """
@@ -161,7 +160,19 @@ class PackageScanner(ScanPlugin):
161160 help_group = SCAN_GROUP ,
162161 sort_order = 21 ,
163162 ),
164-
163+ PluggableCommandLineOption (
164+ (
165+ '--package-only' ,
166+ ),
167+ is_flag = True ,
168+ default = False ,
169+ help = (
170+ 'Only detect package information and skip license/copyright detection steps, '
171+ 'in application package and dependency manifests, lockfiles and related data.'
172+ ),
173+ help_group = SCAN_GROUP ,
174+ sort_order = 22 ,
175+ ),
165176 PluggableCommandLineOption (
166177 ('--list-packages' ,),
167178 is_flag = True ,
@@ -172,10 +183,10 @@ class PackageScanner(ScanPlugin):
172183 ),
173184 ]
174185
175- def is_enabled (self , package , system_package , ** kwargs ):
176- return package or system_package
186+ def is_enabled (self , package , system_package , package_only , ** kwargs ):
187+ return package or system_package or package_only
177188
178- def get_scanner (self , package = True , system_package = False , ** kwargs ):
189+ def get_scanner (self , package = True , system_package = False , package_only = False , ** kwargs ):
179190 """
180191 Return a scanner callable to scan a file for package data.
181192 """
@@ -185,9 +196,10 @@ def get_scanner(self, package=True, system_package=False, **kwargs):
185196 get_package_data ,
186197 application = package ,
187198 system = system_package ,
199+ package_only = package_only ,
188200 )
189201
190- def process_codebase (self , codebase , strip_root = False , ** kwargs ):
202+ def process_codebase (self , codebase , strip_root = False , package_only = False , ** kwargs ):
191203 """
192204 Populate the ``codebase`` top level ``packages`` and ``dependencies``
193205 with package and dependency instances, assembling parsed package data
@@ -196,6 +208,11 @@ def process_codebase(self, codebase, strip_root=False, **kwargs):
196208 Also perform additional package license detection that depends on either
197209 file license detection or the package detections.
198210 """
211+ # If we only want purls, we want to skip both the package
212+ # assembly and the extra package license detection steps
213+ if package_only :
214+ return
215+
199216 has_licenses = hasattr (codebase .root , 'license_detections' )
200217
201218 # These steps add proper license detections to package_data and hence
0 commit comments