install module from requirements Args: requirement_path: The path of requirement file No returns, raise error if failed
(requirement_path, )
| 296 | |
| 297 | |
| 298 | def 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 | |
| 326 | def import_module_from_file(module_name, file_path): |
no test coverage detected
searching dependent graphs…