File tree Expand file tree Collapse file tree 2 files changed +12
-12
lines changed
Expand file tree Collapse file tree 2 files changed +12
-12
lines changed Original file line number Diff line number Diff line change @@ -352,6 +352,18 @@ def compile_stan_file(
352352 )
353353 compiler_options .validate ()
354354
355+ # if program has include directives, record path
356+ if '#include' in src .read_text ():
357+ path = os .fspath (src .parent .resolve ())
358+ if 'include-paths' not in compiler_options .stanc_options :
359+ compiler_options .stanc_options ['include-paths' ] = [path ]
360+ else :
361+ paths : list [str ] = compiler_options .stanc_options [
362+ 'include-paths'
363+ ] # type: ignore
364+ if path not in paths :
365+ paths .append (path )
366+
355367 exe_target = src .with_suffix (EXTENSION )
356368 if exe_target .exists ():
357369 exe_time = os .path .getmtime (exe_target )
Original file line number Diff line number Diff line change @@ -168,18 +168,6 @@ def __init__(
168168 ' found: {}.' .format (self ._name , filename )
169169 )
170170
171- # if program has include directives, record path
172- with open (self ._stan_file , 'r' ) as fd :
173- program = fd .read ()
174- if '#include' in program :
175- path , _ = os .path .split (
176- os .path .abspath (os .path .expanduser (self ._stan_file ))
177- )
178- if 'include-paths' not in self ._stanc_options :
179- self ._stanc_options ['include-paths' ] = [path ]
180- elif path not in self ._stanc_options ['include-paths' ]:
181- self ._stanc_options ['include-paths' ].append (path )
182-
183171 self ._exe_file = compilation .compile_stan_file (
184172 str (self .stan_file ),
185173 force = force_compile ,
You can’t perform that action at this time.
0 commit comments