Skip to content

Commit c89eed6

Browse files
authored
Enable running with alternative python, inside venv (#81)
1 parent 3213c2b commit c89eed6

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

pyperformance/cli.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,13 +167,13 @@ def parse_args():
167167
if hasattr(options, 'python'):
168168
# Replace "~" with the user home directory
169169
options.python = os.path.expanduser(options.python)
170-
# Try to the absolute path to the binary
171-
abs_python = shutil.which(options.python)
170+
# Try to get the absolute path to the binary
171+
abs_python = os.path.abspath(options.python)
172172
if not abs_python:
173173
print("ERROR: Unable to locate the Python executable: %r" %
174174
options.python)
175175
sys.exit(1)
176-
options.python = os.path.realpath(abs_python)
176+
options.python = abs_python
177177

178178
return (parser, options)
179179

pyperformance/cli_run.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,15 @@ def cmd_run(parser, options):
2626
print("ERROR: the output file %s already exists!" % options.output)
2727
sys.exit(1)
2828

29-
if not os.path.isabs(sys.executable):
30-
print("ERROR: sys.executable is not an absolute path")
29+
if hasattr(options, 'python'):
30+
executable = options.python
31+
else:
32+
executable = sys.executable
33+
if not os.path.isabs(executable):
34+
print("ERROR: \"%s\" is not an absolute path" % executable)
3135
sys.exit(1)
3236
bench_funcs, bench_groups, should_run = get_benchmarks_to_run(options)
33-
cmd_prefix = [sys.executable]
37+
cmd_prefix = [executable]
3438
suite, errors = run_benchmarks(bench_funcs, should_run, cmd_prefix, options)
3539

3640
if not suite:

0 commit comments

Comments
 (0)