diff --git a/python/taichi/__init__.py b/python/taichi/__init__.py index e96ae156999cc..837d9998ede90 100644 --- a/python/taichi/__init__.py +++ b/python/taichi/__init__.py @@ -2,6 +2,7 @@ from taichi._funcs import * from taichi._lib import core as _ti_core +from taichi._lib.utils import warn_restricted_version from taichi._logging import * from taichi._snode import * from taichi.lang import * # pylint: disable=W0622 # TODO(archibate): It's `taichi.lang.core` overriding `taichi.core` @@ -93,3 +94,6 @@ def __getattr__(attr): del sys del _ti_core + +warn_restricted_version() +del warn_restricted_version diff --git a/python/taichi/_lib/utils.py b/python/taichi/_lib/utils.py index 9c6869a0fc772..cb5c1d3b468f3 100644 --- a/python/taichi/_lib/utils.py +++ b/python/taichi/_lib/utils.py @@ -2,6 +2,7 @@ import platform import re import sys +import warnings from colorama import Fore, Style @@ -202,7 +203,9 @@ def try_get_loaded_libc_version(): def try_get_pip_version(): try: - import pip # pylint: disable=import-outside-toplevel + with warnings.catch_warnings(): + warnings.simplefilter("ignore") + import pip # pylint: disable=import-outside-toplevel return tuple([int(v) for v in pip.__version__.split('.')]) except ImportError: return None @@ -244,6 +247,3 @@ def warn_restricted_version(): ) except Exception: pass - - -warn_restricted_version()