From 01b69c78ff33854f7f28149e8167cb4219fcb416 Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Mon, 14 Feb 2022 03:01:43 +0000 Subject: CTAN sync 202202140301 --- macros/luatex/latex/pyluatex/pyluatex.lua | 26 ++++++++++++++++++-------- macros/luatex/latex/pyluatex/pyluatex.pdf | Bin 84163 -> 84169 bytes macros/luatex/latex/pyluatex/pyluatex.sty | 2 +- macros/luatex/latex/pyluatex/pyluatex.tex | 4 ++-- 4 files changed, 21 insertions(+), 11 deletions(-) (limited to 'macros/luatex/latex/pyluatex') diff --git a/macros/luatex/latex/pyluatex/pyluatex.lua b/macros/luatex/latex/pyluatex/pyluatex.lua index f95ab989c0..f9d8ff68a6 100644 --- a/macros/luatex/latex/pyluatex/pyluatex.lua +++ b/macros/luatex/latex/pyluatex/pyluatex.lua @@ -33,7 +33,6 @@ pyluatex = pyluatex or { -- status.filename: path to pyluatex.sty local folder = file.pathpart(file.collapsepath(status.filename, true)) -local script = file.join(folder, "pyluatex-interpreter.py") local tcp = nil local env_end = nil @@ -53,6 +52,7 @@ local function err_cmd(message) end function pyluatex.start(executable) + local script = file.join(folder, "pyluatex-interpreter.py") local is_windows = package.config:sub(1,1) ~= "/" local cmd if is_windows then @@ -61,15 +61,25 @@ function pyluatex.start(executable) cmd = executable .. " \"" .. script .. "\" &" end local f = io.popen(cmd, "r") - local port = f:read("*l"):gsub("\r", ""):gsub("\n", "") + local port = f:read("*l") f:close() - if port then - tcp = socket.tcp() - tcp:connect("127.0.0.1", port) - else - tex.sprint(err_cmd("Python backend (executable: " .. executable .. - ") could not be started")) + function err(message) + tex.sprint(err_cmd("Python backend could not be started (" .. message .. ")")) + end + + if port == nil then + err("executable: " .. executable) + return + end + port = trim(port) + if port:match("^%d+$") == nil then + err("invalid TCP port: " .. port) + return + end + tcp = socket.tcp() + if tcp:connect("127.0.0.1", port) == nil then + err("TCP connection failed") end end diff --git a/macros/luatex/latex/pyluatex/pyluatex.pdf b/macros/luatex/latex/pyluatex/pyluatex.pdf index 23699dd22b..173c053483 100644 Binary files a/macros/luatex/latex/pyluatex/pyluatex.pdf and b/macros/luatex/latex/pyluatex/pyluatex.pdf differ diff --git a/macros/luatex/latex/pyluatex/pyluatex.sty b/macros/luatex/latex/pyluatex/pyluatex.sty index cf67916d19..6c247993a9 100644 --- a/macros/luatex/latex/pyluatex/pyluatex.sty +++ b/macros/luatex/latex/pyluatex/pyluatex.sty @@ -9,7 +9,7 @@ %% version 2005/12/01 or later. \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{pyluatex}[2022/02/04 v0.4.1 Execute Python code on the fly] +\ProvidesPackage{pyluatex}[2022/02/13 v0.4.2 Execute Python code on the fly] \RequirePackage{expl3} \ExplSyntaxOn diff --git a/macros/luatex/latex/pyluatex/pyluatex.tex b/macros/luatex/latex/pyluatex/pyluatex.tex index 594d1c0e90..7446313863 100644 --- a/macros/luatex/latex/pyluatex/pyluatex.tex +++ b/macros/luatex/latex/pyluatex/pyluatex.tex @@ -15,7 +15,7 @@ \usepackage{url} \title{The \emph{pyluatex} package} \author{Tobias Enderle\\\url{https://github.com/tndrle/PyLuaTeX}} -\date{v0.4.1 (2022/02/04)} +\date{v0.4.2 (2022/02/13)} \begin{document} \maketitle \raggedright @@ -143,7 +143,7 @@ For an example, see the Typesetting Code section. 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}| + \textit{Example:} \inlcode|\usepackage[shutdown=veryenddocument]{pyluatex}| \end{itemize} 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}|. -- cgit v1.2.3