Skip to content

Commit

Permalink
v0.16
Browse files Browse the repository at this point in the history
  • Loading branch information
gpoore committed Jul 21, 2017
1 parent a636e61 commit 0fb1731
Show file tree
Hide file tree
Showing 19 changed files with 79 additions and 61 deletions.
14 changes: 14 additions & 0 deletions NEWS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,20 @@ Version History
===============



v0.16 (2017/07/20)
------------------

* Added preliminary console support for Julia (#98).

* Fixed Python console compatibility with Python 3.6 by setting the ``code``
module's new ``exitmsg`` argument to suppress the exit message (#100).

* Improved Rust support, including tracking of created files and
dependencies (#91).



v0.15 (2016/07/21)
------------------

Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

:Author: Geoffrey Poore

:Version: 0.15
:Version: 0.16

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

Expand Down
2 changes: 1 addition & 1 deletion pythontex/README
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
===================================================================

:Author: Geoffrey Poore
:Version: 0.15 (2016/07/21)
:Version: 0.16 (2017/07/20)
:License: LPPL v1.3 or later (LaTeX code) and BSD 3-Clause (Python code)
:Development: https://github.com/gpoore/pythontex
:Requirements: Python 2.7 or 3.2+; Pygments
Expand Down
2 changes: 1 addition & 1 deletion pythontex/depythontex.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
launch depythontex2.py or depythontex3.py directly. The version of Python
does not matter for depythontex, since no code is executed.
Copyright (c) 2013-2016, Geoffrey M. Poore
Copyright (c) 2013-2017, Geoffrey M. Poore
All rights reserved.
Licensed under the BSD 3-Clause License:
http://www.opensource.org/licenses/BSD-3-Clause
Expand Down
4 changes: 2 additions & 2 deletions pythontex/depythontex2.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
typeset with a different package.
Copyright (c) 2013-2016, Geoffrey M. Poore
Copyright (c) 2013-2017, Geoffrey M. Poore
All rights reserved.
Licensed under the BSD 3-Clause License:
http://www.opensource.org/licenses/BSD-3-Clause
Expand Down Expand Up @@ -86,7 +86,7 @@

# Script parameters
# Version
__version__ = '0.16dev'
__version__ = '0.16'


# Functions and parameters for customizing the script output
Expand Down
4 changes: 2 additions & 2 deletions pythontex/depythontex3.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
typeset with a different package.
Copyright (c) 2013-2016, Geoffrey M. Poore
Copyright (c) 2013-2017, Geoffrey M. Poore
All rights reserved.
Licensed under the BSD 3-Clause License:
http://www.opensource.org/licenses/BSD-3-Clause
Expand Down Expand Up @@ -86,7 +86,7 @@

# Script parameters
# Version
__version__ = '0.16dev'
__version__ = '0.16'


# Functions and parameters for customizing the script output
Expand Down
14 changes: 9 additions & 5 deletions pythontex/pythontex.dtx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
%<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
%<package>\ProvidesPackage{pythontex}
%<*package>
[2017/05/25 v0.16dev execute and typeset Python code and other languages]
[2017/07/20 v0.16 execute and typeset Python code and other languages]
%</package>
%
%<*driver>
Expand Down Expand Up @@ -134,7 +134,7 @@
%</driver>
% \fi
%
% \CheckSum{3182}
% \CheckSum{3218}
%
% \CharacterTable
% {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
Expand All @@ -154,10 +154,10 @@
%
%

% \begin{changelog}{v0.16}{2017/06/??}
% \begin{changelog}{v0.16}{2017/07/20}
% \begin{itemize}
% \item Added preliminary console support for Julia (\#98).
% \item Fixed Python console compatibility with Python 3.6 by setting the \texttt{code} module's new \texttt{exitmsg} argument to suppress the exit message (\#100).
% \item Fixed Python console compatibility with Python 3.6 by setting the \texttt{code} module's new \texttt{exitmsg} argument to suppress the exit message (\#100).
% \item Improved Rust support, including tracking of created files and dependencies (\#91).
% \end{itemize}
% \end{changelog}
Expand Down Expand Up @@ -1547,6 +1547,10 @@
%
% Julia exceptions are synchronized with the document, but the line numbering does not always correspond to the Python equivalent. This is because Julia allows expressions to be continued on subsequent lines in ways that Python does not.
%
% \subsubsection*{Console}
%
% Preliminary Julia console support was added in v0.16, under the base name |juliacon|. Unlike the Python console environments that allow invalid input, currently everything entered in a |juliaconsole| environment must be valid. The Julia console uses \href{https://github.com/mpastell/Weave.jl}{\textsf{Weave.jl}} internally to evaluate code, and it currently does not support invalid input.
%
%
% \subsection{Octave}
%
Expand Down Expand Up @@ -1809,7 +1813,7 @@
% We store the name of the package in a macro for later use in warnings and error messages.
% \begin{macrocode}
\newcommand{\pytx@packagename}{PythonTeX}
\newcommand{\pytx@packageversion}{0.16dev}
\newcommand{\pytx@packageversion}{0.16}
% \end{macrocode}
%
% \subsection{Required packages}
Expand Down
Binary file modified pythontex/pythontex.pdf
Binary file not shown.
2 changes: 1 addition & 1 deletion pythontex/pythontex.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
Licensed under the BSD 3-Clause License:
Copyright (c) 2012-2016, Geoffrey M. Poore
Copyright (c) 2012-2017, Geoffrey M. Poore
All rights reserved.
Expand Down
4 changes: 2 additions & 2 deletions pythontex/pythontex.sty
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
%%
\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\ProvidesPackage{pythontex}
[2017/05/25 v0.16dev execute and typeset Python code and other languages]
[2017/07/20 v0.16 execute and typeset Python code and other languages]


\newcommand{\pytx@packagename}{PythonTeX}
\newcommand{\pytx@packageversion}{0.16dev}
\newcommand{\pytx@packageversion}{0.16}
\RequirePackage{fvextra}
\RequirePackage{etoolbox}
\RequirePackage{xstring}
Expand Down
4 changes: 2 additions & 2 deletions pythontex/pythontex2.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
Licensed under the BSD 3-Clause License:
Copyright (c) 2012-2016, Geoffrey M. Poore
Copyright (c) 2012-2017, Geoffrey M. Poore
All rights reserved.
Expand Down Expand Up @@ -77,7 +77,7 @@

# Script parameters
# Version
__version__ = '0.16dev'
__version__ = '0.16'



Expand Down
4 changes: 2 additions & 2 deletions pythontex/pythontex3.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
Licensed under the BSD 3-Clause License:
Copyright (c) 2012-2016, Geoffrey M. Poore
Copyright (c) 2012-2017, Geoffrey M. Poore
All rights reserved.
Expand Down Expand Up @@ -77,7 +77,7 @@

# Script parameters
# Version
__version__ = '0.16dev'
__version__ = '0.16'



Expand Down
38 changes: 19 additions & 19 deletions pythontex/pythontex_2to3.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,30 @@
'''
Convert PythonTeX scripts from Python 2 to Python 3
It isn't possible to have a single PythonTeX code base, since unicode text
needs to be supported. Under Python 2, this means importing unicode_literals
It isn't possible to have a single PythonTeX code base, since unicode text
needs to be supported. Under Python 2, this means importing unicode_literals
from __future__, or using the unicode function or "u" prefix. Under Python 3,
all strings are automatically unicode.
At the same time, the differences between the Python 2 and 3 versions are
At the same time, the differences between the Python 2 and 3 versions are
usually very small, involving only a few lines of code. To keep the code base
unified, while simultaneously fully supporting both Python 2 and 3, the
following scheme was devised. The code is written for Python 2. Whenever
code is not compatible with Python 3, it is enclosed with the tags
"#// Python 2" and "#\\ End Python 2" (each on its own line, by itself). If
a Python 3 version of the code is needed, it is included between analogous
tags "#// Python 3" and "#\\ End Python 2". The Python 3 code is commented
unified, while simultaneously fully supporting both Python 2 and 3, the
following scheme was devised. The code is written for Python 2. Whenever
code is not compatible with Python 3, it is enclosed with the tags
"#// Python 2" and "#\\ End Python 2" (each on its own line, by itself). If
a Python 3 version of the code is needed, it is included between analogous
tags "#// Python 3" and "#\\ End Python 2". The Python 3 code is commented
out with "#", at the same indentation level as the Python 3 tags.
This script creates Python 3 scripts from the original Python 2 scripts
by commenting out everything between the Python 2 tags, and uncommenting
everything between the Python 3 tags. In this way, full compatibility is
maintained with both Python 2 and 3 while keeping the code base essentially
unified. This approach also allows greater customization of version-specific
code than would be possible if automatic translation with a tool like 2to3
This script creates Python 3 scripts from the original Python 2 scripts
by commenting out everything between the Python 2 tags, and uncommenting
everything between the Python 3 tags. In this way, full compatibility is
maintained with both Python 2 and 3 while keeping the code base essentially
unified. This approach also allows greater customization of version-specific
code than would be possible if automatic translation with a tool like 2to3
was required.
Copyright (c) 2012-2014, Geoffrey M. Poore
Copyright (c) 2012-2017, Geoffrey M. Poore
All rights reserved.
Licensed under the BSD 3-Clause License:
http://www.opensource.org/licenses/BSD-3-Clause
Expand All @@ -50,7 +50,7 @@ def from2to3(list_of_code):
in_2 = False
in_3 = False
indent = ''

for line in list_of_code:
if r'#// Python 2' in line:
in_2 = True
Expand All @@ -70,8 +70,8 @@ def from2to3(list_of_code):
if fixed[0].startswith('#!/usr/bin/env python2'):
fixed[0] = fixed[0].replace('python2', 'python3')
return fixed


for file in files_to_process:
f = open(file, 'r', encoding=encoding)
converted_code = from2to3(f.readlines())
Expand Down
2 changes: 1 addition & 1 deletion pythontex/pythontex_engines.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
Copyright (c) 2012-2016, Geoffrey M. Poore
Copyright (c) 2012-2017, Geoffrey M. Poore
All rights reserved.
Licensed under the BSD 3-Clause License:
http://www.opensource.org/licenses/BSD-3-Clause
Expand Down
16 changes: 8 additions & 8 deletions pythontex_gallery/make_pythontex_gallery_html2.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
# -*- coding: utf8 -*-

'''
This script creates an HTML version of pythontex_gallery.tex, using
This script creates an HTML version of pythontex_gallery.tex, using
depythontex. This task could be accomplished manually with little effort,
but that would involve directly modifying pythontex_gallery.tex, which is
but that would involve directly modifying pythontex_gallery.tex, which is
undesirable.
The conversion process involves a few tricks for dealing with image formats
and paths. These could be unnecessary in a document that is specifically
written with HTML conversion in mind. For example, all images could be
saved in the main document directory (or have their full path specified
explicitly), all images could be saved in PNG format, and all images could
and paths. These could be unnecessary in a document that is specifically
written with HTML conversion in mind. For example, all images could be
saved in the main document directory (or have their full path specified
explicitly), all images could be saved in PNG format, and all images could
have their extension specified in the `\includegraphics` command.
Pandoc doesn't currently deal with all the LaTeX in the gallery file
Pandoc doesn't currently deal with all the LaTeX in the gallery file
correctly, so a few special tweaks are required.
'''

Expand Down Expand Up @@ -52,7 +52,7 @@
for n, line in enumerate(gallery):
if 'savefig' in line and re.search(r"savefig\('\w+\.pdf'", line):
gallery[n] = re.sub(r"savefig\('(\w+)\.pdf'", r"savefig('\1.png'", line)
if r'\includegraphics' in line and re.search(r'\includegraphics(?:\[.*\])?\{\w+\.pdf\}', line):
if r'\includegraphics' in line and re.search(r'\\includegraphics(?:\[.*\])?\{\w+\.pdf\}', line):
gallery[n] = re.sub(r'\\includegraphics(?:\[.*\])?\{(\w+)\.pdf\}', r'\includegraphics{\1.png}', line)
if r'\begin{mdframed}' in line:
gallery[n] = re.sub(r'\\begin\{mdframed\}(?:\[.*\])?', '', line)
Expand Down
16 changes: 8 additions & 8 deletions pythontex_gallery/make_pythontex_gallery_html3.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
# -*- coding: utf8 -*-

'''
This script creates an HTML version of pythontex_gallery.tex, using
This script creates an HTML version of pythontex_gallery.tex, using
depythontex. This task could be accomplished manually with little effort,
but that would involve directly modifying pythontex_gallery.tex, which is
but that would involve directly modifying pythontex_gallery.tex, which is
undesirable.
The conversion process involves a few tricks for dealing with image formats
and paths. These could be unnecessary in a document that is specifically
written with HTML conversion in mind. For example, all images could be
saved in the main document directory (or have their full path specified
explicitly), all images could be saved in PNG format, and all images could
and paths. These could be unnecessary in a document that is specifically
written with HTML conversion in mind. For example, all images could be
saved in the main document directory (or have their full path specified
explicitly), all images could be saved in PNG format, and all images could
have their extension specified in the `\includegraphics` command.
Pandoc doesn't currently deal with all the LaTeX in the gallery file
Pandoc doesn't currently deal with all the LaTeX in the gallery file
correctly, so a few special tweaks are required.
'''

Expand Down Expand Up @@ -52,7 +52,7 @@
for n, line in enumerate(gallery):
if 'savefig' in line and re.search(r"savefig\('\w+\.pdf'", line):
gallery[n] = re.sub(r"savefig\('(\w+)\.pdf'", r"savefig('\1.png'", line)
if r'\includegraphics' in line and re.search(r'\includegraphics(?:\[.*\])?\{\w+\.pdf\}', line):
if r'\includegraphics' in line and re.search(r'\\includegraphics(?:\[.*\])?\{\w+\.pdf\}', line):
gallery[n] = re.sub(r'\\includegraphics(?:\[.*\])?\{(\w+)\.pdf\}', r'\includegraphics{\1.png}', line)
if r'\begin{mdframed}' in line:
gallery[n] = re.sub(r'\\begin\{mdframed\}(?:\[.*\])?', '', line)
Expand Down
Binary file modified pythontex_gallery/myplot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 6 additions & 6 deletions pythontex_gallery/pythontex_gallery.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
code > span.cv { color: #60a0b0; font-weight: bold; font-style: italic; } /* CommentVar */
code > span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Information */
</style>
<script src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"></script>
<script src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_CHTML-full" type="text/javascript"></script>
</head>
<body>
<div id="header">
Expand Down Expand Up @@ -133,15 +133,15 @@ <h1 id="an-automated-derivative-and-integral-table">An automated derivative and

<span class="co"># Create a list of functions to include in the table</span>
funcs <span class="op">=</span> [<span class="st">&#39;sin(x)&#39;</span>, <span class="st">&#39;cos(x)&#39;</span>, <span class="st">&#39;tan(x)&#39;</span>,
<span class="co">&#39;sin(x)**2&#39;</span>, <span class="st">&#39;cos(x)**2&#39;</span>, <span class="st">&#39;tan(x)**2&#39;</span>,
<span class="co">&#39;asin(x)&#39;</span>, <span class="st">&#39;acos(x)&#39;</span>, <span class="st">&#39;atan(x)&#39;</span>,
<span class="co">&#39;sinh(x)&#39;</span>, <span class="st">&#39;cosh(x)&#39;</span>, <span class="st">&#39;tanh(x)&#39;</span>]
<span class="st">&#39;sin(x)**2&#39;</span>, <span class="st">&#39;cos(x)**2&#39;</span>, <span class="st">&#39;tan(x)**2&#39;</span>,
<span class="st">&#39;asin(x)&#39;</span>, <span class="st">&#39;acos(x)&#39;</span>, <span class="st">&#39;atan(x)&#39;</span>,
<span class="st">&#39;sinh(x)&#39;</span>, <span class="st">&#39;cosh(x)&#39;</span>, <span class="st">&#39;tanh(x)&#39;</span>]

<span class="bu">print</span>(<span class="vs">r&#39;\begin{align*}&#39;</span>)

<span class="cf">for</span> func <span class="op">in</span> funcs:
<span class="cf">for</span> func <span class="kw">in</span> funcs:
<span class="co"># Put in some vertical space when switching to arc and hyperbolic funcs</span>
<span class="cf">if</span> func <span class="op">==</span> <span class="st">&#39;asin(x)&#39;</span> <span class="op">or</span> func <span class="op">==</span> <span class="st">&#39;sinh(x)&#39;</span>:
<span class="cf">if</span> func <span class="op">==</span> <span class="st">&#39;asin(x)&#39;</span> <span class="kw">or</span> func <span class="op">==</span> <span class="st">&#39;sinh(x)&#39;</span>:
<span class="bu">print</span>(<span class="vs">r&#39;&amp;\\&#39;</span>)
myderiv <span class="op">=</span> <span class="st">&#39;Derivative(&#39;</span> <span class="op">+</span> func <span class="op">+</span> <span class="st">&#39;, x)&#39;</span>
myint <span class="op">=</span> <span class="st">&#39;Integral(&#39;</span> <span class="op">+</span> func <span class="op">+</span> <span class="st">&#39;, x)&#39;</span>
Expand Down
Binary file modified pythontex_gallery/pythontex_gallery.pdf
Binary file not shown.

0 comments on commit 0fb1731

Please sign in to comment.