apache / mxnet

Lightweight, Portable, Flexible Distributed/Mobile Deep Learning with Dynamic, Mutation-aware Dataflow Dep Scheduler; for Python, R, Julia, Scala, Go, Javascript and more
https://mxnet.apache.org
Apache License 2.0
20.75k stars 6.8k forks source link

DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead. #20824

Open FrancescoCasalegno opened 2 years ago

FrancescoCasalegno commented 2 years ago

Description

setuptools has deprecated the usage of distutils Version classes since version 60.3.0. See https://github.com/pypa/setuptools/commit/1701579e0827317d8888c2254a17b5786b6b5246 for details.

As a consequence, a warning is raised any time we try, e.g., to do from docker import from_env. Notice that this warning can be fatal if the user has set a warning filter to error mode, which is not too uncommon when running unit tests in CI.

Error Message

/opt/hostedtoolcache/Python/3.7.12/x64/lib/python3.7/site-packages/mxnet/__init__.py:104: in <module>
    from . import numpy_dispatch_protocol
/opt/hostedtoolcache/Python/3.7.12/x64/lib/python3.7/site-packages/mxnet/numpy_dispatch_protocol.py:193: in <module>
    @with_array_function_protocol
/opt/hostedtoolcache/Python/3.7.12/x64/lib/python3.7/site-packages/mxnet/numpy_dispatch_protocol.py:48: in with_array_function_protocol
    cur_np_ver = LooseVersion(_np.__version__)
/opt/hostedtoolcache/Python/3.7.12/x64/lib/python3.7/site-packages/setuptools/_distutils/version.py:57: in __init__
    stacklevel=2,
E   DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.

To Reproduce

import warnings
warnings.filterwarnings("error")

import mxnet as mx

What have you tried to solve it?

To fix the problem we should replace occurrences of distutils.Version (and its subclasses) with packaging.Version.

There are only few cases where intervention is needed, see full list here.

github-actions[bot] commented 2 years ago

Welcome to Apache MXNet (incubating)! We are on a mission to democratize AI, and we are glad that you are contributing to it by opening this issue. Please make sure to include all the relevant context, and one of the @apache/mxnet-committers will be here shortly. If you are interested in contributing to our project, let us know! Also, be sure to check out our guide on contributing to MXNet and our development guides wiki.