Skip to content

Commit ce90b0e

Browse files
authored
[Deprecation] Deprecate python2 as it has reached EOF on Jan 1st, 2020 (#1141)
* add warning * fix lint
1 parent 51c0b08 commit ce90b0e

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

gluoncv/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
from . import model_zoo
1010
from . import nn
1111
from . import utils
12-
from .utils.version import _require_mxnet_version
12+
from .utils.version import _require_mxnet_version, _deprecate_python2
1313
from . import loss
1414

15+
_deprecate_python2()
1516
_require_mxnet_version('1.4.0')

gluoncv/utils/version.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
"""Utility functions for version checking."""
2+
import sys
23
import warnings
34

4-
__all__ = ['check_version', '_require_mxnet_version']
5+
__all__ = ['check_version', '_require_mxnet_version', '_deprecate_python2']
56

67
def check_version(min_version, warning_only=False):
78
"""Check the version of gluoncv satisfies the provided minimum version.
@@ -35,10 +36,18 @@ def _require_mxnet_version(mx_version):
3536
"Legacy mxnet-mkl=={} detected, some new modules may not work properly. "
3637
"mxnet-mkl>={} is required. You can use pip to upgrade mxnet "
3738
"`pip install mxnet-mkl --pre --upgrade` "
38-
"or `pip install mxnet-cu90mkl --pre --upgrade`").format(mx.__version__, mx_version)
39+
"or `pip install mxnet-cu100mkl --pre --upgrade`\
40+
").format(mx.__version__, mx_version)
3941
raise ImportError(msg)
4042
except ImportError:
4143
raise ImportError(
4244
"Unable to import dependency mxnet. "
43-
"A quick tip is to install via `pip install mxnet-mkl/mxnet-cu90mkl --pre`. "
45+
"A quick tip is to install via `pip install mxnet-mkl/mxnet-cu100mkl --pre`. "
4446
"please refer to https://gluon-cv.mxnet.io/#installation for details.")
47+
48+
def _deprecate_python2():
49+
if sys.version_info[0] < 3:
50+
msg = 'Python2 has reached the end of its life on January 1st, 2020. ' + \
51+
'A future version of gluoncv will drop support for Python 2.'
52+
warnings.simplefilter('always', DeprecationWarning)
53+
warnings.warn(msg, DeprecationWarning)

0 commit comments

Comments
 (0)