code: def get_dependencies(requirement, sources):
      
      getters = [
          _get_dependencies_from_cache,
          _cached(_get_dependencies_from_json, sources=sources),
          _cached(_get_dependencies_from_pip, sources=sources),
      ]
      ireq = requirement.as_ireq()
      last_exc = None
      for getter in getters:
          try:
              result = getter(ireq)
          except Exception as e:
              last_exc = sys.exc_info()
              continue
          if result is not None:
              deps, pyreq = result
              reqs = [requirementslib.Requirement.from_line(d) for d in deps]
              return reqs, pyreq
      if last_exc:
          six.reraise(*last_exc)
      raise RuntimeError("failed to get dependencies for {}".format(
          requirement.as_line(),
      ))
docs: Get all dependencies for a given install requirement.
  
      :param requirement: A requirement
      :param sources: Pipfile-formatted sources
      :type sources: list[dict]