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

Function install_module_from_requirements

modelscope/utils/plugins.py:298–323  ·  view source on GitHub ↗

install module from requirements Args: requirement_path: The path of requirement file No returns, raise error if failed

(requirement_path, )

Source from the content-addressed store, hash-verified

296
297
298def install_module_from_requirements(requirement_path, ):
299 """ install module from requirements
300 Args:
301 requirement_path: The path of requirement file
302
303 No returns, raise error if failed
304 """
305
306 install_list = []
307 with open(requirement_path, 'r', encoding='utf-8') as f:
308 requirements = f.read().splitlines()
309 for req in requirements:
310 if req == '':
311 continue
312 installed, _ = PluginsManager.check_plugin_installed(req)
313 if not installed:
314 install_list.append(req)
315
316 if len(install_list) > 0:
317 status_code, _, args = PluginsManager.pip_command(
318 'install',
319 install_list,
320 )
321 if status_code != 0:
322 raise ImportError(
323 f'Failed to install requirements from {requirement_path}')
324
325
326def import_module_from_file(module_name, file_path):

Callers 1

Calls 4

pip_commandMethod · 0.80
readMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…