@@ -199,9 +199,9 @@ def run_report(self, output_dir: str = BASE_DIR) -> None:
199199 raise
200200 else :
201201 quarto_path = Path (sys ._MEIPASS ) / "quarto_cli" / "bin" / "quarto"
202- if sys . platform == "win32" :
203- # ! to check
204- quarto_path = self . quarto_path . with_suffix ( ".exe " )
202+ _sys_exe = sys . executable
203+ # set executable to the bundled python (manually added to bundle)
204+ sys . executable = str ( Path ( sys . _MEIPASS ) / "python " )
205205 self .report .logger .info (f"quarto_path: { quarto_path } " )
206206
207207 args = [f"{ quarto_path } " , "convert" , file_path_to_qmd ]
@@ -213,13 +213,25 @@ def run_report(self, output_dir: str = BASE_DIR) -> None:
213213 f"Converted '{ self .report .title } ' '{ self .report_type } ' report to Jupyter Notebook after execution"
214214 )
215215 notebook_filename = Path (file_path_to_qmd ).with_suffix (".ipynb" )
216- # ipynb will not be executed per default
217- # ! check if execution works although qmd cannot be executed...
216+ # quarto does not try to execute ipynb files, just render them
217+ # execute manually using bundled python binary
218+ # https://nbconvert.readthedocs.io/en/latest/execute_api.html
219+ import nbformat
220+ from nbconvert .preprocessors import ExecutePreprocessor
221+
222+ with open (notebook_filename , encoding = "utf-8" ) as f :
223+ nb = nbformat .read (f , as_version = 4 )
224+ ep = ExecutePreprocessor (timeout = 600 , kernel_name = "python3" )
225+ nb , _ = ep .preprocess (nb , {"metadata" : {"path" : "./" }})
226+ with open (notebook_filename , "w" , encoding = "utf-8" ) as f :
227+ nbformat .write (nb , f )
228+ # quarto does not try execute ipynb files per default, just render these
218229 args = [f"{ quarto_path } " , "render" , notebook_filename ]
219230 subprocess .run (
220231 args ,
221232 check = True ,
222233 )
234+ sys .executable = _sys_exe
223235
224236 def _create_yaml_header (self ) -> str :
225237 """
0 commit comments