Skip to content

Commit

Permalink
Fix #981: replace deprecated pkg_resources calls (#982)
Browse files Browse the repository at this point in the history
  • Loading branch information
ottonemo authored Jun 19, 2023
1 parent de718ef commit 5f1ec03
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions skorch/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
import sys
import warnings

import pkg_resources
from pkg_resources import parse_version
import importlib.metadata

from .history import History
from .net import NeuralNet
from .classifier import NeuralNetClassifier
from .classifier import NeuralNetBinaryClassifier
from .regressor import NeuralNetRegressor
from . import callbacks
from ._version import Version


MIN_TORCH_VERSION = '1.1.0'
Expand All @@ -26,8 +26,8 @@
"(aka 'torch'). "
"Visit https://pytorch.org/ for installation instructions.")

torch_version = pkg_resources.get_distribution('torch').version
if parse_version(torch_version) < parse_version(MIN_TORCH_VERSION):
torch_version = torch.__version__
if Version(torch_version) < Version(MIN_TORCH_VERSION):
msg = ('skorch depends on a newer version of PyTorch (at least {req}, not '
'{installed}). Visit https://pytorch.org for installation details')
raise ImportWarning(msg.format(req=MIN_TORCH_VERSION, installed=torch_version))
Expand All @@ -42,8 +42,7 @@
'callbacks',
]


try:
__version__ = pkg_resources.get_distribution('skorch').version
__version__ = importlib.metadata.version("skorch")
except: # pylint: disable=bare-except
__version__ = 'n/a'
Binary file modified skorch/tests/net_cuda.pkl
Binary file not shown.

0 comments on commit 5f1ec03

Please sign in to comment.