@@ -122,23 +122,13 @@ def run(self, cwd, args):
122
122
return ret_code , out .data
123
123
124
124
125
- class CPythonVm (AbstractPythonVm ):
126
- PYTHON_INTERPRETER = "python3"
125
+ class AbstractPythonNoWarmupVm (AbstractPythonVm ):
126
+ __metaclass__ = ABCMeta
127
127
128
- def __init__ (self , config_name , options = None , virtualenv = None , no_warmup = False ):
129
- super (CPythonVm , self ).__init__ (config_name , options )
130
- self ._virtualenv = virtualenv
128
+ def __init__ (self , config_name , options = None , no_warmup = False ):
129
+ super (AbstractPythonNoWarmupVm , self ).__init__ (config_name , options )
131
130
self ._no_warmup = no_warmup
132
131
133
- @property
134
- def interpreter (self ):
135
- if self ._virtualenv :
136
- return os .path .join (self ._virtualenv , CPythonVm .PYTHON_INTERPRETER )
137
- return CPythonVm .PYTHON_INTERPRETER
138
-
139
- def name (self ):
140
- return VM_NAME_CPYTHON
141
-
142
132
@staticmethod
143
133
def remove_warmup_runs (args ):
144
134
_args = []
@@ -154,20 +144,39 @@ def remove_warmup_runs(args):
154
144
155
145
def run (self , cwd , args ):
156
146
if self ._no_warmup :
157
- args = CPythonVm .remove_warmup_runs (args )
158
- return super (CPythonVm , self ).run (cwd , args )
147
+ args = AbstractPythonNoWarmupVm .remove_warmup_runs (args )
148
+ return super (AbstractPythonNoWarmupVm , self ).run (cwd , args )
159
149
160
150
161
- class PyPyVm (AbstractPythonVm ):
162
- def __init__ (self , config_name , options = None ):
163
- super (PyPyVm , self ).__init__ (config_name , options = options )
151
+ class CPythonVm (AbstractPythonNoWarmupVm ):
152
+ PYTHON_INTERPRETER = "python3"
153
+
154
+ def __init__ (self , config_name , options = None , virtualenv = None , no_warmup = False ):
155
+ super (CPythonVm , self ).__init__ (config_name , options = options , no_warmup = no_warmup )
156
+ self ._virtualenv = virtualenv
157
+
158
+ @property
159
+ def interpreter (self ):
160
+ if self ._virtualenv :
161
+ return os .path .join (self ._virtualenv , CPythonVm .PYTHON_INTERPRETER )
162
+ return CPythonVm .PYTHON_INTERPRETER
163
+
164
+ def name (self ):
165
+ return VM_NAME_CPYTHON
166
+
167
+
168
+ class PyPyVm (AbstractPythonNoWarmupVm ):
169
+ PYPY_INTERPRETER = "pypy3"
170
+
171
+ def __init__ (self , config_name , options = None , no_warmup = False ):
172
+ super (PyPyVm , self ).__init__ (config_name , options = options , no_warmup = no_warmup )
164
173
165
174
@property
166
175
def interpreter (self ):
167
176
home = mx .get_env (ENV_PYPY_HOME )
168
177
if not home :
169
178
mx .abort ("{} is not set!" .format (ENV_PYPY_HOME ))
170
- return join (home , 'bin' , 'pypy3' )
179
+ return join (home , 'bin' , PyPyVm . PYPY_INTERPRETER )
171
180
172
181
def name (self ):
173
182
return VM_NAME_PYPY
0 commit comments