texlive[61901] Master/texmf-dist: pyluatex (5feb22)

commits+karl at tug.org commits+karl at tug.org
Sat Feb 5 22:24:25 CET 2022


Revision: 61901
          http://tug.org/svn/texlive?view=revision&revision=61901
Author:   karl
Date:     2022-02-05 22:24:24 +0100 (Sat, 05 Feb 2022)
Log Message:
-----------
pyluatex (5feb22)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/lualatex/pyluatex/README.md
    trunk/Master/texmf-dist/doc/lualatex/pyluatex/pyluatex.pdf
    trunk/Master/texmf-dist/doc/lualatex/pyluatex/pyluatex.tex
    trunk/Master/texmf-dist/tex/lualatex/pyluatex/pyluatex-interpreter.py
    trunk/Master/texmf-dist/tex/lualatex/pyluatex/pyluatex.lua
    trunk/Master/texmf-dist/tex/lualatex/pyluatex/pyluatex.sty

Modified: trunk/Master/texmf-dist/doc/lualatex/pyluatex/README.md
===================================================================
--- trunk/Master/texmf-dist/doc/lualatex/pyluatex/README.md	2022-02-05 21:24:11 UTC (rev 61900)
+++ trunk/Master/texmf-dist/doc/lualatex/pyluatex/README.md	2022-02-05 21:24:24 UTC (rev 61901)
@@ -50,7 +50,7 @@
 * Linux, macOS or Windows
 
 Our automated tests currently use TeX Live 2021 and Python 3.7+ on
-Ubuntu 20.04, macOS Catalina 10.15 and Windows Server 2019.
+Ubuntu 20.04, macOS Big Sur 11 and Windows Server 2019.
 
 ## License
 [LPPL 1.3c](http://www.latex-project.org/lppl.txt) for LaTeX code and

Modified: trunk/Master/texmf-dist/doc/lualatex/pyluatex/pyluatex.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/lualatex/pyluatex/pyluatex.tex
===================================================================
--- trunk/Master/texmf-dist/doc/lualatex/pyluatex/pyluatex.tex	2022-02-05 21:24:11 UTC (rev 61900)
+++ trunk/Master/texmf-dist/doc/lualatex/pyluatex/pyluatex.tex	2022-02-05 21:24:24 UTC (rev 61901)
@@ -15,7 +15,7 @@
 \usepackage{url}
 \title{The \emph{pyluatex} package}
 \author{Tobias Enderle\\\url{https://github.com/tndrle/PyLuaTeX}}
-\date{v0.4.0 (2021/11/05)}
+\date{v0.4.1 (2022/02/04)}
 \begin{document}
 \maketitle
 \raggedright
@@ -139,8 +139,13 @@
   By default, PyLuaTeX aborts the compilation process when Python reports an error.
   If the \inlcode|ignoreerrors| option is set, the compilation process is not aborted.\\[0.5ex]
   \textit{Example:} \inlcode|\usepackage[ignoreerrors]{pyluatex}|
+\item \inlcode|shutdown|\\[0.5ex]
+  Specifies when the Python process is shut down. (default: \inlcode|veryveryend|)\\[0.5ex]
+  \textit{Options:} \inlcode|veryveryend|, \inlcode|veryenddocument|, \inlcode|off|\\[0.5ex]
+  PyLuaTeX uses the hooks of the package \textit{atveryend} to shut down the Python interpreter when the compilation is done. With the option \inlcode|veryveryend|, Python is shut down in the \inlcode|\AtVeryVeryEnd| hook. With the option \inlcode|veryenddocument|, Python is shut down in the \inlcode|\AtVeryEndDocument| hook. With the option \inlcode|off|, Python is not shut down explicitly. However, the Python process will shut down when the LuaTeX process finishes even if \inlcode|off| is selected. Using \inlcode|off| on Windows might lead to problems with SyncTeX, though.\\[0.5ex]
+  \textit{Example:} \inlcode|\usepackage[veryenddocument]{pyluatex}|
 \end{itemize}
-Package options (except for \inlcode|executable|) can be changed in the document with the
+Package options (except for \inlcode|executable| and \inlcode|shutdown|) can be changed in the document with the
 \inlcode|\pyoption| command, e.g. \inlcode|\pyoption{verbose}{true}| or \inlcode|\pyoption{ignoreerrors}{false}|.
 
 \subsection{Macros}
@@ -212,7 +217,7 @@
 \item Linux, macOS or Windows
 \end{itemize}
 Our automated tests currently use TeX Live 2021 and Python 3.7+ on
-Ubuntu 20.04, macOS Catalina 10.15 and Windows Server 2019.
+Ubuntu 20.04, macOS Big Sur 11 and Windows Server 2019.
 
 \section{Typesetting Code}
 Sometimes, in addition to having Python code executed and the output written to your document, you also want to show the code itself in your document.

Modified: trunk/Master/texmf-dist/tex/lualatex/pyluatex/pyluatex-interpreter.py
===================================================================
--- trunk/Master/texmf-dist/tex/lualatex/pyluatex/pyluatex-interpreter.py	2022-02-05 21:24:11 UTC (rev 61900)
+++ trunk/Master/texmf-dist/tex/lualatex/pyluatex/pyluatex-interpreter.py	2022-02-05 21:24:24 UTC (rev 61901)
@@ -1,7 +1,7 @@
 """
 MIT License
 
-Copyright (c) 2021 Tobias Enderle
+Copyright (c) 2021-2022 Tobias Enderle
 
 Permission is hereby granted, free of charge, to any person obtaining a
 copy of this software and associated documentation files (the "Software"),
@@ -84,10 +84,13 @@
         interpreters = defaultdict(Interpreter)
         while True:
             data = self.rfile.readline().decode('utf-8')
-            if len(data) == 0:
+            if len(data) == 0:  # socket closed, LuaTeX process finished
                 return
 
             data = json.loads(data)
+            if data == 'shutdown':
+                return
+
             interpreter = interpreters[data['session']]
             code = textwrap.dedent(data['code'])
             if data['repl_mode']:

Modified: trunk/Master/texmf-dist/tex/lualatex/pyluatex/pyluatex.lua
===================================================================
--- trunk/Master/texmf-dist/tex/lualatex/pyluatex/pyluatex.lua	2022-02-05 21:24:11 UTC (rev 61900)
+++ trunk/Master/texmf-dist/tex/lualatex/pyluatex/pyluatex.lua	2022-02-05 21:24:24 UTC (rev 61901)
@@ -1,7 +1,7 @@
 --[[
 MIT License
 
-Copyright (c) 2021 Tobias Enderle
+Copyright (c) 2021-2022 Tobias Enderle
 
 Permission is hereby granted, free of charge, to any person obtaining a
 copy of this software and associated documentation files (the "Software"),
@@ -73,6 +73,10 @@
     end
 end
 
+function pyluatex.shutdown()
+    tcp:send(json.encode("shutdown") .. "\n")
+end
+
 local function request(data)
     tcp:send(json.encode(data) .. "\n")
     local output = tcp:receive("*l")

Modified: trunk/Master/texmf-dist/tex/lualatex/pyluatex/pyluatex.sty
===================================================================
--- trunk/Master/texmf-dist/tex/lualatex/pyluatex/pyluatex.sty	2022-02-05 21:24:11 UTC (rev 61900)
+++ trunk/Master/texmf-dist/tex/lualatex/pyluatex/pyluatex.sty	2022-02-05 21:24:24 UTC (rev 61901)
@@ -1,4 +1,4 @@
-%% Copyright 2021 Tobias Enderle
+%% Copyright 2021-2022 Tobias Enderle
 %%
 %% This work may be distributed and/or modified under the
 %% conditions of the LaTeX Project Public License, either version 1.3
@@ -9,15 +9,15 @@
 %% version 2005/12/01 or later.
 
 \NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{pyluatex}[2021/11/05 v0.4.0 Execute Python code on the fly]
+\ProvidesPackage{pyluatex}[2022/02/04 v0.4.1 Execute Python code on the fly]
 
 \RequirePackage{expl3}
 \ExplSyntaxOn
 \sys_if_engine_luatex:TF{}{%
-\PackageError{PyLuaTeX}{LuaTeX~is~required}{}%
+    \PackageError{PyLuaTeX}{LuaTeX~is~required}{}%
 }
 \sys_if_shell_unrestricted:TF{}{%
-\PackageError{PyLuaTeX}{Shell~escape~required~(add~-shell-escape~option)}{}%
+    \PackageError{PyLuaTeX}{Shell~escape~required~(add~-shell-escape~option)}{}%
 }
 \ExplSyntaxOff
 
@@ -27,6 +27,7 @@
 \DeclareStringOption[python3]{executable}
 \DeclareBoolOption{ignoreerrors}
 \DeclareBoolOption{verbose}
+\DeclareStringOption[veryveryend]{shutdown}
 \ProcessKeyvalOptions*
 
 \ifpyluatex at ignoreerrors
@@ -41,6 +42,25 @@
 \fi
 \directlua{pyluatex.start([==[\pyluatex at executable]==])}
 
+\ExplSyntaxOn
+\cs_generate_variant:Nn \tl_if_eq:nnTF { V }
+\tl_if_eq:VnTF{\pyluatex at shutdown}{veryveryend}{%
+    \RequirePackage{atveryend}
+    \AtVeryVeryEnd{\directlua{pyluatex.shutdown()}}
+}{%
+    \tl_if_eq:VnTF{\pyluatex at shutdown}{veryenddocument}{%
+        \RequirePackage{atveryend}
+        \AtVeryEndDocument{\directlua{pyluatex.shutdown()}}
+    }{%
+        \tl_if_eq:VnTF{\pyluatex at shutdown}{off}{}{%
+            \PackageError{PyLuaTeX}{%
+                Invalid~value~for~package~option~"shutdown":~\pyluatex at shutdown
+            }{}%
+        }
+    }
+}
+\ExplSyntaxOff
+
 \newcommand*{\PyLTVerbatimEnv}{\directlua{pyluatex.set_parent_env([==[\@currenvir]==])}}
 
 \newenvironment{python}{\directlua{pyluatex.record_env("python", false)}}%



More information about the tex-live-commits mailing list.