Skip to content

Commit fa96845

Browse files
committed
[hotfix] add support for running a cpython vm from a virtual environment
PullRequest: graalpython/242
2 parents 975e928 + 08f4706 commit fa96845

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

mx.graalpython/mx_graalpython_benchmark.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,16 +116,24 @@ def interpreter(self):
116116

117117
def run(self, cwd, args):
118118
_check_vm_args(self.name(), args)
119-
stdout_capture = mx.TeeOutputCapture(mx.OutputCapture())
119+
out = mx.OutputCapture()
120+
stdout_capture = mx.TeeOutputCapture(out)
120121
ret_code = mx.run([self.interpreter] + args, out=stdout_capture, err=stdout_capture)
121-
print(stdout_capture.data)
122-
return ret_code, stdout_capture.data
122+
return ret_code, out.data
123123

124124

125125
class CPythonVm(AbstractPythonVm):
126+
PYTHON_INTERPRETER = "python3"
127+
128+
def __init__(self, config_name, options=None, virtualenv=None):
129+
super(CPythonVm, self).__init__(config_name, options)
130+
self._virtualenv = virtualenv
131+
126132
@property
127133
def interpreter(self):
128-
return "python3"
134+
if self._virtualenv:
135+
return os.path.join(self._virtualenv, CPythonVm.PYTHON_INTERPRETER)
136+
return CPythonVm.PYTHON_INTERPRETER
129137

130138
def name(self):
131139
return VM_NAME_CPYTHON

0 commit comments

Comments
 (0)