from pathlib import Path


def is_installed_module(module_filename):
    """
    Checks if a module is "installed" (e.g. using pip), as opposed to a "local" module, belonging
    to user's env (e.g. local development tree).
    """
    return any(
        p.name in ['site-packages', 'dist-packages']
        for p in Path(module_filename).parents
    )