MCPcopy
hub / github.com/pex-tool/pex / _PipSession

Class _PipSession

pex/resolver.py:292–523  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

290
291@attr.s(frozen=True)
292class _PipSession(object):
293 requests = attr.ib(converter=_uniqued_download_requests) # type: Tuple[DownloadRequest, ...]
294 direct_requirements = attr.ib() # type: Iterable[ParsedRequirement]
295 allow_prereleases = attr.ib(default=False) # type: bool
296 transitive = attr.ib(default=True) # type: bool
297 package_index_configuration = attr.ib(default=None) # type: Optional[PackageIndexConfiguration]
298 build_configuration = attr.ib(default=BuildConfiguration()) # type: BuildConfiguration
299 observer = attr.ib(default=None) # type: Optional[ResolveObserver]
300 pip_log = attr.ib(default=None) # type: Optional[PipLog]
301 pip_version = attr.ib(default=None) # type: Optional[PipVersionValue]
302 resolver = attr.ib(default=None) # type: Optional[Resolver]
303 dependency_configuration = attr.ib(
304 default=DependencyConfiguration()
305 ) # type: DependencyConfiguration
306
307 def iter_local_projects(self):
308 # type: () -> Iterator[BuildRequest]
309 for requirement in self.direct_requirements:
310 if isinstance(requirement, LocalProjectRequirement):
311 for request in self.requests:
312 yield BuildRequest.for_directory(
313 target=request.target,
314 source_path=requirement.path,
315 editable=requirement.editable,
316 )
317
318 def generate_reports(self, max_parallel_jobs=None):
319 # type: (Optional[int]) -> Reports
320
321 if not self.requests or not any(request.has_requirements for request in self.requests):
322 # Nothing to report.
323 return Reports()
324
325 dest = safe_mkdtemp(
326 prefix="resolver_report.", dir=safe_mkdir(CacheDir.DOWNLOADS.path(".tmp"))
327 )
328
329 log_manager = PipLogManager.create(
330 self.pip_log,
331 download_targets=tuple(request.download_target for request in self.requests),
332 )
333 if self.pip_log and not self.pip_log.user_specified:
334 TRACER.log(
335 "Preserving `pip install --dry-run` log at {log_path}".format(
336 log_path=self.pip_log.path
337 ),
338 V=ENV.PEX_VERBOSE,
339 )
340
341 spawn_report = functools.partial(
342 self._spawn_report, resolved_target_dir=dest, log_manager=log_manager
343 )
344 with TRACER.timed(
345 "Resolving for:\n {}".format(
346 "\n ".join(request.render_description() for request in self.requests)
347 )
348 ):
349 try:

Callers 2

_download_internalFunction · 0.85
reportsFunction · 0.85

Calls 2

BuildConfigurationClass · 0.90

Tested by

no test coverage detected