texlive[59953] Master/texmf-dist: pyluatex (16jul21)

commits+karl at tug.org commits+karl at tug.org
Fri Jul 16 21:57:47 CEST 2021


Revision: 59953
          http://tug.org/svn/texlive?view=revision&revision=59953
Author:   karl
Date:     2021-07-16 21:57:46 +0200 (Fri, 16 Jul 2021)
Log Message:
-----------
pyluatex (16jul21)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/lualatex/pyluatex/README.md
    trunk/Master/texmf-dist/doc/lualatex/pyluatex/pyluatex.lua
    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.sty

Modified: trunk/Master/texmf-dist/doc/lualatex/pyluatex/README.md
===================================================================
--- trunk/Master/texmf-dist/doc/lualatex/pyluatex/README.md	2021-07-16 19:57:34 UTC (rev 59952)
+++ trunk/Master/texmf-dist/doc/lualatex/pyluatex/README.md	2021-07-16 19:57:46 UTC (rev 59953)
@@ -54,3 +54,7 @@
 We use the great [json.lua](https://github.com/rxi/json.lua) library under the terms
 of the [MIT license](https://opensource.org/licenses/MIT).
 
+## Further Information
+Author: Tobias Enderle
+
+Development: https://github.com/tndrle/PyLuaTeX

Modified: trunk/Master/texmf-dist/doc/lualatex/pyluatex/pyluatex.lua
===================================================================
--- trunk/Master/texmf-dist/doc/lualatex/pyluatex/pyluatex.lua	2021-07-16 19:57:34 UTC (rev 59952)
+++ trunk/Master/texmf-dist/doc/lualatex/pyluatex/pyluatex.lua	2021-07-16 19:57:46 UTC (rev 59953)
@@ -36,6 +36,7 @@
 local tcp = nil
 
 local python_lines = {}
+local python_output = nil
 
 local env_end = "\\end{python}"
 
@@ -71,28 +72,34 @@
     return response.success, response.output
 end
 
-local function print_input(code)
+local function log_input(code)
     texio.write_nl("PyLuaTeX input for session \"" .. pyluatex.session .. "\": " .. code)
 end
 
-local function print_output(code)
+local function log_output(code)
     texio.write_nl("PyLuaTeX output: " .. code)
 end
 
+local function print_lines(str)
+    for s in str:gmatch("[^\r\n]+") do
+        tex.sprint(s)
+    end
+end
+
 function pyluatex.execute(code, write)
-    if pyluatex.verbose then print_input(code) end
+    if pyluatex.verbose then log_input(code) end
 
     local success, output = request({ session = pyluatex.session, code = code })
     if success then
-        if pyluatex.verbose then print_output(output) end
+        if pyluatex.verbose then log_output(output) end
         if write then
-            tex.sprint(output)
+            print_lines(output)
         else
             return output
         end
     else
-        if not pyluatex.verbose then print_input(code) end
-        print_output(output)
+        if not pyluatex.verbose then log_input(code) end
+        log_output(output)
         if write then
             tex.sprint(err_cmd("Python error (see above)"))
         end
@@ -100,6 +107,13 @@
     return nil
 end
 
+function pyluatex.print_env()
+    if python_output ~= nil then
+        print_lines(python_output)
+        python_output = nil
+    end
+end
+
 local function record_line(line)
     local s, e = line:find(env_end)
     if s ~= nil then
@@ -108,7 +122,8 @@
         local code = table.concat(python_lines, "\n")
         local output = pyluatex.execute(code, false)
         if output ~= nil then
-            return output .. line:sub(s)
+            python_output = output
+            return line:sub(s)
         else
             return env_end .. err_cmd("Python error (see above)") .. line:sub(e + 1)
         end
@@ -120,6 +135,7 @@
 
 function pyluatex.record_env()
     python_lines = {}
+    python_output = nil
     luatexbase.add_to_callback("process_input_buffer", record_line, "pyluatex_record_line")
 end
 

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	2021-07-16 19:57:34 UTC (rev 59952)
+++ trunk/Master/texmf-dist/doc/lualatex/pyluatex/pyluatex.tex	2021-07-16 19:57:46 UTC (rev 59953)
@@ -15,7 +15,7 @@
 \usepackage{url}
 \title{The \emph{pyluatex} package}
 \author{Tobias Enderle\\\url{https://github.com/tndrle/PyLuaTeX}}
-\date{v0.1.2 (2021/07/14)}
+\date{v0.1.3 (2021/07/15)}
 \begin{document}
 \maketitle
 \raggedright
@@ -72,13 +72,18 @@
   Demonstrates the use of different Python sessions in a document
 \item \inlcode|data-visualization.tex|\\[0.5ex]
   Demonstrates the visualization of data using \textit{pgfplots} and \textit{pandas}
+\item \inlcode|matplotlib-external.tex|\\[0.5ex]
+  Demonstrates how \textit{matplotlib} plots can be generated and included in a document
+\item \inlcode|matplotlib-pgf.tex|\\[0.5ex]
+  Demonstrates how \textit{matplotlib} plots can be generated and included in a document using \textit{PGF}
 \end{itemize}
 For more intricate use cases have a look at our tests in the folder \inlcode|test|.
 
 \section{Installation}
-PyLuaTeX is not yet available through package managers or CTAN\footnote{\url{https://ctan.org}}.
+PyLuaTeX is available on CTAN\footnote{\url{https://ctan.org/pkg/pyluatex}} and in MiKTeX.
+It will be available in TeX Live soon (when you read this it probably already is).
 
-To install PyLuaTeX, do the following steps:
+To install PyLuaTeX \textbf{manually}, do the following steps:
 \begin{enumerate}
 \item  Locate your local \textit{TEXMF} folder\\[0.5ex]
 The location of this folder may vary. Typical defaults for TeX Live are \inlcode|~/texmf| for Linux,

Modified: trunk/Master/texmf-dist/tex/lualatex/pyluatex/pyluatex.sty
===================================================================
--- trunk/Master/texmf-dist/tex/lualatex/pyluatex/pyluatex.sty	2021-07-16 19:57:34 UTC (rev 59952)
+++ trunk/Master/texmf-dist/tex/lualatex/pyluatex/pyluatex.sty	2021-07-16 19:57:46 UTC (rev 59953)
@@ -9,7 +9,7 @@
 %% version 2005/12/01 or later.
 
 \NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{pyluatex}[2021/07/14 v0.1.2 Execute Python code on the fly]
+\ProvidesPackage{pyluatex}[2021/07/15 v0.1.3 Execute Python code on the fly]
 
 \RequirePackage{expl3}
 \ExplSyntaxOn
@@ -30,7 +30,8 @@
 
 \directlua{pyluatex.start([==[\pyluatex at executable]==])}
 
-\newenvironment{python}{\directlua{pyluatex.record_env()}}{}
+\newenvironment{python}{\directlua{pyluatex.record_env()}}%
+{\directlua{pyluatex.print_env()}}
 
 \newcommand*{\py}[1]{%
 \directlua{pyluatex.execute([==[print(str(#1), end='')]==], true)}%



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