From c4dbe7c982d00abf62e9a8927ecdef11521773a8 Mon Sep 17 00:00:00 2001
From: Norbert Preining <norbert@preining.info>
Date: Thu, 18 Jan 2024 03:01:29 +0000
Subject: CTAN sync 202401180301

---
 .../latex/contrib/pythonimmediate/pythonimmediate.sty  | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

(limited to 'macros/latex/contrib/pythonimmediate/pythonimmediate.sty')

diff --git a/macros/latex/contrib/pythonimmediate/pythonimmediate.sty b/macros/latex/contrib/pythonimmediate/pythonimmediate.sty
index 4556973831..1e632aba96 100644
--- a/macros/latex/contrib/pythonimmediate/pythonimmediate.sty
+++ b/macros/latex/contrib/pythonimmediate/pythonimmediate.sty
@@ -1,5 +1,5 @@
 % File: pythonimmediate.sty
-% Copyright 2022-2023 user202729
+% Copyright 2022-2024 user202729
 %
 % This work  may be  distributed and/or  modified under  the conditions  of the
 % LaTeX Project Public License (LPPL),  either version 1.3c  of this license or
@@ -12,9 +12,10 @@
 % 
 % The Current Maintainer of this work is user202729.
 
-\ProvidesExplPackage{pythonimmediate}{2023/03/07}{0.4.0}{Library to run Python code}
+\ProvidesExplPackage{pythonimmediate}{2024/01/18}{0.5.0}{Library to run Python code}
 
 \RequirePackage{saveenv}
+\PassOptionsToPackage{abspath}{currfile}  % try to enable abspath if possible (i.e. if package isn't loaded) but otherwise don't give option-clash error
 \RequirePackage{currfile}
 \RequirePackage{l3keys2e}
 \RequirePackage{precattl}
@@ -110,11 +111,14 @@
 
 \bool_if:NTF \_pythonimmediate_child_process {
 	\newwrite \_pythonimmediate_write_file
-	%\immediate\openout \_pythonimmediate_write_file=symlink-to-stderr.txt~
-	% tried this method, it seems to work except that it's buffered when stderr is redirected to a file...
-	\immediate\openout \_pythonimmediate_write_file=|"\_pythonimmediate_python_executable \space \_pythonimmediate_python_flags \space -m ~ pythonimmediate.copy_to_stderr"~
-
-
+	\sys_if_engine_luatex:TF {
+		% use Lua to write to stderr
+		\directlua{ (require "pythonimmediate_helper")() }
+	} {
+		%\immediate\openout \_pythonimmediate_write_file=symlink-to-stderr.txt~
+		% tried this method, it seems to work except that it's buffered when stderr is redirected to a file...
+		\immediate\openout \_pythonimmediate_write_file=|"\_pythonimmediate_python_executable \space \_pythonimmediate_python_flags \space -m ~ pythonimmediate.copy_to_stderr"~
+	}
 } {
 
 	\sys_if_engine_luatex:TF {
-- 
cgit v1.2.3

