summaryrefslogtreecommitdiff
path: root/Master
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2021-07-16 19:57:46 +0000
committerKarl Berry <karl@freefriends.org>2021-07-16 19:57:46 +0000
commit4c38ce6b85080cb3ec3aa689cd8bdea837b0732b (patch)
tree2661e6ea45896f79f01d5a06dfc29466dfd942fb /Master
parent7dae219cffdd41f06364c53711ced32311b69733 (diff)
pyluatex (16jul21)
git-svn-id: svn://tug.org/texlive/trunk@59953 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master')
-rw-r--r--Master/texmf-dist/doc/lualatex/pyluatex/README.md4
-rw-r--r--Master/texmf-dist/doc/lualatex/pyluatex/pyluatex.lua32
-rw-r--r--Master/texmf-dist/doc/lualatex/pyluatex/pyluatex.pdfbin64343 -> 65417 bytes
-rw-r--r--Master/texmf-dist/doc/lualatex/pyluatex/pyluatex.tex11
-rw-r--r--Master/texmf-dist/tex/lualatex/pyluatex/pyluatex.sty5
5 files changed, 39 insertions, 13 deletions
diff --git a/Master/texmf-dist/doc/lualatex/pyluatex/README.md b/Master/texmf-dist/doc/lualatex/pyluatex/README.md
index f9e727fabfd..a555ec20086 100644
--- a/Master/texmf-dist/doc/lualatex/pyluatex/README.md
+++ b/Master/texmf-dist/doc/lualatex/pyluatex/README.md
@@ -54,3 +54,7 @@ Ubuntu 20.04, macOS Catalina 10.15 and Windows Server 2019.
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
diff --git a/Master/texmf-dist/doc/lualatex/pyluatex/pyluatex.lua b/Master/texmf-dist/doc/lualatex/pyluatex/pyluatex.lua
index 07d8ea49d3f..4f904afe157 100644
--- a/Master/texmf-dist/doc/lualatex/pyluatex/pyluatex.lua
+++ b/Master/texmf-dist/doc/lualatex/pyluatex/pyluatex.lua
@@ -36,6 +36,7 @@ local script = file.join(folder, "pyluatex-interpreter.py")
local tcp = nil
local python_lines = {}
+local python_output = nil
local env_end = "\\end{python}"
@@ -71,28 +72,34 @@ local function request(data)
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 @@ function pyluatex.execute(code, write)
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 function record_line(line)
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 @@ end
function pyluatex.record_env()
python_lines = {}
+ python_output = nil
luatexbase.add_to_callback("process_input_buffer", record_line, "pyluatex_record_line")
end
diff --git a/Master/texmf-dist/doc/lualatex/pyluatex/pyluatex.pdf b/Master/texmf-dist/doc/lualatex/pyluatex/pyluatex.pdf
index 2ff342d0f82..4e93fb29355 100644
--- a/Master/texmf-dist/doc/lualatex/pyluatex/pyluatex.pdf
+++ b/Master/texmf-dist/doc/lualatex/pyluatex/pyluatex.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/lualatex/pyluatex/pyluatex.tex b/Master/texmf-dist/doc/lualatex/pyluatex/pyluatex.tex
index a6a66fbde27..c64d7579459 100644
--- a/Master/texmf-dist/doc/lualatex/pyluatex/pyluatex.tex
+++ b/Master/texmf-dist/doc/lualatex/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.1.2 (2021/07/14)}
+\date{v0.1.3 (2021/07/15)}
\begin{document}
\maketitle
\raggedright
@@ -72,13 +72,18 @@ The folder \inlcode|example| contains additional example documents:
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,
diff --git a/Master/texmf-dist/tex/lualatex/pyluatex/pyluatex.sty b/Master/texmf-dist/tex/lualatex/pyluatex/pyluatex.sty
index 752f19d0e76..b9ce3f97179 100644
--- a/Master/texmf-dist/tex/lualatex/pyluatex/pyluatex.sty
+++ b/Master/texmf-dist/tex/lualatex/pyluatex/pyluatex.sty
@@ -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@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)}%