From e70fa88d64fd3893269fb85bf6dfc03112250b2a Mon Sep 17 00:00:00 2001 From: ice-tong Date: Tue, 21 Jun 2022 01:50:42 +0800 Subject: [PATCH] refine(commands/install.py): refine check_mim_resources --- mim/commands/install.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/mim/commands/install.py b/mim/commands/install.py index 6529014..f76183c 100644 --- a/mim/commands/install.py +++ b/mim/commands/install.py @@ -321,7 +321,14 @@ def get_mminstall_from_pypi(mmpkg: str, def check_mim_resources() -> None: - """Check if the mim resource directory exists.""" + """Check if the mim resource directory exists. + + Newer versions of the OpenMMLab package have packaged the mim resource + files into the distribution package, while earlier versions do not. + + If the mim resources file (aka `.mim`) do not exists, log a warning that a + new version needs to be installed. + """ importlib.reload(pip._vendor.pkg_resources) for pkg in pip._vendor.pkg_resources.working_set: # type: ignore pkg_name = pkg.project_name @@ -333,6 +340,6 @@ def check_mim_resources() -> None: else: installed_path = os.path.join(pkg.location, pkg_name) mim_resources_path = os.path.join(installed_path, '.mim') - if os.path.join(mim_resources_path): + if not os.path.exists(mim_resources_path): echo_warning(f'mim resources not found: {mim_resources_path}, ' f'you can try to install the latest {pkg_name}.')