Skip to content

Commit 65be8ca

Browse files
committed
v0.15
1 parent ff04515 commit 65be8ca

17 files changed

+390
-368
lines changed

NEWS.rst

+197-152
Large diffs are not rendered by default.

README.rst

+28-53
Original file line numberDiff line numberDiff line change
@@ -11,77 +11,52 @@
1111

1212
:Author: Geoffrey Poore
1313

14-
:Version: 0.14
14+
:Version: 0.15
1515

1616
:License: LPPL_ (LaTeX code) and `BSD 3-Clause`_ (Python code)
1717

1818
.. _LPPL: http://www.latex-project.org/lppl.txt
1919

2020
.. _`BSD 3-Clause`: http://www.opensource.org/licenses/BSD-3-Clause
2121

22-
22+
23+
2324
Overview
2425
========
2526

26-
PythonTeX provides fast, user-friendly access to Python from within LaTeX. It allows Python code entered within a LaTeX document to be executed, and the results to be included within the original document. It also provides syntax highlighting for code within LaTeX documents via the Pygments syntax highlighter.
27+
PythonTeX provides fast, user-friendly access to Python from within LaTeX. It
28+
allows Python code entered within a LaTeX document to be executed, and the
29+
results to be included within the original document. It also provides syntax
30+
highlighting for code within LaTeX documents via the Pygments syntax
31+
highlighter.
2732

28-
PythonTeX also provides support for Ruby, Julia, and Octave. Support for additional languages is coming soon.
33+
PythonTeX also provides support for Ruby, Julia, Octave, Sage, Bash, and Rust.
34+
Support for additional languages is coming soon.
2935

30-
See ``pythontex.pdf`` for detailed installation instructions, or use the installation script for TeX Live and MiKTeX. See ``pythontex_quickstart.pdf`` to get started, and ``pythontex_gallery.pdf`` for examples of what is possible with PythonTeX.
36+
See ``pythontex_quickstart.pdf`` to get started, and ``pythontex_gallery.pdf``
37+
for examples of what is possible with PythonTeX. PythonTeX is included in
38+
TeX Live and MiKTeX and may be installed via the package manager. See
39+
``pythontex.pdf`` for detailed installation instructions if you want to
40+
install the current development version, or use the installation script for
41+
TeX Live and MiKTeX.
42+
43+
The ``depythontex`` utility creates a copy of a PythonTeX document in which
44+
all Python code has been replaced by its output. This plain LaTeX document is
45+
more suitable for journal submission, sharing, or conversion to other document
46+
formats. See ``pythontex_gallery.html`` and the accompanying conversion
47+
script for an example of a PythonTeX document that was converted to HTML via
48+
``depythontex`` and `Pandoc <http://johnmacfarlane.net/pandoc/>`_.
3149

32-
The ``depythontex`` utility creates a copy of a PythonTeX document in which all Python code has been replaced by its output. This plain LaTeX document is more suitable for journal submission, sharing, or conversion to other document formats. See ``pythontex_gallery.html`` and the accompanying conversion script for an example of a PythonTeX document that was converted to HTML via ``depythontex`` and `Pandoc <http://johnmacfarlane.net/pandoc/>`_.
3350

3451

3552
Citing PythonTeX
3653
================
3754

38-
If you use PythonTeX in your writing and research, please consider citing it in any resulting publications. The best and most recent paper is in `Computational Science & Discovery <http://stacks.iop.org/1749-4699/8/i=1/a=014010>`_ (doi:10.1088/1749-4699/8/1/014010). You may also cite the paper in the `2013 SciPy proceedings <http://conference.scipy.org/proceedings/scipy2013/poore.html>`_.
39-
40-
41-
Latest release
42-
==============
43-
44-
(Full release history is available `here <https://github.com/gpoore/pythontex/blob/master/NEWS.rst>`_.)
45-
46-
v0.14 (2014/07/17)
47-
------------------
48-
49-
New features
50-
~~~~~~~~~~~~
51-
52-
* All commands for working with code inline are now robust, via
53-
``etoolbox``'s ``\newrobustcmd``. Among other things, this allows
54-
commands like ``\py`` to work in standard captions that have not been
55-
redefined to avoid protection issues.
56-
* Upgraded ``syncpdb`` to v0.2, which provides better list formatting.
57-
58-
Backward-incompatible changes
59-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
60-
61-
* The default working directory is now the main document directory instead
62-
of the output directory. Using the output directory was a common source
63-
of confusion for new users and was incompatible with plans for future
64-
development. Old documents in which the working directory was not
65-
specified will continue to use the output directory, but PythonTeX will
66-
print an upgrade message; new documents will use the new setting. The
67-
output directory may be selected as the working directory manually, or
68-
with the shorthand
69-
"``\setpythontexworkingdir{<outputdir>}``".
70-
71-
* Standardized version numbering by removing the "v" prefix from the stored
72-
version numbers in Python variables and LaTeX macros. Standardized the
73-
PythonTeX scripts by renaming ``version`` to ``__version__``.
74-
75-
76-
Objectives for future releases
77-
==============================
78-
79-
* Improve support for macro programming with PythonTeX. Add ``depythontex`` support for user macros.
80-
* Improve system for adding other languages.
81-
* Improve ``stderr`` synchronization. Simplify support for multiple languages.
82-
* Add finer-grained control. Work toward ``rerun`` control of execution at the session level, and control of whether ``stdout`` and ``strerr`` are displayed at the command/environment level.
83-
* Refactor to separate the code-management core from LaTeX-related features, so that the core can be used with other document formats (for example, markdown) in a manner similar to Sweave.
84-
55+
If you use PythonTeX in your writing and research, please consider citing it
56+
in any resulting publications. The best and most recent paper is in
57+
`Computational Science & Discovery <http://stacks.iop.org/1749-4699/8/i=1/a=014010>`_ (doi:10.1088/1749-4699/8/1/014010).
58+
You may also cite the paper in the
59+
`2013 SciPy proceedings <http://conference.scipy.org/proceedings/scipy2013/poore.html>`_.
8560

8661

8762

pythontex/README

+12-12
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,28 @@
33
===================================================================
44

55
:Author: Geoffrey Poore
6-
:Version: 0.14 (2014/07/17)
6+
:Version: 0.15 (2016/07/21)
77
:License: LPPL v1.3 or later (LaTeX code) and BSD 3-Clause (Python code)
88
:Development: https://github.com/gpoore/pythontex
99
:Requirements: Python 2.7 or 3.2+; Pygments
1010

1111

12-
The PythonTeX package allows you to enter Python code within a LaTeX
12+
The PythonTeX package allows you to enter Python code within a LaTeX
1313
document, execute the code, and access its output in the original document.
14-
It also supports the Ruby, Julia, and Octave languages.
14+
It also supports the Ruby, Julia, Octave, Sage, Bash, and Rust languages.
1515

1616
PythonTeX provides fast, user-friendly access to Python from within LaTeX.
17-
Python code is only executed when it has been modified, or when it meets
17+
Python code is only executed when it has been modified, or when it meets
1818
user-specified criteria. Code may be divided into user-defined sessions,
19-
which automatically run in parallel. Errors and warnings are synchronized
20-
with the LaTeX document, so that they refer to the document's line numbers.
21-
External dependencies can be tracked, so that code is re-executed when the
22-
data it depends on is modified. PythonTeX also provides syntax highlighting
19+
which automatically run in parallel. Errors and warnings are synchronized
20+
with the LaTeX document, so that they refer to the document's line numbers.
21+
External dependencies can be tracked, so that code is re-executed when the
22+
data it depends on is modified. PythonTeX also provides syntax highlighting
2323
for code in LaTeX documents via the Pygments syntax highlighter.
2424

2525
PythonTeX includes a "depythontex" utility that creates a copy of a document
2626
in which all Python code has been replaced by its output. This can be
27-
convenient for journal submissions, sharing documents, and converting to
27+
convenient for journal submissions, sharing documents, and converting to
2828
other formats.
2929

3030
Consult pythontex_quickstart.pdf and pythontex_gallery.pdf to get
@@ -36,10 +36,10 @@ Compiling a PythonTeX document involves three steps:
3636
2. Run pythontex.py (all code is executed)
3737
3. Run latex again (Python output is inputted)
3838

39-
See the main documentation in pythontex.pdf for detailed installation
39+
See the main documentation in pythontex.pdf for detailed installation
4040
instructions. An installation script is provided for TeX Live and MiKTeX.
41-
Files should be installed in the directories indicated below. In summary,
42-
all files must be installed, and symlinks or launching wrappers should be
41+
Files should be installed in the directories indicated below. In summary,
42+
all files must be installed, and symlinks or launching wrappers should be
4343
created for pythontex.py and depythontex.py.
4444

4545
* /doc/latex/pythontex/

pythontex/depythontex2.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686

8787
# Script parameters
8888
# Version
89-
__version__ = '0.15dev'
89+
__version__ = '0.15'
9090

9191

9292
# Functions and parameters for customizing the script output

pythontex/depythontex3.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686

8787
# Script parameters
8888
# Version
89-
__version__ = '0.15dev'
89+
__version__ = '0.15'
9090

9191

9292
# Functions and parameters for customizing the script output

pythontex/pythontex.dtx

+11-24
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
%<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
2727
%<package>\ProvidesPackage{pythontex}
2828
%<*package>
29-
[2016/07/20 v0.15dev execute and typeset Python code and other languages]
29+
[2016/07/21 v0.15 execute and typeset Python code and other languages]
3030
%</package>
3131
%
3232
%<*driver>
@@ -134,7 +134,7 @@
134134
%</driver>
135135
% \fi
136136
%
137-
% \CheckSum{3212}
137+
% \CheckSum{3174}
138138
%
139139
% \CharacterTable
140140
% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
@@ -153,20 +153,25 @@
153153
% Right brace \} Tilde \~}
154154
%
155155
%
156-
% \begin{changelog}{v0.15}{2016/07/??}
156+
% \begin{changelog}{v0.15}{2016/07/21}
157157
% \textbf{New features}
158158
% \begin{itemize}
159159
% \item The \texttt{fvextra} package is now required. This provides line breaking with fine-grained control over break locations, the ability to highlight specific lines or ranges of lines, improved handling of tabs, and several additional features.
160160
% \item Added \texttt{sub} commands and environments (\texttt{\string\pys}, \texttt{pysub}, ...). These commands and environments perform string interpolation on text. Fields delimited by \texttt{!\{...\}} are replaced by the result of evaluating and then printing their content. This works for all families of commands and environments, not just Python. See the documentation for details about field delimiters and escaping.
161-
% \item Added \texttt{rust} and \texttt{rs} families of commands and environments. These provide complete support for Rust, except that \texttt{rstex.formatter()}, \texttt{rstex.before()}, and \texttt{rstex.after()} will likely need additional refinement (\#90).
161+
% \item Added \texttt{rust} and \texttt{rs} families of commands and environments. These provide essentially complete support for Rust, except that \texttt{rstex.formatter()}, \texttt{rstex.before()}, and \texttt{rstex.after()} will likely need additional refinement (\#90).
162162
% \item Added the \texttt{sage} family of commands and environments, which provide support for Sage (\#63).
163163
% \item Added \texttt{bash} family of commands and environments. This provides basic support for bash (no utilities class or equivalent). Bash works with Windows if it is installed.
164164
% \item Improved \texttt{console} compatibility under Linux with Python 3 (\#70).
165165
% \item Counters for default sessions are now created automatically. This prevents counter errors under some circumstances when working with \texttt{\string\includeonly}.
166+
% \item Commands like \texttt{\string\py} can now output verbatim content under LuaTeX.
167+
% \end{itemize}
168+
% \textbf{Bugfixes}
169+
% \begin{itemize}
166170
% \item Fixed a bug that could cause an endless loop when a \texttt{code} command or environment printed a \texttt{code} command or environment of the same family with \texttt{autoprint=true}.
167171
% \end{itemize}
168172
% \end{changelog}
169173
%
174+
%
170175
% \begin{changelog}{v0.14}{2014/07/17}
171176
% \textbf{New features}
172177
% \begin{itemize}
@@ -833,7 +838,7 @@
833838
%
834839
% Assignment is \textbf{not} allowed using |\py|. For example, |\py{a=1}| is \textbf{not} valid. This is because assignment cannot be converted to a string.\footnote{It would be simple to allow any code within |\textbackslash py|, including assignment, by using a |try/except| statement. In this way, the functionality of |\textbackslash py| and |\textbackslash pyc| could be merged. While that would be simpler to use, it also has serious drawbacks. If |\textbackslash py| is not exclusively used to typeset string representations of \meta{code}, then it is no longer possible on the \LaTeX\ side to determine whether a command should return a string. Thus, it is harder to determine, from within a \TeX\ editor, whether |pythontex.py| needs to be run; warnings for missing Python content could not be issued, because the system wouldn't know (on the \LaTeX\ side) whether content was indeed missing.}
835840
%
836-
% The text returned by Python must be valid \LaTeX\ code. Verbatim and other special content is allowed under the pdfTeX and XeTeX engines (a known bug prevents it from working with LuaTeX). The primary reasons for using |\py| rather than |print| are (1) |\py| is more compact and (2) |print| requires an external file to be created for every command or environment in which it is used, while |\py| and equivalents for other families share a single external file. Thus, use of |\py| minimizes the creation of external files, which is a key design goal for \pytex.\footnote{For |\textbackslash py|, the text returned by Python is stored in macros and thus must be valid \LaTeX\ code, because \LaTeX\ interprets the returned content. The use of macros for storing returned content means that an external file need not be created for each use of |\textbackslash py|. Rather, all macros created by |\textbackslash py| and equivalent commands from other families are stored in a single file that is inputted. Note that even though the content is stored in macros, verbatim content is allowed, through the use of special macro definitions combined with \texttt{\string\scantokens}.} The main reason for using |print| rather than |\py| is if you need to include a very large amount of material; |print|'s use of external files won't use up \TeX's memory, and may give noticeably better performance once the material is sufficiently long.
841+
% The text returned by Python must be valid \LaTeX\ code. Verbatim and other special content is allowed. The primary reasons for using |\py| rather than |print| are (1) |\py| is more compact and (2) |print| requires an external file to be created for every command or environment in which it is used, while |\py| and equivalents for other families share a single external file. Thus, use of |\py| minimizes the creation of external files, which is a key design goal for \pytex.\footnote{For |\textbackslash py|, the text returned by Python is stored in macros and thus must be valid \LaTeX\ code, because \LaTeX\ interprets the returned content. The use of macros for storing returned content means that an external file need not be created for each use of |\textbackslash py|. Rather, all macros created by |\textbackslash py| and equivalent commands from other families are stored in a single file that is inputted. Note that even though the content is stored in macros, verbatim content is allowed, through the use of special macro definitions combined with \texttt{\string\scantokens}.} The main reason for using |print| rather than |\py| is if you need to include a very large amount of material; |print|'s use of external files won't use up \TeX's memory, and may give noticeably better performance once the material is sufficiently long.
837842
%
838843
% \DescribeMacro{\pyc\oarg{session}\meta{opening~delim}\meta{code}\meta{closing~delim}}
839844
%
@@ -1790,7 +1795,7 @@
17901795
% We store the name of the package in a macro for later use in warnings and error messages.
17911796
% \begin{macrocode}
17921797
\newcommand{\pytx@packagename}{PythonTeX}
1793-
\newcommand{\pytx@packageversion}{0.15dev}
1798+
\newcommand{\pytx@packageversion}{0.15}
17941799
% \end{macrocode}
17951800
%
17961801
% \subsection{Required packages}
@@ -2238,8 +2243,6 @@
22382243
%
22392244
% This prevents the creation of unnecessary files, but it also has a significant drawback: only some content can be saved in a standard macro. In particular, verbatim content using |\verb| and |verbatim| will not work. So we need a way to save anything in a macro. The solution is to create a special macro that captures its argument verbatim. The argument is then tokenized when it is used via |\scantokens|. All of this requires a certain amount of catcode trickery.
22402245
%
2241-
% While this approach works with the XeTeX and pdfTeX engines, it does not work with the LuaTeX engine, which has a known bug in its implementation of |\scantokens|.\footnote{\url{http://tracker.luatex.org/view.php?id=733}} So we provide a separate version for Lua\TeX\ that does not support verbatim. The space after the |#1| is intentional, so that the newline at the beginning of the macro definition is gobbled, and the macro content will start with text rather than leading whitespace. Two separate tests for LuaTeX are performed: comparison with an undefined macro |\pytx@undefined|, which will work under most circumstances, and comparison with |\relax|, which serves as a backup in case a test for LuaTeX by another package |\let|'s |\directlua| to |\relax| (for example, an |\expandafter\ifx\csname directlua\endcsname\relax| test).
2242-
%
22432246
% \begin{macrocode}
22442247
\def\pytx@SVMCR#1{%
22452248
\edef\pytx@tmp{\csname #1\endcsname}%
@@ -2256,22 +2259,6 @@
22562259
!expandafter!scantokens!expandafter{#1!empty}}%
22572260
}%
22582261
!endgroup
2259-
\ifx\directlua\pytx@undefined\else
2260-
\def\pytx@SVMCR#1 {%
2261-
\edef\pytx@tmp{\csname #1\endcsname}%
2262-
\pytx@SVMCR@i}
2263-
\long\def\pytx@SVMCR@i#1\endpytx@SVMCR{%
2264-
\expandafter\gdef\pytx@tmp{#1}%
2265-
}
2266-
\fi
2267-
\ifx\directlua\relax\else
2268-
\def\pytx@SVMCR#1 {%
2269-
\edef\pytx@tmp{\csname #1\endcsname}%
2270-
\pytx@SVMCR@i}
2271-
\long\def\pytx@SVMCR@i#1\endpytx@SVMCR{%
2272-
\expandafter\gdef\pytx@tmp{#1}%
2273-
}
2274-
\fi
22752262
% \end{macrocode}\end{macro}
22762263
%
22772264
% \begin{macro}{pytx@Verbatim}

pythontex/pythontex.ins

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
%% Copyright (C) 2012-2014 by Geoffrey M. Poore <[email protected]>
1+
%% Copyright (C) 2012-2016 by Geoffrey M. Poore <[email protected]>
22
%% --------------------------------------------------------------------------
33
%% This work may be distributed and/or modified under the
44
%% conditions of the LaTeX Project Public License, either version 1.3
@@ -25,7 +25,7 @@
2525

2626
This is a generated file.
2727

28-
Copyright (C) 2012-2014 by Geoffrey M. Poore <[email protected]>
28+
Copyright (C) 2012-2016 by Geoffrey M. Poore <[email protected]>
2929
--------------------------------------------------------------------------
3030
This work may be distributed and/or modified under the
3131
conditions of the LaTeX Project Public License, either version 1.3
@@ -45,9 +45,9 @@ version 2005/12/01 or later.
4545
\Msg{* To finish the installation you have to move the following *}
4646
\Msg{* file into a directory searched by TeX: *}
4747
\Msg{* *}
48-
\Msg{* pythontex.sty *}
48+
\Msg{* pythontex.sty *}
4949
\Msg{* *}
50-
\Msg{* To produce the documentation run the file pythontex.dtx *}
50+
\Msg{* To produce the documentation run the file pythontex.dtx *}
5151
\Msg{* through LaTeX. *}
5252
\Msg{* *}
5353
\Msg{* Happy TeXing! *}

pythontex/pythontex.pdf

33.7 KB
Binary file not shown.

0 commit comments

Comments
 (0)