Force test use bash for setupvars.sh (#4321)
setupvars.sh is incomatible with sh shell.
This commit is contained in:
parent
01aaaf1138
commit
4f79d9ccfc
@ -4,13 +4,32 @@
|
|||||||
|
|
||||||
""" Common utilities for OpenVINO install package.
|
""" Common utilities for OpenVINO install package.
|
||||||
"""
|
"""
|
||||||
import sys
|
import errno
|
||||||
|
import os
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from proc_utils import get_env_from # pylint: disable=import-error
|
import subprocess
|
||||||
|
import sys
|
||||||
|
|
||||||
|
|
||||||
def get_openvino_environment(install_prefix: Path):
|
def get_openvino_environment(install_prefix: Path):
|
||||||
""" Get OpenVINO environment variables
|
""" Get OpenVINO environment variables
|
||||||
"""
|
"""
|
||||||
script = "setupvars.bat" if sys.platform == "win32" else "setupvars.sh"
|
if sys.platform == "win32":
|
||||||
return get_env_from(install_prefix / "bin" / script)
|
script = install_prefix / "bin" / "setupvars.bat"
|
||||||
|
cmd = f"{script} && set"
|
||||||
|
else:
|
||||||
|
script = install_prefix / "bin" / "setupvars.sh"
|
||||||
|
# setupvars.sh is not compatible with /bin/sh. Using bash.
|
||||||
|
cmd = f'bash -c ". {script} && env"'
|
||||||
|
|
||||||
|
if not os.path.exists(str(script)):
|
||||||
|
raise FileNotFoundError(errno.ENOENT, os.strerror(errno.ENOENT), str(script))
|
||||||
|
|
||||||
|
env = {}
|
||||||
|
dump = subprocess.check_output(cmd, shell=True, universal_newlines=True).strip()
|
||||||
|
for line in dump.split("\n"):
|
||||||
|
# split by first '='
|
||||||
|
pair = [str(val).strip() for val in line.split("=", 1)]
|
||||||
|
if len(pair) > 1 and pair[0]: # ignore invalid entries
|
||||||
|
env[pair[0]] = pair[1]
|
||||||
|
return env
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
# Copyright (C) 2021 Intel Corporation
|
# Copyright (C) 2021 Intel Corporation
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
""" Common utilities for working with processes.
|
""" Common utilities for working with paths
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
@ -5,30 +5,8 @@
|
|||||||
""" Common utilities for working with processes.
|
""" Common utilities for working with processes.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import errno
|
|
||||||
import os
|
|
||||||
import logging
|
import logging
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
|
||||||
|
|
||||||
|
|
||||||
def get_env_from(script):
|
|
||||||
""" Get environment set by a shell script
|
|
||||||
"""
|
|
||||||
if not os.path.exists(str(script)):
|
|
||||||
raise FileNotFoundError(errno.ENOENT, os.strerror(errno.ENOENT), str(script))
|
|
||||||
env = {}
|
|
||||||
if sys.platform == "win32":
|
|
||||||
cmd = f'"{script}" && set'
|
|
||||||
else:
|
|
||||||
cmd = f'. "{script}" && env'
|
|
||||||
dump = subprocess.check_output(cmd, shell=True, universal_newlines=True).strip()
|
|
||||||
for line in dump.split("\n"):
|
|
||||||
# split by first '='
|
|
||||||
pair = [str(val).strip() for val in line.split("=", 1)]
|
|
||||||
if len(pair) > 1 and pair[0]: # ignore invalid entries
|
|
||||||
env[pair[0]] = pair[1]
|
|
||||||
return env
|
|
||||||
|
|
||||||
|
|
||||||
def cmd_exec(args, env=None, log=None, verbose=True):
|
def cmd_exec(args, env=None, log=None, verbose=True):
|
||||||
|
Loading…
Reference in New Issue
Block a user