def was_installed_by_pip(pkg):<EOL>
try:<EOL><INDENT>dist = pkg_resources.get_distribution(pkg)<EOL>return (dist.has_metadata('<STR_LIT>') and<EOL>'<STR_LIT>' in dist.get_metadata_lines('<STR_LIT>'))<EOL><DEDENT>except pkg_resources.DistributionNotFound:<EOL><INDENT>return False<EOL><DEDENT>
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.