Skip to content

Commit

Permalink
[Deprecation] Deprecate python2 as it has reached EOF on Jan 1st, 2020 (
Browse files Browse the repository at this point in the history
#1141)

* add warning

* fix lint
  • Loading branch information
zhreshold authored Jan 13, 2020
1 parent 51c0b08 commit ce90b0e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
3 changes: 2 additions & 1 deletion gluoncv/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
from . import model_zoo
from . import nn
from . import utils
from .utils.version import _require_mxnet_version
from .utils.version import _require_mxnet_version, _deprecate_python2
from . import loss

_deprecate_python2()
_require_mxnet_version('1.4.0')
15 changes: 12 additions & 3 deletions gluoncv/utils/version.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
"""Utility functions for version checking."""
import sys
import warnings

__all__ = ['check_version', '_require_mxnet_version']
__all__ = ['check_version', '_require_mxnet_version', '_deprecate_python2']

def check_version(min_version, warning_only=False):
"""Check the version of gluoncv satisfies the provided minimum version.
Expand Down Expand Up @@ -35,10 +36,18 @@ def _require_mxnet_version(mx_version):
"Legacy mxnet-mkl=={} detected, some new modules may not work properly. "
"mxnet-mkl>={} is required. You can use pip to upgrade mxnet "
"`pip install mxnet-mkl --pre --upgrade` "
"or `pip install mxnet-cu90mkl --pre --upgrade`").format(mx.__version__, mx_version)
"or `pip install mxnet-cu100mkl --pre --upgrade`\
").format(mx.__version__, mx_version)
raise ImportError(msg)
except ImportError:
raise ImportError(
"Unable to import dependency mxnet. "
"A quick tip is to install via `pip install mxnet-mkl/mxnet-cu90mkl --pre`. "
"A quick tip is to install via `pip install mxnet-mkl/mxnet-cu100mkl --pre`. "
"please refer to https://gluon-cv.mxnet.io/#installation for details.")

def _deprecate_python2():
if sys.version_info[0] < 3:
msg = 'Python2 has reached the end of its life on January 1st, 2020. ' + \
'A future version of gluoncv will drop support for Python 2.'
warnings.simplefilter('always', DeprecationWarning)
warnings.warn(msg, DeprecationWarning)

0 comments on commit ce90b0e

Please sign in to comment.