MCPcopy Index your code
hub / github.com/modelscope/modelscope / _check_plugin_installed

Method _check_plugin_installed

modelscope/utils/plugins.py:808–835  ·  view source on GitHub ↗
(package, verified_version=None)

Source from the content-addressed store, hash-verified

806
807 @staticmethod
808 def _check_plugin_installed(package, verified_version=None):
809 from packaging.requirements import Requirement
810 req = Requirement(package)
811
812 try:
813 # Ensure newly installed packages are discoverable
814 importlib.invalidate_caches()
815 dist = importlib.metadata.distribution(req.name)
816 version = dist.version
817
818 # To test if the package is installed
819 installed = True
820
821 # If installed, test if the version is correct
822 for spec in req.specifier:
823 installed_valid_version = spec.contains(version)
824 if not installed_valid_version:
825 installed = False
826 break
827
828 except importlib.metadata.PackageNotFoundError:
829 version = ''
830 installed = False
831
832 if installed and verified_version is not None and verified_version != version:
833 return False, verified_version
834 else:
835 return installed, version
836
837 @staticmethod
838 def pip_command(

Callers 1

Calls 1

containsMethod · 0.80

Tested by

no test coverage detected