|
| 1 | +#!/usr/bin/env python |
| 2 | + |
| 3 | +import pandas as pd |
| 4 | +from packaging.specifiers import SpecifierSet |
| 5 | +from packaging.version import Version |
| 6 | + |
| 7 | + |
| 8 | +def check_compatibility(row, min_python, min_numpy): |
| 9 | + """ |
| 10 | + Determines the Python and NumPy version compatibility |
| 11 | + """ |
| 12 | + python_compatible = min_python in (row.MIN_PYTHON_SPEC & row.MAX_PYTHON_SPEC) |
| 13 | + numpy_compatible = min_numpy in (row.MIN_NUMPY_SPEC & row.MAX_NUMPY_SPEC) |
| 14 | + return python_compatible & numpy_compatible |
| 15 | + |
| 16 | + |
| 17 | +MIN_PYTHON = "3.8" # Change this |
| 18 | + |
| 19 | +df = ( |
| 20 | + pd.read_html( |
| 21 | + "https://numba.readthedocs.io/en/stable/user/installing.html#version-support-information" # noqa |
| 22 | + )[0] |
| 23 | + .dropna() |
| 24 | + .query(f'Python.str.startswith("{MIN_PYTHON}")', engine="python") |
| 25 | + .pipe(lambda df: df.assign(NumPy=df.NumPy.str.split().str[0])) |
| 26 | + .iloc[-1] |
| 27 | +) |
| 28 | +MIN_NUMBA = df.Numba |
| 29 | +MIN_NUMPY = df.NumPy |
| 30 | + |
| 31 | +df = ( |
| 32 | + pd.read_html("https://docs.scipy.org/doc/scipy/dev/toolchain.html#numpy")[1] |
| 33 | + .replace({".x": ""}, regex=True) |
| 34 | + .rename(columns=lambda x: x.replace(" ", "_")) |
| 35 | + .query('`Python_versions`.str.contains("2.7") == False') |
| 36 | + .pipe( |
| 37 | + lambda df: df.assign( |
| 38 | + MIN_PYTHON_SPEC=df.Python_versions.str.split(",").str[0].apply(SpecifierSet) |
| 39 | + ) |
| 40 | + ) |
| 41 | + .pipe( |
| 42 | + lambda df: df.assign( |
| 43 | + MAX_PYTHON_SPEC=df.Python_versions.str.split(",").str[1].apply(SpecifierSet) |
| 44 | + ) |
| 45 | + ) |
| 46 | + .pipe( |
| 47 | + lambda df: df.assign( |
| 48 | + MIN_NUMPY_SPEC=df.NumPy_versions.str.split(",").str[0].apply(SpecifierSet) |
| 49 | + ) |
| 50 | + ) |
| 51 | + .pipe( |
| 52 | + lambda df: df.assign( |
| 53 | + MAX_NUMPY_SPEC=df.NumPy_versions.str.split(",").str[1].apply(SpecifierSet) |
| 54 | + ) |
| 55 | + ) |
| 56 | + .assign( |
| 57 | + COMPATIBLE=lambda row: row.apply( |
| 58 | + check_compatibility, axis=1, args=(Version(MIN_PYTHON), Version(MIN_NUMPY)) |
| 59 | + ) |
| 60 | + ) |
| 61 | + .query("COMPATIBLE == True") |
| 62 | + .iloc[-1] |
| 63 | +) |
| 64 | +MIN_SCIPY = df.SciPy_version |
| 65 | + |
| 66 | +print( |
| 67 | + f"python: {MIN_PYTHON}\nnumba: {MIN_NUMBA}\nnumpy: {MIN_NUMPY}\nscipy: {MIN_SCIPY}" |
| 68 | +) |
0 commit comments