(self, downloaded)
| 332 | ) |
| 333 | |
| 334 | def lock(self, downloaded): |
| 335 | # type: (Downloaded) -> Tuple[LockedResolve, ...] |
| 336 | |
| 337 | dist_metadatas_by_download_target = defaultdict( |
| 338 | OrderedSet |
| 339 | ) # type: DefaultDict[DownloadTarget, OrderedSet[DistMetadata]] |
| 340 | build_requests = OrderedSet() # type: OrderedSet[BuildRequest] |
| 341 | |
| 342 | for local_distribution in downloaded.local_distributions: |
| 343 | if local_distribution.is_wheel: |
| 344 | dist_metadatas_by_download_target[local_distribution.download_target].add( |
| 345 | DistMetadata.load(local_distribution.path) |
| 346 | ) |
| 347 | elif os.path.isfile(local_distribution.path): |
| 348 | build_requests.add( |
| 349 | BuildRequest.for_file( |
| 350 | target=local_distribution.download_target, |
| 351 | source_path=local_distribution.path, |
| 352 | subdirectory=local_distribution.subdirectory, |
| 353 | ) |
| 354 | ) |
| 355 | else: |
| 356 | build_requests.add( |
| 357 | BuildRequest.for_directory( |
| 358 | target=local_distribution.download_target, |
| 359 | source_path=local_distribution.path, |
| 360 | subdirectory=local_distribution.subdirectory, |
| 361 | ) |
| 362 | ) |
| 363 | |
| 364 | resolved_requirements_by_download_target = ( |
| 365 | OrderedDict() |
| 366 | ) # type: OrderedDict[DownloadTarget, Tuple[ResolvedRequirement, ...]] |
| 367 | for analysis in self._analysis: |
| 368 | lock_result = analysis.analyzer.lock_result |
| 369 | build_requests.update( |
| 370 | BuildRequest.for_directory( |
| 371 | target=analysis.download_target, source_path=local_project |
| 372 | ) |
| 373 | for local_project in lock_result.local_projects |
| 374 | ) |
| 375 | resolved_requirements_by_download_target[ |
| 376 | analysis.download_target |
| 377 | ] = lock_result.resolved_requirements |
| 378 | |
| 379 | with TRACER.timed( |
| 380 | "Building {count} source {distributions} to gather metadata for lock.".format( |
| 381 | count=len(build_requests), distributions=pluralize(build_requests, "distribution") |
| 382 | ) |
| 383 | ): |
| 384 | pool = ThreadPool(processes=self.max_parallel_jobs) |
| 385 | try: |
| 386 | targets_and_project_directories = list( |
| 387 | pool.map(_prepare_project_directory, build_requests), |
| 388 | ) |
| 389 | finally: |
| 390 | pool.close() |
| 391 | pool.join() |
no test coverage detected