1"""All minimum dependencies for scikit-learn."""
2import platform
3import argparse
4
5
6# numpy scipy and cython should by in sync with pyproject.toml
7if platform.python_implementation() == "PyPy":
8    NUMPY_MIN_VERSION = "1.19.0"
9else:
10    # We pinned PyWavelet (a scikit-image dependence) to 1.1.1 in the minimum
11    # documentation CI builds that is the latest version that support our
12    # minimum NumPy version required. If PyWavelets 1.2+ is installed, it would
13    # require NumPy 1.17+ that trigger a bug with Pandas 0.25:
14    # https://github.com/numpy/numpy/issues/18355#issuecomment-774610226
15    # When upgrading NumPy, we can unpin PyWavelets but we need to update the
16    # minimum version of Pandas >= 1.0.5.
17    NUMPY_MIN_VERSION = "1.14.6"
18
19SCIPY_MIN_VERSION = "1.1.0"
20JOBLIB_MIN_VERSION = "0.11"
21THREADPOOLCTL_MIN_VERSION = "2.0.0"
22PYTEST_MIN_VERSION = "5.0.1"
23CYTHON_MIN_VERSION = "0.29.24"
24
25
26# 'build' and 'install' is included to have structured metadata for CI.
27# It will NOT be included in setup's extras_require
28# The values are (version_spec, comma separated tags)
29dependent_packages = {
30    "numpy": (NUMPY_MIN_VERSION, "build, install"),
31    "scipy": (SCIPY_MIN_VERSION, "build, install"),
32    "joblib": (JOBLIB_MIN_VERSION, "install"),
33    "threadpoolctl": (THREADPOOLCTL_MIN_VERSION, "install"),
34    "cython": (CYTHON_MIN_VERSION, "build"),
35    "matplotlib": ("2.2.3", "benchmark, docs, examples, tests"),
36    "scikit-image": ("0.14.5", "docs, examples, tests"),
37    "pandas": ("0.25.0", "benchmark, docs, examples, tests"),
38    "seaborn": ("0.9.0", "docs, examples"),
39    "memory_profiler": ("0.57.0", "benchmark, docs"),
40    "pytest": (PYTEST_MIN_VERSION, "tests"),
41    "pytest-cov": ("2.9.0", "tests"),
42    "flake8": ("3.8.2", "tests"),
43    "black": ("21.6b0", "tests"),
44    "mypy": ("0.770", "tests"),
45    "pyamg": ("4.0.0", "tests"),
46    "sphinx": ("4.0.1", "docs"),
47    "sphinx-gallery": ("0.7.0", "docs"),
48    "numpydoc": ("1.0.0", "docs"),
49    "Pillow": ("7.1.2", "docs"),
50    "sphinx-prompt": ("1.3.0", "docs"),
51    "sphinxext-opengraph": ("0.4.2", "docs"),
52}
53
54
55# create inverse mapping for setuptools
56tag_to_packages: dict = {
57    extra: []
58    for extra in ["build", "install", "docs", "examples", "tests", "benchmark"]
59}
60for package, (min_version, extras) in dependent_packages.items():
61    for extra in extras.split(", "):
62        tag_to_packages[extra].append("{}>={}".format(package, min_version))
63
64
65# Used by CI to get the min dependencies
66if __name__ == "__main__":
67    parser = argparse.ArgumentParser(description="Get min dependencies for a package")
68
69    parser.add_argument("package", choices=dependent_packages)
70    args = parser.parse_args()
71    min_version = dependent_packages[args.package][0]
72    print(min_version)
73