code: def resolve_requirements(self, interpreter, req_libs):
      
      with self.invalidated(req_libs) as invalidation_check:
        # If there are no relevant targets, we still go through the motions of resolving
        # an empty set of requirements, to prevent downstream tasks from having to check
        # for this special case.
        if invalidation_check.all_vts:
          target_set_id = VersionedTargetSet.from_versioned_targets(
              invalidation_check.all_vts).cache_key.hash
        else:
          target_set_id = 'no_targets'
  
        # We need to ensure that we are resolving for only the current platform if we are
        # including local python dist targets that have native extensions.
        targets_by_platform = pex_build_util.targets_by_platform(self.context.targets(), self._python_setup)
        if self._python_native_code_settings.check_build_for_current_platform_only(targets_by_platform):
          platforms = ['current']
        else:
          platforms = list(sorted(targets_by_platform.keys()))
  
        path = os.path.realpath(os.path.join(self.workdir, str(interpreter.identity), target_set_id))
        # Note that we check for the existence of the directory, instead of for invalid_vts,
        # to cover the empty case.
        if not os.path.isdir(path):
          with safe_concurrent_creation(path) as safe_path:
            pex_builder = PexBuilderWrapper.Factory.create(
              builder=PEXBuilder(path=safe_path, interpreter=interpreter, copy=True),
              log=self.context.log)
            pex_builder.add_requirement_libs_from(req_libs, platforms=platforms)
            pex_builder.freeze()
      return PEX(path, interpreter=interpreter)
docs: Requirements resolution for PEX files.
  
      :param interpreter: Resolve against this :class:`PythonInterpreter`.
      :param req_libs: A list of :class:`PythonRequirementLibrary` targets to resolve.
      :returns: a PEX containing target requirements and any specified python dist targets.