Check requirements file is updated relatively to prev. version of the file.

    :param str fpath: Path to the requirements file.
    :param str prev_version_fpath: Path to the prev. version requirements file.
    :rtype: bool
    :raise ValueError: Requirements file doesn't exist.

def is_changed(fpath, prev_version_fpath):
    """Check requirements file is updated relatively to prev. version of the file.

    :param str fpath: Path to the requirements file.
    :param str prev_version_fpath: Path to the prev. version requirements file.
    :rtype: bool
    :raise ValueError: Requirements file doesn't exist.
    """
    if not (fpath and os.path.isfile(fpath)):
        raise ValueError("Requirements file {0!r} doesn't exist.".format(fpath))

    # Compile the list of new requirements.
    new_requirements = parse_pip_requirements(fpath)

    # Hash them.
    new_requirements_hash = _str_to_sha1hex(str(new_requirements))

    # Read the hash of the previous requirements if any.
    previous_requirements_hash = 0
    if os.path.exists(prev_version_fpath):
        with open(prev_version_fpath) as fd:
            previous_requirements_hash = fd.read()

    # Create/Update the file with the hash of the new requirements.
    dirname = os.path.dirname(prev_version_fpath)
    # First time when running tox in the project .tox directory is missing.
    if not os.path.isdir(dirname):
        os.makedirs(dirname)
    with open(prev_version_fpath, 'w+') as fd:
        fd.write(new_requirements_hash)

    # Compare the hash of the new requirements with the hash of the previous
    # requirements.
    return previous_requirements_hash != new_requirements_hash