def verify_no_pip_install()

in quality-checks/pip_install_check.py [0:0]


def verify_no_pip_install(directory: Path) -> bool:
    """
    Verify there is no direct use of `pip install` in the directory tree.

    :param directory: The directory to scan.

    :returns True if the verification succeeds, otherwise False.
    """
    # Check if the directory exists
    if not directory.is_dir():
        print(f"The directory {directory} does not exist.")
        return True

    # Walk through the shell scripts in the directory tree.
    ret_code = True
    for filepath in directory.glob("**/*.sh"):
        if any(filepath.match(p) for p in PIP_INSTALL_ALLOWLIST):
            print(f"Ignoring {filepath} since it is in the allowlist.")
            continue
        if check_file_for_pip_install(filepath):
            print(f"{EMJOI_CHECK_MARK_BUTTON} {filepath}")
        else:
            print(f"{EMJOI_CROSS_MARK} {filepath}.")
            ret_code = False

    return ret_code