Add proper virtualenv support to run_checks.py

This commit is contained in:
Florian Bruhin 2015-01-19 23:50:01 +01:00
parent 18443a6880
commit 6a7e454789

View File

@ -91,10 +91,15 @@ def run(name, target=None, print_version=False):
if target is not None:
args.append(target)
with _adjusted_pythonpath(name):
# for virtualenvs
executable = os.path.join(os.path.dirname(sys.executable), name)
if not os.path.exists(executable):
# in $PATH
executable = name
if print_version:
subprocess.call([name, '--version'])
subprocess.call([executable, '--version'])
try:
status = subprocess.call([name] + args)
status = subprocess.call([executable] + args)
except OSError:
traceback.print_exc()
status = None