From 959f9c9e8cfc177ad04e41ba00a357ebbb3d8016 Mon Sep 17 00:00:00 2001 From: yancong <32220263+ice-tong@users.noreply.github.com> Date: Sat, 4 Feb 2023 11:41:49 +0800 Subject: [PATCH] [Fix] Fix AssertionError when importing pip before setuptools (#198) * fix AssertionError when importing pip before setuptools * refine comments --- mim/__init__.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/mim/__init__.py b/mim/__init__.py index a854bbe..9da953b 100644 --- a/mim/__init__.py +++ b/mim/__init__.py @@ -1,4 +1,18 @@ # Copyright (c) OpenMMLab. All rights reserved. + +# NOTE: We could got AssertionError when importing pip before +# setuptools. A workaround is to import setuptools first and filter +# warnings that are caused by setuptools replacing distutils. +# Related issues: +# - https://github.com/pypa/setuptools/issues/3621 +# - https://github.com/open-mmlab/mmclassification/issues/1343 +try: + import setuptools # noqa: F401 + import warnings + warnings.filterwarnings('ignore', 'Setuptools is replacing distutils') +except ImportError: + pass + from .commands import ( download, get_model_info,