diff --git a/pyperformance/cli.py b/pyperformance/cli.py index dbfe4645..8c7ca310 100644 --- a/pyperformance/cli.py +++ b/pyperformance/cli.py @@ -167,13 +167,13 @@ def parse_args(): if hasattr(options, 'python'): # Replace "~" with the user home directory options.python = os.path.expanduser(options.python) - # Try to the absolute path to the binary - abs_python = shutil.which(options.python) + # Try to get the absolute path to the binary + abs_python = os.path.abspath(options.python) if not abs_python: print("ERROR: Unable to locate the Python executable: %r" % options.python) sys.exit(1) - options.python = os.path.realpath(abs_python) + options.python = abs_python return (parser, options) diff --git a/pyperformance/cli_run.py b/pyperformance/cli_run.py index c5009e28..a760c877 100644 --- a/pyperformance/cli_run.py +++ b/pyperformance/cli_run.py @@ -26,11 +26,15 @@ def cmd_run(parser, options): print("ERROR: the output file %s already exists!" % options.output) sys.exit(1) - if not os.path.isabs(sys.executable): - print("ERROR: sys.executable is not an absolute path") + if hasattr(options, 'python'): + executable = options.python + else: + executable = sys.executable + if not os.path.isabs(executable): + print("ERROR: \"%s\" is not an absolute path" % executable) sys.exit(1) bench_funcs, bench_groups, should_run = get_benchmarks_to_run(options) - cmd_prefix = [sys.executable] + cmd_prefix = [executable] suite, errors = run_benchmarks(bench_funcs, should_run, cmd_prefix, options) if not suite: