Repository: numpy/numpy
File: tools/check_openblas_version.py (Python)

Code before:
    def get_version(line):
        req = line.split(";")[0].split("==")[1].split(".")[:5]
        return tuple(int(s) for s in req)

    def parse_reqs(reqfile):
        with open(reqfile) as f:
            lines = f.readlines()

        v32 = None
        v64 = None
        for line in lines:
            if "scipy-openblas32" in line:
                v32 = get_version(line)
            if "scipy-openblas64" in line:
                v64 = get_version(line)
        return v32, v64

    this_dir = os.path.abspath(os.path.dirname(__file__))
    reqfile_thisrepo = os.path.join(this_dir, '..', 'requirements',
                                    'ci_requirements.txt')

    v32_thisrepo, v64_thisrepo = parse_reqs(reqfile_thisrepo)
    v32_rel, v64_rel = parse_reqs(reqfile)

    def compare_versions(v_rel, v_thisrepo, bits):
        if not v64_rel >= v64_thisrepo:
            raise AssertionError(f"`numpy-release` version of scipy-openblas{bits} "
                                 f"{v_rel} is behind this repo: {v_thisrepo}")

    compare_versions(v64_rel, v64_thisrepo, "64")
    compare_versions(v32_rel, v32_thisrepo, "32")


def main():
    parser = argparse.ArgumentParser()
    parser.add_argument(
        "--req-files",
        type=str,
        help="Path to the requirements file to compare with the one in this repo"
    )
    parser.add_argument(
        "--min-version",
        type=str,
        help="The minimum version that should have been used at build time for "
             "installed `numpy` package"
    )
    args = parser.parse_args()

    if args.min_version is None and args.req_files is None:
        raise ValueError("One of `--req-files` or `--min-version` needs to be "
                         "specified")

Review comment (suggestion):
```suggestion
        if not v_rel >= v_thisrepo:
```

Code after:
    def get_version(line):
        req = line.split(";")[0].split("==")[1].split(".")[:5]
        return tuple(int(s) for s in req)

    def parse_reqs(reqfile):
        with open(reqfile) as f:
            lines = f.readlines()

        v32 = None
        v64 = None
        for line in lines:
            if "scipy-openblas32" in line:
                v32 = get_version(line)
            if "scipy-openblas64" in line:
                v64 = get_version(line)
        if v32 is None or v64 is None:
            raise AssertionError("Expected `scipy-openblas32` and "
                                 "`scipy-openblas64` in `ci_requirements.txt`, "
                                 f"got:\n  {'  '.join(lines)}")
        return v32, v64

    this_dir = os.path.abspath(os.path.dirname(__file__))
    reqfile_thisrepo = os.path.join(this_dir, '..', 'requirements',
                                    'ci_requirements.txt')

    v32_thisrepo, v64_thisrepo = parse_reqs(reqfile_thisrepo)
    v32_rel, v64_rel = parse_reqs(reqfile)

    def compare_versions(v_rel, v_thisrepo, bits):
        if not v_rel >= v_thisrepo:
            raise AssertionError(f"`numpy-release` version of scipy-openblas{bits} "
                                 f"{v_rel} is behind this repo: {v_thisrepo}")

    compare_versions(v64_rel, v64_thisrepo, "64")
    compare_versions(v32_rel, v32_thisrepo, "32")


def main():
    parser = argparse.ArgumentParser()
    parser.add_argument(
        "--req-files",
        type=str,
        help="Path to the requirements file to compare with the one in this repo"
    )
    parser.add_argument(
        "--min-version",
        type=str,
        help="The minimum version that should have been used at build time for "
             "installed `numpy` package"
    )
    args = parser.parse_args()