diff --git a/conftest.py b/conftest.py index ee8dcf1c..d6ff8b6a 100644 --- a/conftest.py +++ b/conftest.py @@ -1,5 +1,5 @@ import sys -from distutils.version import LooseVersion +from packaging.version import Version import sklearn import pytest @@ -13,9 +13,9 @@ def pytest_collection_modifyitems(config, items): try: import numpy as np - if LooseVersion(np.__version__) < LooseVersion("1.14") or LooseVersion( + if Version(np.__version__) < Version("1.14") or Version( sklearn.__version__ - ) < LooseVersion("0.23.0"): + ) < Version("0.23.0"): reason = ( "doctests are only run for numpy >= 1.14 " "and scikit-learn >=0.23.0" diff --git a/environment.yml b/environment.yml index fcb0d294..9a918045 100644 --- a/environment.yml +++ b/environment.yml @@ -3,3 +3,4 @@ dependencies: - numpy - scipy - scikit-learn + - packaging diff --git a/setup.py b/setup.py index 6c6399a5..f3e94be9 100755 --- a/setup.py +++ b/setup.py @@ -21,7 +21,12 @@ LICENSE = "new BSD" DOWNLOAD_URL = "https://github.com/scikit-learn-contrib/scikit-learn-extra" VERSION = __version__ # noqa -INSTALL_REQUIRES = ["numpy>=1.13.3", "scipy>=0.19.1", "scikit-learn>=0.23.0"] +INSTALL_REQUIRES = [ + "numpy>=1.13.3", + "scipy>=0.19.1", + "scikit-learn>=0.23.0", + "packaging", +] CLASSIFIERS = [ "Intended Audience :: Science/Research", "Intended Audience :: Developers", diff --git a/sklearn_extra/cluster/_commonnn.py b/sklearn_extra/cluster/_commonnn.py index 4683c0e6..57689792 100644 --- a/sklearn_extra/cluster/_commonnn.py +++ b/sklearn_extra/cluster/_commonnn.py @@ -6,7 +6,7 @@ # # License: BSD 3 clause -from distutils.version import LooseVersion +from packaging.version import Version import warnings import numpy as np @@ -15,7 +15,7 @@ import sklearn from sklearn.base import BaseEstimator, ClusterMixin -if LooseVersion(sklearn.__version__) < LooseVersion("0.23.0"): +if Version(sklearn.__version__) < Version("0.23.0"): from sklearn.utils import check_array, check_consistent_length # In scikit-learn version 0.23.x use