in modular_api/services/install_service.py [0:0]
def install_module_with_destination_folder(paths_to_module: str):
"""
Installing module by path
:param paths_to_module: path to the modules
:return: stdout, stderror of the installation process
"""
if not paths_to_module:
message = f"Path not found: {paths_to_module}"
_LOG.error(message)
sys.exit(message)
if os.path.isfile(paths_to_module):
message = f'The path {[paths_to_module]} to the module is file. ' \
f'Please specify the path to folder of the module which ' \
f'consist of setup.py.'
_LOG.error(message)
sys.exit(message)
_LOG.info(f"Going to execute pip install command for {paths_to_module}")
os_name = os.name
command = f'pip install -e {paths_to_module}'
if os_name == WINDOWS:
with subprocess.Popen(
command,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
) as terminal_process:
stdout, stderr = terminal_process.communicate()
elif os_name == LINUX:
with subprocess.Popen(
shlex.split(command),
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
) as terminal_process:
stdout, stderr = terminal_process.communicate()
else:
message = f'The {os_name} OS is not supported by tool.'
_LOG.error(message)
sys.exit(message)
if stdout is not None:
stdout = stdout.decode('utf-8')
_LOG.info(f"Out: {stdout}")
if stderr is not None:
stderr = stderr.decode('utf-8')
_LOG.error(f"Errors: {stderr}")
_LOG.info('Installation completed with errors')
sys.exit(stderr)