From 4a0029a0f7999acedd286da57893396d9e947b7c Mon Sep 17 00:00:00 2001 From: Adrian Gao Date: Sat, 6 Aug 2022 12:31:38 +1000 Subject: [PATCH] Add ability to pass extra kwargs to subprocess --- pylatex/document.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/pylatex/document.py b/pylatex/document.py index 47d4c73f..cb83a039 100644 --- a/pylatex/document.py +++ b/pylatex/document.py @@ -178,7 +178,8 @@ def generate_tex(self, filepath=None): super().generate_tex(self._select_filepath(filepath)) def generate_pdf(self, filepath=None, *, clean=True, clean_tex=True, - compiler=None, compiler_args=None, silent=True): + compiler=None, compiler_args=None, silent=True, + check_output_kwargs=None): """Generate a pdf file from the document. Args @@ -200,6 +201,10 @@ def generate_pdf(self, filepath=None, *, clean=True, clean_tex=True, this is None it defaults to an empty list. silent: bool Whether to hide compiler output + check_output_kwargs: `dict` or `None` + Extra keyword arguments that should be passed to the subprocess + that runs the LaTeX compiler. If this is None it defaults to an + empty dictionary. """ if compiler_args is None: @@ -237,9 +242,10 @@ def generate_pdf(self, filepath=None, *, clean=True, clean_tex=True, main_arguments = ['--interaction=nonstopmode', filepath + '.tex'] - check_output_kwargs = {} + if check_output_kwargs is None: + check_output_kwargs = {} if python_cwd_available: - check_output_kwargs = {'cwd': dest_dir} + check_output_kwargs.update({'cwd': dest_dir}) os_error = None