Minimum NumPy & SciPY Dependencies

Hi all,

For each version of numba, is there an easy way to determine what the corresponding minimum supported version of python, numpy and scipy would be?

1 Like

I usually get that info (sans scipy) from the .whl file, something like

 if pip_file.endswith('.whl'):
            with zipfile.ZipFile(pip_file) as pip_content:
                pip_meta_file = next(_ for _ in pip_content.namelist() if _.endswith('.dist-info/METADATA'))
                pip_meta = pip_content.read(pip_meta_file)
                for _ in sorted(re.findall(r'^(\S+:\s+.+)$', pip_meta.decode(), re.MULTILINE)):
                     print(_)

snipped output

Requires-Dist: importlib-metadata ; python_version < “3.9”
Requires-Dist: llvmlite (<0.40,>=0.39.0dev0)
Requires-Dist: numpy (<1.24,>=1.18)
Requires-Dist: setuptools
Requires-Python: >=3.7
Summary: compiling Python code using LLVM
Version: 0.56.4

This might be useful too:

https://numba.readthedocs.io/en/stable/user/installing.html#version-support-information

Thank you all for your input. I ended up writing a small Python script that determines the minimum versions based on the following logic:

  1. Choose the desired minimum python version to support (e.g., python 3.8)
  2. Determine the minimum numba version that supports the minimum python version based on this table (e.g., numba 0.57.0) AND also get the corresponding minimum numpy version (e.g., numpy 1.21)
  3. Finally, determine the minimum scipy version that supports the minimum python and numpy versions based on this table but note that the python and numpy versions supported are in ranges and your minimum versions are likely captured within (i.e., in the middle) of the range

All of this is handled within the aforementioned script.

import pandas as pd
from packaging.specifiers import SpecifierSet
from packaging.version import Version


def check_compatibility(row, min_python, min_numpy):
    """
    Determines the Python and NumPy version compatibility
    """
    python_compatible = min_python in (row.MIN_PYTHON_SPEC & row.MAX_PYTHON_SPEC)
    numpy_compatible = min_numpy in (row.MIN_NUMPY_SPEC & row.MAX_NUMPY_SPEC)
    return python_compatible & numpy_compatible


MIN_PYTHON = "3.8"  # Change this

df = (
    pd.read_html(
        "https://numba.readthedocs.io/en/stable/user/installing.html#version-support-information"  # noqa
    )[0]
    .dropna()
    .query(f'Python.str.startswith("{MIN_PYTHON}")', engine="python")
    .pipe(lambda df: df.assign(NumPy=df.NumPy.str.split().str[0]))
    .iloc[-1]
)
MIN_NUMBA = df.Numba
MIN_NUMPY = df.NumPy

df = (
    pd.read_html("https://docs.scipy.org/doc/scipy/dev/toolchain.html#numpy")[1]
    .replace({".x": ""}, regex=True)
    .rename(columns=lambda x: x.replace(" ", "_"))
    .query('`Python_versions`.str.contains("2.7") == False')
    .pipe(
        lambda df: df.assign(
            MIN_PYTHON_SPEC=df.Python_versions.str.split(",").str[0].apply(SpecifierSet)
        )
    )
    .pipe(
        lambda df: df.assign(
            MAX_PYTHON_SPEC=df.Python_versions.str.split(",").str[1].apply(SpecifierSet)
        )
    )
    .pipe(
        lambda df: df.assign(
            MIN_NUMPY_SPEC=df.NumPy_versions.str.split(",").str[0].apply(SpecifierSet)
        )
    )
    .pipe(
        lambda df: df.assign(
            MAX_NUMPY_SPEC=df.NumPy_versions.str.split(",").str[1].apply(SpecifierSet)
        )
    )
    .assign(
        COMPATIBLE=lambda row: row.apply(
            check_compatibility, axis=1, args=(Version(MIN_PYTHON), Version(MIN_NUMPY))
        )
    )
    .query("COMPATIBLE == True")
    .iloc[-1]
)
MIN_SCIPY = df.SciPy_version

print(
    f"python: {MIN_PYTHON}\nnumba: {MIN_NUMBA}\nnumpy: {MIN_NUMPY}\nscipy: {MIN_SCIPY}"
)

For python 3.8, this will print out the following minimum dependencies:

python: 3.8
numba: 0.57.0
numpy: 1.21
scipy: 1.10

Can you change the script to retrieve the latest patch release for Numba. In the above I think it would be 0.57.1 rather than 0.57.0.

1 Like