@@ -161,12 +161,12 @@ def __init__(
161161 self ._compiler_options .add_include_path (path )
162162
163163 # try to detect models w/out parameters, needed for sampler
164- if not cmdstan_version_before (2 , 27 ) and cmdstan_version_before (
165- 2 , 29
166- ):
164+ if not cmdstan_version_before (
165+ 2 , 27
166+ ): # unknown end of version range
167167 model_info = self .src_info ()
168168 if 'parameters' in model_info :
169- self ._fixed_param = len (model_info ['parameters' ]) == 0
169+ self ._fixed_param | = len (model_info ['parameters' ]) == 0
170170
171171 if exe_file is not None :
172172 self ._exe_file = os .path .realpath (os .path .expanduser (exe_file ))
@@ -275,19 +275,25 @@ def src_info(self) -> Dict[str, Any]:
275275 return result
276276 try :
277277 cmd = (
278- [os .path .join ('.' , 'bin' , 'stanc' + EXTENSION )]
278+ [os .path .join (cmdstan_path () , 'bin' , 'stanc' + EXTENSION )]
279279 # handle include-paths, allow-undefined etc
280280 + self ._compiler_options .compose_stanc ()
281281 + [
282282 '--info' ,
283283 self .stan_file ,
284284 ]
285285 )
286- sout = io .StringIO ()
287- do_command (cmd = cmd , cwd = cmdstan_path (), fd_out = sout )
288- result = json .loads (sout .getvalue ())
286+ proc = subprocess .run (
287+ cmd , capture_output = True , text = True , check = True
288+ )
289+ result = json .loads (proc .stdout )
289290 return result
290- except (ValueError , RuntimeError ) as e :
291+ except (
292+ ValueError ,
293+ RuntimeError ,
294+ OSError ,
295+ subprocess .CalledProcessError ,
296+ ) as e :
291297 get_logger ().debug (e )
292298 return result
293299
0 commit comments