code: def was_installed_by_pip(pkg):
      # type: (str) -> bool
      
      try:
          dist = pkg_resources.get_distribution(pkg)
          return (dist.has_metadata('INSTALLER') and
                  'pip' in dist.get_metadata_lines('INSTALLER'))
      except pkg_resources.DistributionNotFound:
          return False
docs: Checks whether pkg was installed by pip
  
      This is used not to display the upgrade message when pip is in fact
      installed by system package manager, such as dnf on Fedora.