Skip to content

Commit 1936392

Browse files
committed
Added minimum dependency compatibility script
1 parent 82a6f59 commit 1936392

File tree

3 files changed

+71
-6
lines changed

3 files changed

+71
-6
lines changed

min.py

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
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+
)

pypi.sh

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@
33
# 1. Update version number in setup.py
44
# 2. Update CHANGELOG
55
# 3. Update README with new features/functions/tutorials
6-
# 4. Determine minimum dependencies
7-
# a) Find the minimum Python and NumPy version you want to support: https://numpy.org/neps/nep-0029-deprecation_policy.html#support-table
8-
# b) Then find the SciPy version that has a "Python" version and "Minimum NumPy version" that is supported: https://docs.scipy.org/doc/scipy/dev/toolchain.html#numpyy
9-
# c) Check Numba for mimumum Python and NumPy versions supported: https://numba.readthedocs.io/en/stable/user/installing.html#version-support-information
6+
# 4. Determine minimum dependencies with ./min.py
107
# 5. Bump minimum dependencies
118
# a) setup.py
129
# b) requirements.txt

test.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ test_custom()
107107
# ./test.sh custom 5 tests/test_stump.py
108108
# ./test.sh custom 5 tests/test_stump.py::test_stump_self_join
109109
#
110-
# You may mimic coverag testing conditions by disable `numba` JIT
110+
# You may mimic coverage testing conditions by disabling `numba` JIT
111111
# and enabling the `cuda` simulator by setting two environment
112112
# variables prior to calling `test.sh`:
113113
#
@@ -161,7 +161,7 @@ test_coverage()
161161
coverage run --append --source=. -m pytest -rsx -W ignore::RuntimeWarning -W ignore::DeprecationWarning -W ignore::UserWarning $testfile
162162
check_errs $?
163163
done
164-
coverage report -m --fail-under=100 --skip-covered --omit=setup.py,docstring.py,stumpy/cache.py
164+
coverage report -m --fail-under=100 --skip-covered --omit=setup.py,docstring.py,min.py,stumpy/cache.py
165165
}
166166

167167
check_links()

0 commit comments

Comments
 (0)