From 2dc62b3a102a9cbb8bd2620433fc57043feec397 Mon Sep 17 00:00:00 2001 From: Alfredo Moralejo Date: Tue, 14 May 2019 15:35:15 +0200 Subject: [PATCH] Discover python executable when discover is not used Currently it's hardcoded to 'python' wich in some cases may not exist, as in some distros with python3 only. This patch uses PYTHON env variable if defined or executable used to run stestr. --- stestr/commands/run.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/stestr/commands/run.py b/stestr/commands/run.py index c2698907..8930c0e3 100644 --- a/stestr/commands/run.py +++ b/stestr/commands/run.py @@ -348,7 +348,15 @@ def run_command(config='.stestr.conf', repo_type='file', if ids.find('/') != -1: root = ids.replace('.py', '') ids = root.replace('/', '.') - run_cmd = 'python -m subunit.run ' + ids + stestr_python = sys.executable + if os.environ.get('PYTHON'): + python_bin = os.environ.get('PYTHON') + elif stestr_python: + python_bin = stestr_python + else: + raise RuntimeError("The Python interpreter was not found and " + "PYTHON is not set") + run_cmd = python_bin + ' -m subunit.run ' + ids def run_tests(): run_proc = [('subunit', output.ReturnCodeToSubunit(