Skip to content

Commit

Permalink
Replace distutils with packaging
Browse files Browse the repository at this point in the history
  • Loading branch information
pquentin committed Oct 3, 2023
1 parent 7ecebd4 commit 1dbe81d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
9 changes: 6 additions & 3 deletions eland/ml/_optional.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@
# specific language governing permissions and limitations
# under the License.

import distutils.version
import importlib
import warnings
from typing import TYPE_CHECKING, Any, Optional

import packaging.version

if TYPE_CHECKING:
from types import ModuleType

Expand All @@ -30,7 +31,7 @@
# The license for this library can be found NOTICE.txt and the code can be
# https://raw.githubusercontent.com/pandas-dev/pandas/v1.0.1/pandas/compat/_optional.py

VERSIONS = {"xgboost": "0.90", "sklearn": "0.22.1"}
VERSIONS = {"xgboost": "0.90", "sklearn": "1.3"}

# Update install.rst when updating versions!

Expand Down Expand Up @@ -104,7 +105,9 @@ def import_optional_dependency(
minimum_version = VERSIONS.get(name)
if minimum_version:
version = _get_version(module)
if distutils.version.LooseVersion(version) < minimum_version:
if packaging.version.parse(version) < packaging.version.Version(
minimum_version
):
assert on_version in {"warn", "raise", "ignore"}
msg = version_message.format(
minimum_version=minimum_version, name=name, actual_version=version
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
"pandas>=1.5,<2",
"matplotlib>=3.6",
"numpy>=1.2.0,<1.24",
"packaging",
],
entry_points={
"console_scripts": "eland_import_hub_model=eland.cli.eland_import_hub_model:main"
Expand Down

0 comments on commit 1dbe81d

Please sign in to comment.