Skip to content

Commit 6017328

Browse files
committed
v0.11 - simplified script usage, renamed and modified some commands for greater clarity and consistency
1 parent 87c74a0 commit 6017328

28 files changed

Lines changed: 1199 additions & 1042 deletions

README.rst

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
:Author: Geoffrey Poore
1111

12-
:Version: 0.11beta
12+
:Version: 0.11
1313

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

@@ -20,25 +20,51 @@
2020

2121
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.
2222

23-
See ``pythontex.pdf`` for installation instructions. See ``pythontex_gallery.pdf`` for examples of what is possible with PythonTeX.
23+
See ``pythontex.pdf`` for detailed installation instructions, or use the installation script for TeX Live. See ``pythontex_quickstart.pdf`` to get started, and ``pythontex_gallery.pdf`` for examples of what is possible with PythonTeX.
2424

2525
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/>`_.
2626

2727

28-
Current status (2013/04/03)
29-
---------------------------
28+
Current status
29+
--------------
3030

31-
A thorough review of all current and planned features has just been completed. This clears the way for a full release as soon as a few modifications are made . The goal is to freeze all syntax and command names after the full release, so ensuring their compatibility with planned features is important.
31+
Immediate development goals:
3232

33-
Upcoming development will focus on refactoring. This has two goals:
33+
* Create a simple system for adding support for additional programming languages beyond Python. Add basic support for at least one additional language as proof-of-concept.
34+
* Improve treatment of stderr, so that UserWarnings generated by packages may be processed correctly.
3435

35-
* Better support for macro programming with PythonTeX.
36-
* Creating a simple system for adding support for additional programming languages beyond Python.
36+
37+
Upcoming objectives:
38+
39+
* Add better support for macro programming with PythonTeX.
3740

3841

3942
Version History
4043
---------------
4144

45+
v0.11 (2013/04/21)
46+
47+
* As the first non-beta release, this version adds several features and introduces several changes. You should read these release notes carefully, since some changes are not backwards-compatible. Changes are based on a thorough review of all current and planned features. PythonTeX's capabilities have already grown beyond what was originally intended, and a long list of features still remains to be implemented. As a result, some changes are needed to ensure consistent syntax and naming in the future. Insofar as possible, all command names and syntax will be frozen after this release.
48+
* Added the ``pythontex.py`` and ``depythontex.py`` wrapper scripts. When run, these detect the current version of Python and import the correct PythonTeX code. It is still possible to run ``pythontex*.py`` and ``depythontex*.py`` directly, but the new wrapper scripts should be used instead for simplicity. There is now only a single ``pythontex_utils.py``, which works with both Python 2 and Python 3.
49+
* Added the ``beta`` package option. This makes the current version behave like v0.11beta, for compatibility. This option is temporary and will probably only be retained for a few releases.
50+
* Backward-incompatible changes (require the ``beta`` option to restore old behavior)
51+
52+
- The ``pyverb`` environment has been renamed ``pyverbatim``. The old name was intended to be concise, but promoted confusion with LaTeX's ``\verb`` macro.
53+
- For ``\printpythontex``, ``\stdoutpythontex``, and ``\stderrpythontex``, the modes ``inlineverb`` and ``v`` have been replaced by ``verb``, and the old mode ``verb`` has been replaced by ``verbatim``. This brings naming conventions in line with standard LaTeX ``\verb`` and ``verbatim``, avoiding a source of potential confusion.
54+
- The ``\setpythontexpyglexer``, ``\setpythontexpygopt``, and ``\setpygmentspygopt`` commands now take an optional argument and a mandatory argument, rather than two mandatory arguments. This creates better uniformity among current and planned settings macros.
55+
- The ``\setpythontexformatter`` and ``\setpygmentsformatter`` commands have been replaced by the ``\setpythontexprettyprinter`` and ``\setpygmentsprettyprinter`` commands. This anticipates possible upcoming features. It also avoids potential confusion with Pygments's formatters and the utilities class's ``formatter()`` method.
56+
57+
* Deprecated (still work, but raise warnings; after a few releases, they will raise errors instead, and after that eventually be removed)
58+
59+
- The ``rerun`` setting ``all`` was renamed ``always``, in preparation for upcoming features.
60+
- The ``stderr`` option is replaced by ``makestderr``. The ``print``/``stdout`` option is replaced by ``debug``. These are intended to prevent confusion with future features.
61+
- The ``fixlr`` option is deprecated. It was originally introduced to deal with some of SymPy's LaTeX formatting, which has since changed.
62+
- The utilities class method ``init_sympy_latex()`` is deprecated. The ``sympy_latex()`` and ``set_sympy_latex()`` methods now automatically initialize themselves on first use.
63+
64+
* Added ``autostdout`` package option and ``\setpythontexautostdout``, to complement ``autoprint``. Added ``prettyprinter`` and ``prettyprintinline`` package options to complement new settings commands.
65+
* Added quickstart guide.
66+
* Installer now installs gallery and quickstart files, if present.
67+
4268

4369
v0.11beta (2013/02/17)
4470

pythontex/README

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
===================================================================
2+
The PythonTeX Package
3+
===================================================================
4+
5+
:Author: Geoffrey Poore
6+
:Version: 0.11 (2013/04/21)
7+
:License: LPPL v1.3 or later (LaTeX code) and BSD 3-Clause (Python code)
8+
:Development: https://github.com/gpoore/pythontex
9+
:Requirements: Python 2.7 or 3.2+; Pygments
10+
11+
12+
The PythonTeX package allows you to enter Python code within a LaTeX
13+
document, execute the code, and access its output in the original document.
14+
15+
PythonTeX provides fast, user-friendly access to Python from within LaTeX.
16+
Python code is only executed when it has been modified, or when it meets
17+
user-specified criteria. Code may be divided into user-defined sessions,
18+
which automatically run in parallel. Errors and warnings are synchronized
19+
with the LaTeX document, so that they refer to the document's line numbers.
20+
External dependencies can be tracked, so that code is re-executed when the
21+
data it depends on is modified. PythonTeX also provides syntax highlighting
22+
for code in LaTeX documents via the Pygments syntax highlighter.
23+
24+
PythonTeX includes a "depythontex" utility that creates a copy of a document
25+
in which all Python code has been replaced by its output. This can be
26+
convenient for journal submissions, sharing documents, and converting to
27+
other formats.
28+
29+
Consult pythontex_quickstart.pdf and pythontex_gallery.pdf to get
30+
started and for examples of what PythonTeX can do.
31+
32+
Compiling a PythonTeX document involves three steps:
33+
34+
1. Run latex (all Python code is saved to an auxiliary file)
35+
2. Run pythontex.py (all code is executed)
36+
3. Run latex again (Python output is inputted)
37+
38+
See the main documentation in pythontex.pdf for detailed installation
39+
instructions. An installation script is provided for TeX Live. Files
40+
should be installed in the directories indicated below. In summary,
41+
all files must be installed, and symlinks or launching wrappers should be
42+
created for pythontex.py and depythontex.py.
43+
44+
* /doc/latex/pythontex/
45+
46+
- pythontex.pdf
47+
- README
48+
- pythontex_quickstart.tex
49+
- pythontex_quickstart.pdf
50+
- pythontex_gallery.tex
51+
- pythontex_gallery.pdf
52+
53+
* /scripts/pythontex/
54+
55+
- pythontex.py, pythontex2.py, and pythontex3.py
56+
- pythontex_types2.py and pythontex_types3.py
57+
- pythontex_utils.py
58+
- depythontex.py, depythontex2.py, and depythontex3.py
59+
60+
* /source/latex/pythontex/
61+
62+
- pythontex.dtx
63+
- pythontex.ins
64+
65+
* /tex/latex/pythontex/
66+
67+
- pythontex.sty

pythontex/README.rst

Lines changed: 0 additions & 23 deletions
This file was deleted.

pythontex/depythontex.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# -*- coding: utf-8 -*-
2+
'''
3+
This is the PythonTeX wrapper script. It automatically detects the version
4+
of Python, and then imports the correct code from depythontex2.py or
5+
depythontex3.py.
6+
7+
Copyright (c) 2013, Geoffrey M. Poore
8+
All rights reserved.
9+
Licensed under the BSD 3-Clause License:
10+
http://www.opensource.org/licenses/BSD-3-Clause
11+
12+
'''
13+
14+
import sys
15+
if sys.version_info[0] == 2:
16+
import depythontex2 as depythontex
17+
elif sys.version_info[0] == 3:
18+
import depythontex3 as depythontex

pythontex/depythontex2.py

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373

7474
# Script parameters
7575
# Version
76-
version = 'v0.11beta'
76+
version = 'v0.11'
7777

7878

7979

@@ -143,7 +143,7 @@ def replace_code_cmd(name, arglist, linenum, code_replacement,
143143

144144
# We only consider two possible modes of typesetting, verbatim and inline
145145
# verbatim
146-
if code_replacement_mode == 'verb':
146+
if code_replacement_mode == 'verbatim':
147147
# Sometimes we must replace a command with an environment, for
148148
# example, for `\inputpygments`
149149

@@ -223,7 +223,7 @@ def replace_code_env(name, arglist, linenum, code_replacement,
223223
224224
'''
225225
# Currently, there is no need to test for code_replacement_mode, because
226-
# this function is only ever called if the mode is 'verb'. That may
226+
# this function is only ever called if the mode is 'verbatim'. That may
227227
# change in the future, but it seems unlikely that code entered in an
228228
# environment would end up typeset with a command.
229229
if listing == 'verbatim':
@@ -309,7 +309,7 @@ def replace_print_cmd(name, arglist, linenum,
309309
(replacement, after) (tuple, of str)
310310
311311
'''
312-
if print_replacement_mode in ('inlineverb', 'v'):
312+
if print_replacement_mode == 'verb':
313313
if print_replacement.count('\n') > 1:
314314
print('* DePythonTeX error:')
315315
print(' Attempt to print multiple lines of content near line ' + str(linenum))
@@ -321,7 +321,7 @@ def replace_print_cmd(name, arglist, linenum,
321321
if delim not in print_replacement:
322322
break
323323
print_replacement = r'\verb' + delim + print_replacement + delim
324-
elif print_replacement_mode in ('verb', ):
324+
elif print_replacement_mode == 'verbatim':
325325
if bool(match('\s*?\n', after)):
326326
# Usually, we would end the verbatim environment with a newline.
327327
# This is fine if there is content in `after` before the next
@@ -496,7 +496,7 @@ def replace_print_env(name, arglist, linenum,
496496
since there are currently no environments that use them; they are only
497497
used by `\printpythontex`, which is a command.
498498
'''
499-
if print_replacement_mode in ('inlineverb', 'v'):
499+
if print_replacement_mode == 'verb':
500500
if print_replacement.count('\n') > 1:
501501
print('* DePythonTeX error:')
502502
print(' Attempt to print multiple lines of content near line ' + str(linenum))
@@ -517,7 +517,7 @@ def replace_print_env(name, arglist, linenum,
517517
# line, where they would have been discarded.
518518
if not bool(match('\s*$', after)):
519519
after = sub('^\s*?\n\s*', '', after)
520-
elif print_replacement_mode in ('verb', ):
520+
elif print_replacement_mode == 'verbatim':
521521
if bool(match('\s*?\n', after)):
522522
# Usually, we would end the verbatim environment with a newline.
523523
# This is fine if there is content in `after` before the next
@@ -659,13 +659,6 @@ def replace_print_env(name, arglist, linenum,
659659

660660

661661

662-
# Let the user know things have started
663-
print('This is DePythonTeX {0}'.format(version))
664-
sys.stdout.flush()
665-
666-
667-
668-
669662
# Deal with argv
670663
# Parse argv
671664
parser = argparse.ArgumentParser()
@@ -715,6 +708,16 @@ def replace_print_env(name, arglist, linenum,
715708
elif args.listing == 'pythontex':
716709
preamble_additions.append('\\usepackage{pythontex}')
717710

711+
712+
713+
714+
# Let the user know things have started
715+
print('This is DePythonTeX {0}'.format(version))
716+
sys.stdout.flush()
717+
718+
719+
720+
718721
# Make sure we have a valid texfile
719722
texfile_name = os.path.expanduser(os.path.normcase(args.TEXNAME))
720723
if not os.path.isfile(texfile_name):
@@ -978,7 +981,7 @@ def replace_print_env(name, arglist, linenum,
978981
f.close()
979982
if typeset == 'c':
980983
code_replacement_mode = mode
981-
if depy_type == 'cmd' and code_replacement_mode != 'verb':
984+
if depy_type == 'cmd' and code_replacement_mode != 'verbatim':
982985
# Usually, code from commands is typeset with commands
983986
# and code from environments is typeset in
984987
# environments. The except is code from commands

pythontex/depythontex3.py

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373

7474
# Script parameters
7575
# Version
76-
version = 'v0.11beta'
76+
version = 'v0.11'
7777

7878

7979

@@ -143,7 +143,7 @@ def replace_code_cmd(name, arglist, linenum, code_replacement,
143143

144144
# We only consider two possible modes of typesetting, verbatim and inline
145145
# verbatim
146-
if code_replacement_mode == 'verb':
146+
if code_replacement_mode == 'verbatim':
147147
# Sometimes we must replace a command with an environment, for
148148
# example, for `\inputpygments`
149149

@@ -223,7 +223,7 @@ def replace_code_env(name, arglist, linenum, code_replacement,
223223
224224
'''
225225
# Currently, there is no need to test for code_replacement_mode, because
226-
# this function is only ever called if the mode is 'verb'. That may
226+
# this function is only ever called if the mode is 'verbatim'. That may
227227
# change in the future, but it seems unlikely that code entered in an
228228
# environment would end up typeset with a command.
229229
if listing == 'verbatim':
@@ -309,7 +309,7 @@ def replace_print_cmd(name, arglist, linenum,
309309
(replacement, after) (tuple, of str)
310310
311311
'''
312-
if print_replacement_mode in ('inlineverb', 'v'):
312+
if print_replacement_mode == 'verb':
313313
if print_replacement.count('\n') > 1:
314314
print('* DePythonTeX error:')
315315
print(' Attempt to print multiple lines of content near line ' + str(linenum))
@@ -321,7 +321,7 @@ def replace_print_cmd(name, arglist, linenum,
321321
if delim not in print_replacement:
322322
break
323323
print_replacement = r'\verb' + delim + print_replacement + delim
324-
elif print_replacement_mode in ('verb', ):
324+
elif print_replacement_mode == 'verbatim':
325325
if bool(match('\s*?\n', after)):
326326
# Usually, we would end the verbatim environment with a newline.
327327
# This is fine if there is content in `after` before the next
@@ -496,7 +496,7 @@ def replace_print_env(name, arglist, linenum,
496496
since there are currently no environments that use them; they are only
497497
used by `\printpythontex`, which is a command.
498498
'''
499-
if print_replacement_mode in ('inlineverb', 'v'):
499+
if print_replacement_mode == 'verb':
500500
if print_replacement.count('\n') > 1:
501501
print('* DePythonTeX error:')
502502
print(' Attempt to print multiple lines of content near line ' + str(linenum))
@@ -517,7 +517,7 @@ def replace_print_env(name, arglist, linenum,
517517
# line, where they would have been discarded.
518518
if not bool(match('\s*$', after)):
519519
after = sub('^\s*?\n\s*', '', after)
520-
elif print_replacement_mode in ('verb', ):
520+
elif print_replacement_mode == 'verbatim':
521521
if bool(match('\s*?\n', after)):
522522
# Usually, we would end the verbatim environment with a newline.
523523
# This is fine if there is content in `after` before the next
@@ -659,13 +659,6 @@ def replace_print_env(name, arglist, linenum,
659659

660660

661661

662-
# Let the user know things have started
663-
print('This is DePythonTeX {0}'.format(version))
664-
sys.stdout.flush()
665-
666-
667-
668-
669662
# Deal with argv
670663
# Parse argv
671664
parser = argparse.ArgumentParser()
@@ -715,6 +708,16 @@ def replace_print_env(name, arglist, linenum,
715708
elif args.listing == 'pythontex':
716709
preamble_additions.append('\\usepackage{pythontex}')
717710

711+
712+
713+
714+
# Let the user know things have started
715+
print('This is DePythonTeX {0}'.format(version))
716+
sys.stdout.flush()
717+
718+
719+
720+
718721
# Make sure we have a valid texfile
719722
texfile_name = os.path.expanduser(os.path.normcase(args.TEXNAME))
720723
if not os.path.isfile(texfile_name):
@@ -978,7 +981,7 @@ def replace_print_env(name, arglist, linenum,
978981
f.close()
979982
if typeset == 'c':
980983
code_replacement_mode = mode
981-
if depy_type == 'cmd' and code_replacement_mode != 'verb':
984+
if depy_type == 'cmd' and code_replacement_mode != 'verbatim':
982985
# Usually, code from commands is typeset with commands
983986
# and code from environments is typeset in
984987
# environments. The except is code from commands

pythontex/pythontex.bat

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
@echo off
2+
pythontex.py %*

0 commit comments

Comments
 (0)