From 26f8c60d721bcd3fe6a0183b9f5ea076f9018293 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Fri, 21 Jul 2017 22:00:53 +0000 Subject: pythontex (21jul17) git-svn-id: svn://tug.org/texlive/trunk@44860 c570f23f-e606-0410-a88d-b1316a301751 --- .../linked_scripts/pythontex/depythontex.py | 2 +- .../texlive/linked_scripts/pythontex/pythontex.py | 2 +- Master/texmf-dist/doc/latex/pythontex/NEWS | 586 -------------------- Master/texmf-dist/doc/latex/pythontex/NEWS.rst | 600 +++++++++++++++++++++ Master/texmf-dist/doc/latex/pythontex/README | 2 +- .../texmf-dist/doc/latex/pythontex/pythontex.pdf | Bin 951758 -> 969134 bytes .../doc/latex/pythontex/pythontex_gallery.pdf | Bin 373106 -> 373207 bytes Master/texmf-dist/scripts/pythontex/depythontex.py | 2 +- .../texmf-dist/scripts/pythontex/depythontex2.py | 4 +- .../texmf-dist/scripts/pythontex/depythontex3.py | 4 +- Master/texmf-dist/scripts/pythontex/pythontex.py | 2 +- Master/texmf-dist/scripts/pythontex/pythontex2.py | 54 +- Master/texmf-dist/scripts/pythontex/pythontex3.py | 54 +- .../texmf-dist/scripts/pythontex/pythontex_2to3.py | 38 +- .../scripts/pythontex/pythontex_engines.py | 259 ++++++--- .../source/latex/pythontex/pythontex.dtx | 46 +- .../texmf-dist/tex/latex/pythontex/pythontex.sty | 23 +- Master/tlpkg/bin/tlpkg-ctan-check | 1 + Master/tlpkg/libexec/ctan2tds | 2 + 19 files changed, 973 insertions(+), 708 deletions(-) delete mode 100644 Master/texmf-dist/doc/latex/pythontex/NEWS create mode 100644 Master/texmf-dist/doc/latex/pythontex/NEWS.rst diff --git a/Build/source/texk/texlive/linked_scripts/pythontex/depythontex.py b/Build/source/texk/texlive/linked_scripts/pythontex/depythontex.py index 30256c6d1c3..3d48e3b1daa 100755 --- a/Build/source/texk/texlive/linked_scripts/pythontex/depythontex.py +++ b/Build/source/texk/texlive/linked_scripts/pythontex/depythontex.py @@ -9,7 +9,7 @@ on your system. If you wish to use a different version of Python, you could 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 diff --git a/Build/source/texk/texlive/linked_scripts/pythontex/pythontex.py b/Build/source/texk/texlive/linked_scripts/pythontex/pythontex.py index 0c6e5c70bb1..2fe6de902a2 100755 --- a/Build/source/texk/texlive/linked_scripts/pythontex/pythontex.py +++ b/Build/source/texk/texlive/linked_scripts/pythontex/pythontex.py @@ -16,7 +16,7 @@ under which your code is actually executed. Licensed under the BSD 3-Clause License: -Copyright (c) 2012-2016, Geoffrey M. Poore +Copyright (c) 2012-2017, Geoffrey M. Poore All rights reserved. diff --git a/Master/texmf-dist/doc/latex/pythontex/NEWS b/Master/texmf-dist/doc/latex/pythontex/NEWS deleted file mode 100644 index 58fa279d663..00000000000 --- a/Master/texmf-dist/doc/latex/pythontex/NEWS +++ /dev/null @@ -1,586 +0,0 @@ -================================================== - PythonTeX News -================================================== - - -Version History -=============== - - -v0.15 (2016/07/21) ------------------- - -New features -~~~~~~~~~~~~ - -* The ``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. - -* Added ``sub`` commands and environments (``\pys``, ``pysub``, ...). These - commands and environments perform string interpolation on text. Fields - delimited by ``!{...}`` 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. - -* Added ``rust`` and ``rs`` families of commands and environments. These - provide essentially complete support for Rust, except that - ``rstex.formatter()``, ``rstex.before()``, and ``rstex.after()`` will - likely need additional refinement (#90). - -* Added the ``sage`` family of commands and environments, which provide - support for Sage (#63). - -* Added ``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. - -* Improved ``console`` compatibility under Linux with Python 3 (#70). - -* Counters for default sessions are now created automatically. This prevents - counter errors under some circumstances when working with ``\includeonly``. - -* Commands like ``\py`` can now output verbatim content under LuaTeX. - -Bugfixes -~~~~~~~~ - -* Fixed a bug that could cause an endless loop when a ``code`` command or - environment printed a ``code`` command or environment of the same family - with ``autoprint=true``. - - - -v0.14 (2014/07/17) ------------------- - -New features -~~~~~~~~~~~~ - -* All commands for working with code inline are now robust, via - ``etoolbox``'s ``\newrobustcmd``. Among other things, this allows - commands like ``\py`` to work in standard captions that have not been - redefined to avoid protection issues. -* Upgraded ``syncpdb`` to v0.2, which provides better list formatting. - -Backward-incompatible changes -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -* The default working directory is now the main document directory instead - of the output directory. Using the output directory was a common source - of confusion for new users and was incompatible with plans for future - development. Old documents in which the working directory was not - specified will continue to use the output directory, but PythonTeX will - print an upgrade message; new documents will use the new setting. The - output directory may be selected as the working directory manually, or - with the shorthand - "``\setpythontexworkingdir{}``". - -* Standardized version numbering by removing the "v" prefix from the stored - version numbers in Python variables and LaTeX macros. Standardized the - PythonTeX scripts by renaming ``version`` to ``__version__``. - - - -v0.13 (2014/07/14) ------------------- - -New features -~~~~~~~~~~~~ - -* Added ``--interactive`` command-line option. This runs a single - session in interactive mode, allowing user input. Among other things, - this is useful when working with debuggers. - -* Added ``--debug`` command-line option. This runs a single session - with the default debugger in interactive mode. Currently, only - standard (non-console) Python sessions are supported. The default - Python debugger is the new ``syncpdb``, which wraps ``pdb`` and - synchronizes code line numbers with document line numbers. All - ``pdb`` commands that take a line number or filename:lineno as an - argument will refer to document files and line numbers when the - argument has a percent symbol (``%``) as a prefix. For example, - ``list %50`` lists code that came from around line 50 in the - document. The ``--debug`` option will support other languages and - provide for customization in the future. - -* Added command-line option ``--jobs``, which allows the maximum number - of concurrent processes to be specified (#35). - -* Added support for GNU Octave, via the ``octave`` family of commands - and environments (#36). Parsing of Octave stderr is not ideal, though - synchronization works in most cases; this will be addressed by a - future rewrite of the stderr parser. - -* Installer now automatically works with MiKTeX, not just TeX Live. - -* The PythonTeX utilities class has a new ``open()`` method that opens - files and automatically tracks dependencies/created files. - -* When ``pythontex2.py`` and ``pythontex3.py`` are run directly, the - Python interpreter is automatically set to a reasonable default - (``py -2`` or ``py -3`` under Windows, using the Python 3.3+ wrapper; - ``python2`` or ``python3`` under other systems). - -* The installer now creates symlinks for the numbered scripts - ``pythontex*.py`` and ``depythontex*.py``. - -* Added Python version checking to all numbered scripts. - -* Under Python, the type of data passed via ``\setpythontexcontext`` may - now be set using YAML-style tags (``!!str``, ``!!int``, ``!!float``). For - example, ``{myint=!!int 123}``. - -* The ``fancyvrb`` options ``firstline`` and ``lastline`` now work with - the ``pygments`` environment and ``\inputpygments`` command. This required - some additional patching of ``fancyvrb``. - -* The ``pytx@Verbatim`` and ``pytx@SaveVerbatim`` environments are now - used for typesetting verbatim code. These are copies of the - ``fancyvrb`` environments. This prevents conflicts when literal - ``Verbatim`` and ``SaveVerbatim`` environments need to be typeset. - -* Improved ``latexmk`` compatibility (#40). Added discussion of - ``latexmk`` usage to documentation. - -* Tildes ``~`` may now be used in ``outputdir`` and ``workingdir`` to - refer to the user�s home directory, even under Windows. - -Bugfixes -~~~~~~~~ - -* Fixed a bug that prevented created files from being cleaned up when - the working directory was not the document root directory and the - full path to the files was not provided. - -* Fixed a bug that prevented the ``fvextfile`` option from working when - external files were highlighted. - - - -v0.13-beta (2014/02/06) ------------------------ - -New features -~~~~~~~~~~~~ - -* Switching to GitHub's Releases for downloads. - -* TeX information such as page dimensions may now be easily passed to the - programming-language side, using the new ``\setpythontexcontext`` command. - Contextual information is stored in the ``context`` attribute of the - utilities class, which is a dictionary (and also has attributes in Python). - -* The utilities class now has ``pt_to_in()``, ``pt_to_cm()``, and - ``pt_to_mm()`` methods for converting units of TeX points into inches, - centimeters, and millimeters. These work with integers and floats, as - well as strings that consist of numbers and optionally end in "pt". There - is also a ``pt_to_bp()`` for converting TeX points (1/72.27 inch) into big - (DTP or PostScript) points (1/72 inch). - -* Expanded Quickstart. Quickstart is now compatible with all LaTeX engines. - Quickstart now avoids ``microtype`` issues on some systems (#32). - -* Added information on citing PythonTeX (#28). - -* Utilities class has a new attribute ``id``, which is a string that joins - the command family name, session name, and session restart parameters with - underscores. This may be used in creating files that need a name that - contains a unique, session-based identifier (for example, names for - figures that are saved automatically). - -Backward-incompatible changes -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -* All utilities-class attributes with names of the form ``input_*`` have - been renamed with the "``input_``" removed. Among other things, this - makes it easier to access the ``context`` attribute (``pytex.context`` - vs. ``pytex.input_context``). - -* ``depythontex`` now has ``-o`` and ``--output`` command-line options for - specifying the name of the output file. If an output file is not - specified, then output is written to ``stdout``. This allows - ``depythontex`` output to be piped to another program. - -* All scripts ``*2.py`` now have shebangs with ``env python2``, and all - scripts ``*3.py`` now have shebangs with ``env python3``. This allows the - wrapper scripts (``env python`` shebang) to be used with the default - Python installation, and the numbered scripts to be used with specific - versions. Remember that except for console content, the ``--interpreter`` - option is what determines the Python version that actually executes code. - The version of Python used to launch ``pythontex.py`` merely determines - the version that manages code execution. (``--interpreter`` support for - console content is coming.) - -* Changed the template style used in the ``CodeEngine`` class. Replacement - fields are now surrounded by single curly braces (as in Python's format - string syntax), rather than double curly braces. Literal curly braces are - obtained by doubling braces. This allows the use of literal adjacent - double braces in templates, which was not possible previously. - -* The Julia template now uses the new ``in()`` function, replacing - ``contains()``. This requires Julia v0.2.0+. - -Bugfixes -~~~~~~~~ - -* Modified test for LuaTeX, so that ``\directlua`` is not ``\let`` to - ``\relax`` if it does not exist. This was causing incompatibility with - ``babel`` under pdfTeX and XeTeX (#33). - -* Added missing shebangs to ``depythontex*.py``. Handling of ``utilspath`` - is now more forgiving, so that ``pythontex_utils.py`` can be installed in - alternate locations (#23). - -* ``depythontex`` no longer leaves a blank line where - ``\usepackage{pythontex}`` was removed. - -* Console environments typeset with ``fancyvrb`` no longer end with an - unnecessary empty line. - -* Fixed bug in installer when ``kpsewhich`` was not found (#21). - - - -v0.12 (2013/08/26) ------------------- - -* Added support for the Julia language, with the ``julia`` and ``jl`` - families of commands and environments. (Note that Pygments only added - Julia support in version 1.6.) - -* Warnings and errors are now synchronized with the line numbers of files - brought in via ``\input``, ``\include``, etc. This is accomplished using - the ``currfile`` package. - -* Added package option ``gobble``. When ``gobble=auto``, all code is - dedented before being executed and/or typeset. The current - implementation is functional but basic; it will be improved and extended - in the future. - -* The document root directory is now always added to ``sys.path`` (or its - equivalent), even when it is not the working directory. (The working - directory has been added to ``sys.path`` since v0.12beta.) The document - directory is added after the working directory, so that the working - directory has precedence. - -* Fixed a bug in ``console`` commands and environments; ``sys.path`` now - contains the working and document directories, and the working directory - is now the output directory by default. This parallels the behavior of - non-``console`` commands and environments. - -* Added command-line option ``--interpreter`` that allows an interpreter to - be invoked via a specific command. This allows, for example, a specific - version of Python to be invoked. - -* Improved synchronization of stderr in cases when an error is triggered - far after its origin (for example, an error caused by a multiline string - that is lacking a closing quote/delimiter, and thus may span several - chunks of user code). - -* Modified usage of the ``shlex`` module to work around its lack of Unicode - support in Python versions prior to 2.7.3. - -* Fixed a bug from v0.12beta that prevented ``\inputpygments`` from working - when ``pygments=true``. - -* Fixed a bug with counters that caused errors when content spanning - multiple columns was created within a ``tabular`` environment. - -* Added checking for compatible Python versions in ``pythontex.py``. - -* Improved execution of ``*.bat`` and ``*.cmd`` files under Windows. The - solution from v0.12beta allowed ``*.bat`` and ``*.cmd`` to be found and - executed when the extension was not given, but did not give correct - return codes. - - -v0.12beta (2013/06/24) ----------------------- - -* Merged ``pythontex_types*.py`` into a single replacement - ``pythontex_engines.py`` compatible with both Python 2 and 3. It is - now much simpler to add support for additional languages. - -* Added support for the Ruby language as a demonstration of new - capabilities. The ``ruby`` and ``rb`` families of commands and - environments may be enabled via the new ``usefamily`` package option. - Support for additional languages is coming soon. See the new section - in the documentation on support for other languages for more - information. - -* Reimplemented treatment of Pygments content for better efficiency. - Now a Pygments process only runs if there is content to highlight. - Eliminated redundant highlighting of unmodified code. - -* Improved treatment of dependencies. If a dependency is modified - (``os.path.getmtime()``) after the current PythonTeX run starts, then - code that depends on it will be re-executed the next time PythonTeX - runs. A message is also issued to indicate that this is the case. - -* The utilities class now has ``before()`` and ``after()`` methods that - are called immediately before and after user code. These may be - redefined to customize output. For example, LaTeX commands could be - printed before and after user code; stdout could be redirected to - ``StringIO`` for further processing; or matplotlib figures could be - automatically detected, saved, and included in the document. - -* Added explanation of how to track dependencies and created files - automatically, and how to include matplotlib figures automatically, - to the documentation for the PythonTeX utilities class. - -* Created a new system for parsing and synchronizing stderr. - - - Exceptions that do not reference a line number in user code (such - as those from ``warnings.warn()`` in a module) are now traced back - to a single command or environment. Previously no synchronization - was attempted. This is accomplished by writing delimiters to - stderr before executing the code from each command/environment. - - - Exceptions that do reference a line in user code are more - efficiently synchronized with a document line number. This is - accomplished by careful record keeping as each script is - assembled. Line number synchronization no longer involves parsing - the script that was executed. - - - Improved and generalized parsing of stderr, in preparation for - supporting additional languages. Exceptions that cannot be - identified as errors or warnings are treated based on - ``Popen.returncode``. - -* Created a new system for ``console`` content. - - - There are now separate families of ``console`` commands and - environments. No Pygments or ``fancyvrb`` settings are shared with - the non-``console`` families, as was previously the case. There - is a new family of commands and environments based on ``pycon``, - including the ``\pycon`` command (inline reference to console variable), - ``pyconsole`` environment (same as the old one), ``\pyconc`` and - ``pyconcode`` (execute only), and ``\pyconv`` and ``pyconverbatim`` - (typeset only). There are equivalent families based on - ``pylabcon`` and ``sympycon``. - - - Each console session now runs in its own process and is cached - individually. Console output is now cached so that changing - Pygments settings no longer requires re-execution. - - - Unicode is now supported under Python 2. - - - The new package option ``pyconfuture`` allows automatic imports - from ``__future__`` for ``console`` families under Python 2, - paralleling the ``pyfuture`` option. - - - Any errors or warnings caused by code that is not typeset - (``code`` command and environment, startup code) are reported in - the run summary. This ensures that such code does not create - mischief. - - - ``customcode`` is now supported for ``console`` content. - -* Better support for ``latexmk`` and similar build tools. PythonTeX - creates a file of macros (``*.pytxmcr``) that is always included in a - document, and thus can be automatically detected and tracked by - ``latexmk``. This file now contains the time at which PythonTeX last - created files. When new files are created, the macro file will have a - new hash, triggering another document compile. - -* Improved the way in which the PythonTeX ``outputdir`` is added to the - graphics path. This had been done with ``\graphicspath``, but that - overwrites any graphics path previously specified by the user. Now the - ``outputdir`` is appended to any pre-existing path. - -* Added the ``depythontex`` option ``--graphicspath``. This adds the - ``outputdir`` to the graphics path of the ``depythontex`` document. - -* The installer now provides more options for installation locations. - It will now create missing directories if desired. - -* The working directory (``workingdir``) is now appended to - ``sys.path``, so that code there may be imported. - -* Under Windows, ``subprocess.Popen()`` is now invoked with - ``shell=True`` if ``shell=False`` results in a WindowsError. This - allows commands involving ``*.bat`` and ``*.cmd`` files to be - executed when the extension is not specified; otherwise, only ``*.exe`` - can be found and run. - -* The path to utils is now found in ``pythontex.py`` via - ``sys.path[0]`` rather than ``kpsewhich``. This allows the PythonTeX - scripts to be executed in an arbitrary location; they no longer must - be installed in a texmf tree where ``kpsewhich`` can find them. - -* Added ``rerun`` value ``never``. - -* At the end of each run, data and macros are only saved if modified, - improving efficiency. - -* The number of temporary files required by each process was reduced by - one. All macros for commands like ``\py`` are now returned within - stdout, rather than in their own file. - -* Fixed a bug with ``\stderrpythontex``; it was defaulting to ``verb`` - rather than ``verbatim`` mode. - - -v0.11 (2013/04/21) ------------------- - -* 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. -* 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. -* 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. -* Backward-incompatible changes (require the ``beta`` option to restore old behavior) - - - The ``pyverb`` environment has been renamed ``pyverbatim``. The old name was intended to be concise, but promoted confusion with LaTeX's ``\verb`` macro. - - 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. - - 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. - - 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. - -* Deprecated (still work, but raise warnings; after a few releases, they will raise errors instead, and after that eventually be removed) - - - The ``rerun`` setting ``all`` was renamed ``always``, in preparation for upcoming features. - - The ``stderr`` option is replaced by ``makestderr``. The ``print``/``stdout`` option is replaced by ``debug``. These are intended to prevent confusion with future features. - - The ``fixlr`` option is deprecated. It was originally introduced to deal with some of SymPy's LaTeX formatting, which has since changed. - - The utilities class method ``init_sympy_latex()`` is deprecated. The ``sympy_latex()`` and ``set_sympy_latex()`` methods now automatically initialize themselves on first use. - -* Added ``autostdout`` package option and ``\setpythontexautostdout``, to complement ``autoprint``. Added ``prettyprinter`` and ``prettyprintinline`` package options to complement new settings commands. -* Added quickstart guide. -* Installer now installs gallery and quickstart files, if present. - - -v0.11beta (2013/02/17) ----------------------- - -* Commands like ``\py`` can now bring in any valid LaTeX code, including verbatim content, under the pdfTeX and XeTeX engines. Verbatim content was not allowed previously. LuaTeX cannot bring in verbatim, due to a known bug. -* Added package option ``depythontex`` and scripts ``depythontex*.py``. These allow a PythonTeX document to be converted into a pure LaTeX document, with no Python dependency. The package option creates an auxiliary file with extension ``.depytx``. The ``depythontex*.py`` scripts take this auxiliary file and the original LaTeX document, and combine the two to produce a new document that does not rely on the PythonTeX package. All PythonTeX commands and environments are replaced by their output. All Python-generated content is substituted directly into the document. By default, all typeset code is wrapped in ``\verb`` and ``verbatim``, but ``depythontex*.py`` has a ``--listing`` option that allows ``fancyvrb``, ``listings``, ``minted``, or ``pythontex`` to be used instead. -* The current PythonTeX version is now saved in the ``.pytxcode``. If this does not match the version of the PythonTeX scripts, a warning is issued. This makes it easier to determine errors due to version mismatches. -* Fixed an incompatibility with the latest release of ``xstring`` (version 1.7, 2013/01/13). -* Fixed a bug in the ``console`` environment that could cause problems when switching from Pygments highlighting to ``fancyvrb`` when using the ``fvextfile`` option. Fixed a bug introduced in the v0.10beta series that prevented the ``console`` environment from working with ``fancyvrb``. -* Fixed a bug with PythonTeX verbatim commands and environments that use Pygments. The verbatim commands and environments were incorrectly treated as if they had the attributes of executed code in the v0.10beta series. -* Fixed a bug from the v0.10beta series that sometimes prevented imports from ``__future__`` from working when there were multiple sessions. -* Fixed a bug related to hashing dependencies' mtime under Python 3. - - -v0.10beta2 (2013/01/23) ------------------------ - -* Improved ``pythontex*.py``'s handling of the name of the file being processed. A warning is no longer raised if the name is given with an extension; extensions are now processed (stripped) automatically. The filename may now contain a path to the file, so you need not run ``pythontex*.py`` from within the document's directory. -* Added command-line option ``--verbose`` for more verbose output. Currently, this prints a list of all processes that are launched. -* Fixed a bug that could crash ``pythontex*.py`` when the package option ``pygments=false``. -* Added documentation about ``autoprint`` behavior in the preamble. Summary: ``code`` commands and environments are allowed in the preamble as of v0.10beta. ``autoprint`` only applies to the body of the document, because nothing can be typeset in the preamble. Content printed in the preamble can be brought in by explicitly using ``\printpythontex``, but this should be used with great care. -* Revised ``\stdoutpythontex`` and ``\printpythontex`` so that they work in the preamble. Again, this should be used with great care if at all. -* Revised treatment of any content that custom code attempts to print. Custom code is not allowed to print to the document (see documentation). If custom code attempts to print, a warning is raised, and the printed content is included in the ``pythontex*.py`` run summary. -* One-line entries in stderr, such as those produced by Python's ``warnings.warn()``, were not previously parsed because they are of the form ``::`` rather than ``line ``. These are now parsed and synchronized with the document. They are also correctly parsed for inclusion in the document via ``\stderrpythontex``. -* If the package option ``stderrfilename`` is changed, all sessions that produced errors or warnings are now re-executed automatically, so that their stderr content is properly updated with the new filename. - - -v0.10beta (2013/01/09) ----------------------- - -* Backward-incompatible: Redid treatment of command-line options for - ``pythontex*.py``, using Python's ``argparse`` module. Run - ``pythontex*.py`` with option ``-h`` to see new command line options. -* Deprecated: ``\setpythontexcustomcode`` is deprecated in favor of the - ``\pythontexcustomc`` command and ``pythontexcustomcode`` - environment. These allow entry of pure code, unlike - ``\setpythontexcustomcode``. These also allow custom code to be - added to the beginning or end of a session, via an optional argument. - Improved treatment of errors and warnings associated with custom - code. -* The summary of errors and warnings now correctly differentiates - errors and warnings produced by user code, rather than treating all - of them as errors. By default, ``pythontex*.py`` now returns an - exit code of 1 if there were errors. -* The PythonTeX utilities class now allows external file dependencies - to be specified via ``pytex.add_dependencies()``, so that sessions - are automatically re-executed when external dependencies are - modified (modification is determined via either hash or mtime; this - is governed by the new ``hashdependencies`` option). -* The PythonTeX utilities class now allows created files to be - specified via ``pytex.add_created()``, so that created files may be - automatically cleaned up (deleted) when the code that created them - is modified (for example, name change for a saved plot). -* Added the following package options. - - - ``stdout`` (or ``print``): Allows input of stdout to be disabled. - Useful for debugging. - - ``runall``: Executes everything. Useful when code depends on - external data. - - ``rerun``: Determines when code is re-executed. Code may be set - to always run (same as ``runall`` option), or only run when it is - modified or when it produces errors or warnings. By default, - code is always re-executed if there are errors or modifications, - but not re-executed if there are warnings. - - ``hashdependencies``: Determines whether external dependencies - (data, external code files highlighted with Pygments, etc.) are - checked for modification via hashing or modification time. - Modification time is default for performance reasons. - -* Added the following new command line options. The options that are - equivalent to package options are overridden by the package options - when present. - - - ``--error-exit-code``: Determines whether an exit code of 1 is - returned if there were errors. On by default, but can be turned - off since it is undesirable when working with some editors. - - ``--runall``: Equivalent to new package option. - - ``--rerun``: Equivalent to new package option. - - ``--hashdependencies``: Equivalent to new package option. - -* Modified the ``fixlr`` option, so that it only patches commands if - they have not already been patched (avoids package conflicts). -* Added ``\setpythontexautoprint`` command for toggling autoprint - on/off within the body of the document. -* Installer now attempts to create symlinks under OS X and Linux with - TeX Live, and under OS X with MacPorts Tex Live. -* Performed compatibility testing under lualatex and xelatex - (previously, had only tested with pdflatex). Added documentation - for using these TeX engines; at most, slightly different preambles - are needed. Modified the PythonTeX gallery to support all three - engines. -* Code commands and environments may now be used in the preamble. - This, combined with the new treatment of custom code, allows - PythonTeX to be used in creating LaTeX packages. -* Added documentation for using PythonTeX in LaTeX programming. -* Fixed a bug that sometimes caused incorrect line numbers with - ``stderr`` content. Improved processing of stderr. -* Fixed a bug in automatic detection of pre-existing listings - environment. -* Improved the detection of imports from ``__future__``. Detection - should now be stricter, faster, and more accurate. - - -v0.9beta3 (2012/07/17) ----------------------- - -* Added Unicode support, which required the Python code to be split into - one set for Python 2 and another set for Python 3. This will require - any old installation to be completely removed, and a new installation - created from scratch. -* Refactoring of Python code. Documents should automatically re-execute - all code after updating to the new version. Otherwise, you should delete - the PythonTeX directory and run PythonTeX. -* Improved installation script. -* Added package options: ``pyfuture``, ``stderr``, ``upquote``, - ``pyglexer``, ``pyginline``. Renamed the ``pygextfile`` option to - ``fvextfile``. -* Added custom code and workingdir commands. -* Added the ``console`` environment and associated options. -* Rewrote ``pythontex_utils*.py``, creating a new, context-aware interface to - SymPy's LatexPrinter class. -* Content brought in via macros no longer uses labels. Rather, long defs - are used, which allows line breaks. -* Pygments highlighting is now default for PythonTeX commands and environments. - - -v0.9beta2 (2012/05/09) ----------------------- - -* Changed Python output extension to ``.stdout``. - - -v0.9beta (2012/04/27) ---------------------- - -* Initial public beta release. diff --git a/Master/texmf-dist/doc/latex/pythontex/NEWS.rst b/Master/texmf-dist/doc/latex/pythontex/NEWS.rst new file mode 100644 index 00000000000..016a7407948 --- /dev/null +++ b/Master/texmf-dist/doc/latex/pythontex/NEWS.rst @@ -0,0 +1,600 @@ +================================================== + PythonTeX News +================================================== + + +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) +------------------ + +New features +~~~~~~~~~~~~ + +* The ``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. + +* Added ``sub`` commands and environments (``\pys``, ``pysub``, ...). These + commands and environments perform string interpolation on text. Fields + delimited by ``!{...}`` 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. + +* Added ``rust`` and ``rs`` families of commands and environments. These + provide essentially complete support for Rust, except that + ``rstex.formatter()``, ``rstex.before()``, and ``rstex.after()`` will + likely need additional refinement (#90). + +* Added the ``sage`` family of commands and environments, which provide + support for Sage (#63). + +* Added ``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. + +* Improved ``console`` compatibility under Linux with Python 3 (#70). + +* Counters for default sessions are now created automatically. This prevents + counter errors under some circumstances when working with ``\includeonly``. + +* Commands like ``\py`` can now output verbatim content under LuaTeX. + +Bugfixes +~~~~~~~~ + +* Fixed a bug that could cause an endless loop when a ``code`` command or + environment printed a ``code`` command or environment of the same family + with ``autoprint=true``. + + + +v0.14 (2014/07/17) +------------------ + +New features +~~~~~~~~~~~~ + +* All commands for working with code inline are now robust, via + ``etoolbox``'s ``\newrobustcmd``. Among other things, this allows + commands like ``\py`` to work in standard captions that have not been + redefined to avoid protection issues. +* Upgraded ``syncpdb`` to v0.2, which provides better list formatting. + +Backward-incompatible changes +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +* The default working directory is now the main document directory instead + of the output directory. Using the output directory was a common source + of confusion for new users and was incompatible with plans for future + development. Old documents in which the working directory was not + specified will continue to use the output directory, but PythonTeX will + print an upgrade message; new documents will use the new setting. The + output directory may be selected as the working directory manually, or + with the shorthand + "``\setpythontexworkingdir{}``". + +* Standardized version numbering by removing the "v" prefix from the stored + version numbers in Python variables and LaTeX macros. Standardized the + PythonTeX scripts by renaming ``version`` to ``__version__``. + + + +v0.13 (2014/07/14) +------------------ + +New features +~~~~~~~~~~~~ + +* Added ``--interactive`` command-line option. This runs a single + session in interactive mode, allowing user input. Among other things, + this is useful when working with debuggers. + +* Added ``--debug`` command-line option. This runs a single session + with the default debugger in interactive mode. Currently, only + standard (non-console) Python sessions are supported. The default + Python debugger is the new ``syncpdb``, which wraps ``pdb`` and + synchronizes code line numbers with document line numbers. All + ``pdb`` commands that take a line number or filename:lineno as an + argument will refer to document files and line numbers when the + argument has a percent symbol (``%``) as a prefix. For example, + ``list %50`` lists code that came from around line 50 in the + document. The ``--debug`` option will support other languages and + provide for customization in the future. + +* Added command-line option ``--jobs``, which allows the maximum number + of concurrent processes to be specified (#35). + +* Added support for GNU Octave, via the ``octave`` family of commands + and environments (#36). Parsing of Octave stderr is not ideal, though + synchronization works in most cases; this will be addressed by a + future rewrite of the stderr parser. + +* Installer now automatically works with MiKTeX, not just TeX Live. + +* The PythonTeX utilities class has a new ``open()`` method that opens + files and automatically tracks dependencies/created files. + +* When ``pythontex2.py`` and ``pythontex3.py`` are run directly, the + Python interpreter is automatically set to a reasonable default + (``py -2`` or ``py -3`` under Windows, using the Python 3.3+ wrapper; + ``python2`` or ``python3`` under other systems). + +* The installer now creates symlinks for the numbered scripts + ``pythontex*.py`` and ``depythontex*.py``. + +* Added Python version checking to all numbered scripts. + +* Under Python, the type of data passed via ``\setpythontexcontext`` may + now be set using YAML-style tags (``!!str``, ``!!int``, ``!!float``). For + example, ``{myint=!!int 123}``. + +* The ``fancyvrb`` options ``firstline`` and ``lastline`` now work with + the ``pygments`` environment and ``\inputpygments`` command. This required + some additional patching of ``fancyvrb``. + +* The ``pytx@Verbatim`` and ``pytx@SaveVerbatim`` environments are now + used for typesetting verbatim code. These are copies of the + ``fancyvrb`` environments. This prevents conflicts when literal + ``Verbatim`` and ``SaveVerbatim`` environments need to be typeset. + +* Improved ``latexmk`` compatibility (#40). Added discussion of + ``latexmk`` usage to documentation. + +* Tildes ``~`` may now be used in ``outputdir`` and ``workingdir`` to + refer to the user�s home directory, even under Windows. + +Bugfixes +~~~~~~~~ + +* Fixed a bug that prevented created files from being cleaned up when + the working directory was not the document root directory and the + full path to the files was not provided. + +* Fixed a bug that prevented the ``fvextfile`` option from working when + external files were highlighted. + + + +v0.13-beta (2014/02/06) +----------------------- + +New features +~~~~~~~~~~~~ + +* Switching to GitHub's Releases for downloads. + +* TeX information such as page dimensions may now be easily passed to the + programming-language side, using the new ``\setpythontexcontext`` command. + Contextual information is stored in the ``context`` attribute of the + utilities class, which is a dictionary (and also has attributes in Python). + +* The utilities class now has ``pt_to_in()``, ``pt_to_cm()``, and + ``pt_to_mm()`` methods for converting units of TeX points into inches, + centimeters, and millimeters. These work with integers and floats, as + well as strings that consist of numbers and optionally end in "pt". There + is also a ``pt_to_bp()`` for converting TeX points (1/72.27 inch) into big + (DTP or PostScript) points (1/72 inch). + +* Expanded Quickstart. Quickstart is now compatible with all LaTeX engines. + Quickstart now avoids ``microtype`` issues on some systems (#32). + +* Added information on citing PythonTeX (#28). + +* Utilities class has a new attribute ``id``, which is a string that joins + the command family name, session name, and session restart parameters with + underscores. This may be used in creating files that need a name that + contains a unique, session-based identifier (for example, names for + figures that are saved automatically). + +Backward-incompatible changes +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +* All utilities-class attributes with names of the form ``input_*`` have + been renamed with the "``input_``" removed. Among other things, this + makes it easier to access the ``context`` attribute (``pytex.context`` + vs. ``pytex.input_context``). + +* ``depythontex`` now has ``-o`` and ``--output`` command-line options for + specifying the name of the output file. If an output file is not + specified, then output is written to ``stdout``. This allows + ``depythontex`` output to be piped to another program. + +* All scripts ``*2.py`` now have shebangs with ``env python2``, and all + scripts ``*3.py`` now have shebangs with ``env python3``. This allows the + wrapper scripts (``env python`` shebang) to be used with the default + Python installation, and the numbered scripts to be used with specific + versions. Remember that except for console content, the ``--interpreter`` + option is what determines the Python version that actually executes code. + The version of Python used to launch ``pythontex.py`` merely determines + the version that manages code execution. (``--interpreter`` support for + console content is coming.) + +* Changed the template style used in the ``CodeEngine`` class. Replacement + fields are now surrounded by single curly braces (as in Python's format + string syntax), rather than double curly braces. Literal curly braces are + obtained by doubling braces. This allows the use of literal adjacent + double braces in templates, which was not possible previously. + +* The Julia template now uses the new ``in()`` function, replacing + ``contains()``. This requires Julia v0.2.0+. + +Bugfixes +~~~~~~~~ + +* Modified test for LuaTeX, so that ``\directlua`` is not ``\let`` to + ``\relax`` if it does not exist. This was causing incompatibility with + ``babel`` under pdfTeX and XeTeX (#33). + +* Added missing shebangs to ``depythontex*.py``. Handling of ``utilspath`` + is now more forgiving, so that ``pythontex_utils.py`` can be installed in + alternate locations (#23). + +* ``depythontex`` no longer leaves a blank line where + ``\usepackage{pythontex}`` was removed. + +* Console environments typeset with ``fancyvrb`` no longer end with an + unnecessary empty line. + +* Fixed bug in installer when ``kpsewhich`` was not found (#21). + + + +v0.12 (2013/08/26) +------------------ + +* Added support for the Julia language, with the ``julia`` and ``jl`` + families of commands and environments. (Note that Pygments only added + Julia support in version 1.6.) + +* Warnings and errors are now synchronized with the line numbers of files + brought in via ``\input``, ``\include``, etc. This is accomplished using + the ``currfile`` package. + +* Added package option ``gobble``. When ``gobble=auto``, all code is + dedented before being executed and/or typeset. The current + implementation is functional but basic; it will be improved and extended + in the future. + +* The document root directory is now always added to ``sys.path`` (or its + equivalent), even when it is not the working directory. (The working + directory has been added to ``sys.path`` since v0.12beta.) The document + directory is added after the working directory, so that the working + directory has precedence. + +* Fixed a bug in ``console`` commands and environments; ``sys.path`` now + contains the working and document directories, and the working directory + is now the output directory by default. This parallels the behavior of + non-``console`` commands and environments. + +* Added command-line option ``--interpreter`` that allows an interpreter to + be invoked via a specific command. This allows, for example, a specific + version of Python to be invoked. + +* Improved synchronization of stderr in cases when an error is triggered + far after its origin (for example, an error caused by a multiline string + that is lacking a closing quote/delimiter, and thus may span several + chunks of user code). + +* Modified usage of the ``shlex`` module to work around its lack of Unicode + support in Python versions prior to 2.7.3. + +* Fixed a bug from v0.12beta that prevented ``\inputpygments`` from working + when ``pygments=true``. + +* Fixed a bug with counters that caused errors when content spanning + multiple columns was created within a ``tabular`` environment. + +* Added checking for compatible Python versions in ``pythontex.py``. + +* Improved execution of ``*.bat`` and ``*.cmd`` files under Windows. The + solution from v0.12beta allowed ``*.bat`` and ``*.cmd`` to be found and + executed when the extension was not given, but did not give correct + return codes. + + +v0.12beta (2013/06/24) +---------------------- + +* Merged ``pythontex_types*.py`` into a single replacement + ``pythontex_engines.py`` compatible with both Python 2 and 3. It is + now much simpler to add support for additional languages. + +* Added support for the Ruby language as a demonstration of new + capabilities. The ``ruby`` and ``rb`` families of commands and + environments may be enabled via the new ``usefamily`` package option. + Support for additional languages is coming soon. See the new section + in the documentation on support for other languages for more + information. + +* Reimplemented treatment of Pygments content for better efficiency. + Now a Pygments process only runs if there is content to highlight. + Eliminated redundant highlighting of unmodified code. + +* Improved treatment of dependencies. If a dependency is modified + (``os.path.getmtime()``) after the current PythonTeX run starts, then + code that depends on it will be re-executed the next time PythonTeX + runs. A message is also issued to indicate that this is the case. + +* The utilities class now has ``before()`` and ``after()`` methods that + are called immediately before and after user code. These may be + redefined to customize output. For example, LaTeX commands could be + printed before and after user code; stdout could be redirected to + ``StringIO`` for further processing; or matplotlib figures could be + automatically detected, saved, and included in the document. + +* Added explanation of how to track dependencies and created files + automatically, and how to include matplotlib figures automatically, + to the documentation for the PythonTeX utilities class. + +* Created a new system for parsing and synchronizing stderr. + + - Exceptions that do not reference a line number in user code (such + as those from ``warnings.warn()`` in a module) are now traced back + to a single command or environment. Previously no synchronization + was attempted. This is accomplished by writing delimiters to + stderr before executing the code from each command/environment. + + - Exceptions that do reference a line in user code are more + efficiently synchronized with a document line number. This is + accomplished by careful record keeping as each script is + assembled. Line number synchronization no longer involves parsing + the script that was executed. + + - Improved and generalized parsing of stderr, in preparation for + supporting additional languages. Exceptions that cannot be + identified as errors or warnings are treated based on + ``Popen.returncode``. + +* Created a new system for ``console`` content. + + - There are now separate families of ``console`` commands and + environments. No Pygments or ``fancyvrb`` settings are shared with + the non-``console`` families, as was previously the case. There + is a new family of commands and environments based on ``pycon``, + including the ``\pycon`` command (inline reference to console variable), + ``pyconsole`` environment (same as the old one), ``\pyconc`` and + ``pyconcode`` (execute only), and ``\pyconv`` and ``pyconverbatim`` + (typeset only). There are equivalent families based on + ``pylabcon`` and ``sympycon``. + + - Each console session now runs in its own process and is cached + individually. Console output is now cached so that changing + Pygments settings no longer requires re-execution. + + - Unicode is now supported under Python 2. + + - The new package option ``pyconfuture`` allows automatic imports + from ``__future__`` for ``console`` families under Python 2, + paralleling the ``pyfuture`` option. + + - Any errors or warnings caused by code that is not typeset + (``code`` command and environment, startup code) are reported in + the run summary. This ensures that such code does not create + mischief. + + - ``customcode`` is now supported for ``console`` content. + +* Better support for ``latexmk`` and similar build tools. PythonTeX + creates a file of macros (``*.pytxmcr``) that is always included in a + document, and thus can be automatically detected and tracked by + ``latexmk``. This file now contains the time at which PythonTeX last + created files. When new files are created, the macro file will have a + new hash, triggering another document compile. + +* Improved the way in which the PythonTeX ``outputdir`` is added to the + graphics path. This had been done with ``\graphicspath``, but that + overwrites any graphics path previously specified by the user. Now the + ``outputdir`` is appended to any pre-existing path. + +* Added the ``depythontex`` option ``--graphicspath``. This adds the + ``outputdir`` to the graphics path of the ``depythontex`` document. + +* The installer now provides more options for installation locations. + It will now create missing directories if desired. + +* The working directory (``workingdir``) is now appended to + ``sys.path``, so that code there may be imported. + +* Under Windows, ``subprocess.Popen()`` is now invoked with + ``shell=True`` if ``shell=False`` results in a WindowsError. This + allows commands involving ``*.bat`` and ``*.cmd`` files to be + executed when the extension is not specified; otherwise, only ``*.exe`` + can be found and run. + +* The path to utils is now found in ``pythontex.py`` via + ``sys.path[0]`` rather than ``kpsewhich``. This allows the PythonTeX + scripts to be executed in an arbitrary location; they no longer must + be installed in a texmf tree where ``kpsewhich`` can find them. + +* Added ``rerun`` value ``never``. + +* At the end of each run, data and macros are only saved if modified, + improving efficiency. + +* The number of temporary files required by each process was reduced by + one. All macros for commands like ``\py`` are now returned within + stdout, rather than in their own file. + +* Fixed a bug with ``\stderrpythontex``; it was defaulting to ``verb`` + rather than ``verbatim`` mode. + + +v0.11 (2013/04/21) +------------------ + +* 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. +* 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. +* 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. +* Backward-incompatible changes (require the ``beta`` option to restore old behavior) + + - The ``pyverb`` environment has been renamed ``pyverbatim``. The old name was intended to be concise, but promoted confusion with LaTeX's ``\verb`` macro. + - 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. + - 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. + - 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. + +* Deprecated (still work, but raise warnings; after a few releases, they will raise errors instead, and after that eventually be removed) + + - The ``rerun`` setting ``all`` was renamed ``always``, in preparation for upcoming features. + - The ``stderr`` option is replaced by ``makestderr``. The ``print``/``stdout`` option is replaced by ``debug``. These are intended to prevent confusion with future features. + - The ``fixlr`` option is deprecated. It was originally introduced to deal with some of SymPy's LaTeX formatting, which has since changed. + - The utilities class method ``init_sympy_latex()`` is deprecated. The ``sympy_latex()`` and ``set_sympy_latex()`` methods now automatically initialize themselves on first use. + +* Added ``autostdout`` package option and ``\setpythontexautostdout``, to complement ``autoprint``. Added ``prettyprinter`` and ``prettyprintinline`` package options to complement new settings commands. +* Added quickstart guide. +* Installer now installs gallery and quickstart files, if present. + + +v0.11beta (2013/02/17) +---------------------- + +* Commands like ``\py`` can now bring in any valid LaTeX code, including verbatim content, under the pdfTeX and XeTeX engines. Verbatim content was not allowed previously. LuaTeX cannot bring in verbatim, due to a known bug. +* Added package option ``depythontex`` and scripts ``depythontex*.py``. These allow a PythonTeX document to be converted into a pure LaTeX document, with no Python dependency. The package option creates an auxiliary file with extension ``.depytx``. The ``depythontex*.py`` scripts take this auxiliary file and the original LaTeX document, and combine the two to produce a new document that does not rely on the PythonTeX package. All PythonTeX commands and environments are replaced by their output. All Python-generated content is substituted directly into the document. By default, all typeset code is wrapped in ``\verb`` and ``verbatim``, but ``depythontex*.py`` has a ``--listing`` option that allows ``fancyvrb``, ``listings``, ``minted``, or ``pythontex`` to be used instead. +* The current PythonTeX version is now saved in the ``.pytxcode``. If this does not match the version of the PythonTeX scripts, a warning is issued. This makes it easier to determine errors due to version mismatches. +* Fixed an incompatibility with the latest release of ``xstring`` (version 1.7, 2013/01/13). +* Fixed a bug in the ``console`` environment that could cause problems when switching from Pygments highlighting to ``fancyvrb`` when using the ``fvextfile`` option. Fixed a bug introduced in the v0.10beta series that prevented the ``console`` environment from working with ``fancyvrb``. +* Fixed a bug with PythonTeX verbatim commands and environments that use Pygments. The verbatim commands and environments were incorrectly treated as if they had the attributes of executed code in the v0.10beta series. +* Fixed a bug from the v0.10beta series that sometimes prevented imports from ``__future__`` from working when there were multiple sessions. +* Fixed a bug related to hashing dependencies' mtime under Python 3. + + +v0.10beta2 (2013/01/23) +----------------------- + +* Improved ``pythontex*.py``'s handling of the name of the file being processed. A warning is no longer raised if the name is given with an extension; extensions are now processed (stripped) automatically. The filename may now contain a path to the file, so you need not run ``pythontex*.py`` from within the document's directory. +* Added command-line option ``--verbose`` for more verbose output. Currently, this prints a list of all processes that are launched. +* Fixed a bug that could crash ``pythontex*.py`` when the package option ``pygments=false``. +* Added documentation about ``autoprint`` behavior in the preamble. Summary: ``code`` commands and environments are allowed in the preamble as of v0.10beta. ``autoprint`` only applies to the body of the document, because nothing can be typeset in the preamble. Content printed in the preamble can be brought in by explicitly using ``\printpythontex``, but this should be used with great care. +* Revised ``\stdoutpythontex`` and ``\printpythontex`` so that they work in the preamble. Again, this should be used with great care if at all. +* Revised treatment of any content that custom code attempts to print. Custom code is not allowed to print to the document (see documentation). If custom code attempts to print, a warning is raised, and the printed content is included in the ``pythontex*.py`` run summary. +* One-line entries in stderr, such as those produced by Python's ``warnings.warn()``, were not previously parsed because they are of the form ``::`` rather than ``line ``. These are now parsed and synchronized with the document. They are also correctly parsed for inclusion in the document via ``\stderrpythontex``. +* If the package option ``stderrfilename`` is changed, all sessions that produced errors or warnings are now re-executed automatically, so that their stderr content is properly updated with the new filename. + + +v0.10beta (2013/01/09) +---------------------- + +* Backward-incompatible: Redid treatment of command-line options for + ``pythontex*.py``, using Python's ``argparse`` module. Run + ``pythontex*.py`` with option ``-h`` to see new command line options. +* Deprecated: ``\setpythontexcustomcode`` is deprecated in favor of the + ``\pythontexcustomc`` command and ``pythontexcustomcode`` + environment. These allow entry of pure code, unlike + ``\setpythontexcustomcode``. These also allow custom code to be + added to the beginning or end of a session, via an optional argument. + Improved treatment of errors and warnings associated with custom + code. +* The summary of errors and warnings now correctly differentiates + errors and warnings produced by user code, rather than treating all + of them as errors. By default, ``pythontex*.py`` now returns an + exit code of 1 if there were errors. +* The PythonTeX utilities class now allows external file dependencies + to be specified via ``pytex.add_dependencies()``, so that sessions + are automatically re-executed when external dependencies are + modified (modification is determined via either hash or mtime; this + is governed by the new ``hashdependencies`` option). +* The PythonTeX utilities class now allows created files to be + specified via ``pytex.add_created()``, so that created files may be + automatically cleaned up (deleted) when the code that created them + is modified (for example, name change for a saved plot). +* Added the following package options. + + - ``stdout`` (or ``print``): Allows input of stdout to be disabled. + Useful for debugging. + - ``runall``: Executes everything. Useful when code depends on + external data. + - ``rerun``: Determines when code is re-executed. Code may be set + to always run (same as ``runall`` option), or only run when it is + modified or when it produces errors or warnings. By default, + code is always re-executed if there are errors or modifications, + but not re-executed if there are warnings. + - ``hashdependencies``: Determines whether external dependencies + (data, external code files highlighted with Pygments, etc.) are + checked for modification via hashing or modification time. + Modification time is default for performance reasons. + +* Added the following new command line options. The options that are + equivalent to package options are overridden by the package options + when present. + + - ``--error-exit-code``: Determines whether an exit code of 1 is + returned if there were errors. On by default, but can be turned + off since it is undesirable when working with some editors. + - ``--runall``: Equivalent to new package option. + - ``--rerun``: Equivalent to new package option. + - ``--hashdependencies``: Equivalent to new package option. + +* Modified the ``fixlr`` option, so that it only patches commands if + they have not already been patched (avoids package conflicts). +* Added ``\setpythontexautoprint`` command for toggling autoprint + on/off within the body of the document. +* Installer now attempts to create symlinks under OS X and Linux with + TeX Live, and under OS X with MacPorts Tex Live. +* Performed compatibility testing under lualatex and xelatex + (previously, had only tested with pdflatex). Added documentation + for using these TeX engines; at most, slightly different preambles + are needed. Modified the PythonTeX gallery to support all three + engines. +* Code commands and environments may now be used in the preamble. + This, combined with the new treatment of custom code, allows + PythonTeX to be used in creating LaTeX packages. +* Added documentation for using PythonTeX in LaTeX programming. +* Fixed a bug that sometimes caused incorrect line numbers with + ``stderr`` content. Improved processing of stderr. +* Fixed a bug in automatic detection of pre-existing listings + environment. +* Improved the detection of imports from ``__future__``. Detection + should now be stricter, faster, and more accurate. + + +v0.9beta3 (2012/07/17) +---------------------- + +* Added Unicode support, which required the Python code to be split into + one set for Python 2 and another set for Python 3. This will require + any old installation to be completely removed, and a new installation + created from scratch. +* Refactoring of Python code. Documents should automatically re-execute + all code after updating to the new version. Otherwise, you should delete + the PythonTeX directory and run PythonTeX. +* Improved installation script. +* Added package options: ``pyfuture``, ``stderr``, ``upquote``, + ``pyglexer``, ``pyginline``. Renamed the ``pygextfile`` option to + ``fvextfile``. +* Added custom code and workingdir commands. +* Added the ``console`` environment and associated options. +* Rewrote ``pythontex_utils*.py``, creating a new, context-aware interface to + SymPy's LatexPrinter class. +* Content brought in via macros no longer uses labels. Rather, long defs + are used, which allows line breaks. +* Pygments highlighting is now default for PythonTeX commands and environments. + + +v0.9beta2 (2012/05/09) +---------------------- + +* Changed Python output extension to ``.stdout``. + + +v0.9beta (2012/04/27) +--------------------- + +* Initial public beta release. diff --git a/Master/texmf-dist/doc/latex/pythontex/README b/Master/texmf-dist/doc/latex/pythontex/README index 84ae1cff63b..56259936766 100644 --- a/Master/texmf-dist/doc/latex/pythontex/README +++ b/Master/texmf-dist/doc/latex/pythontex/README @@ -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 diff --git a/Master/texmf-dist/doc/latex/pythontex/pythontex.pdf b/Master/texmf-dist/doc/latex/pythontex/pythontex.pdf index 2531310f30e..bd919b5a556 100644 Binary files a/Master/texmf-dist/doc/latex/pythontex/pythontex.pdf and b/Master/texmf-dist/doc/latex/pythontex/pythontex.pdf differ diff --git a/Master/texmf-dist/doc/latex/pythontex/pythontex_gallery.pdf b/Master/texmf-dist/doc/latex/pythontex/pythontex_gallery.pdf index 245ffd5cc08..41f7c982d44 100644 Binary files a/Master/texmf-dist/doc/latex/pythontex/pythontex_gallery.pdf and b/Master/texmf-dist/doc/latex/pythontex/pythontex_gallery.pdf differ diff --git a/Master/texmf-dist/scripts/pythontex/depythontex.py b/Master/texmf-dist/scripts/pythontex/depythontex.py index 30256c6d1c3..3d48e3b1daa 100755 --- a/Master/texmf-dist/scripts/pythontex/depythontex.py +++ b/Master/texmf-dist/scripts/pythontex/depythontex.py @@ -9,7 +9,7 @@ on your system. If you wish to use a different version of Python, you could 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 diff --git a/Master/texmf-dist/scripts/pythontex/depythontex2.py b/Master/texmf-dist/scripts/pythontex/depythontex2.py index 0975b9b8ca4..7687e0e7244 100755 --- a/Master/texmf-dist/scripts/pythontex/depythontex2.py +++ b/Master/texmf-dist/scripts/pythontex/depythontex2.py @@ -47,7 +47,7 @@ example, typeset code may have a different appearance or layout when it is 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 @@ -86,7 +86,7 @@ import codecs # Script parameters # Version -__version__ = '0.15' +__version__ = '0.16' # Functions and parameters for customizing the script output diff --git a/Master/texmf-dist/scripts/pythontex/depythontex3.py b/Master/texmf-dist/scripts/pythontex/depythontex3.py index 567363eeaa0..bdcea2185e0 100755 --- a/Master/texmf-dist/scripts/pythontex/depythontex3.py +++ b/Master/texmf-dist/scripts/pythontex/depythontex3.py @@ -47,7 +47,7 @@ example, typeset code may have a different appearance or layout when it is 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 @@ -86,7 +86,7 @@ import codecs # Script parameters # Version -__version__ = '0.15' +__version__ = '0.16' # Functions and parameters for customizing the script output diff --git a/Master/texmf-dist/scripts/pythontex/pythontex.py b/Master/texmf-dist/scripts/pythontex/pythontex.py index 0c6e5c70bb1..2fe6de902a2 100755 --- a/Master/texmf-dist/scripts/pythontex/pythontex.py +++ b/Master/texmf-dist/scripts/pythontex/pythontex.py @@ -16,7 +16,7 @@ under which your code is actually executed. Licensed under the BSD 3-Clause License: -Copyright (c) 2012-2016, Geoffrey M. Poore +Copyright (c) 2012-2017, Geoffrey M. Poore All rights reserved. diff --git a/Master/texmf-dist/scripts/pythontex/pythontex2.py b/Master/texmf-dist/scripts/pythontex/pythontex2.py index 519b36f3066..871d394e375 100755 --- a/Master/texmf-dist/scripts/pythontex/pythontex2.py +++ b/Master/texmf-dist/scripts/pythontex/pythontex2.py @@ -13,7 +13,7 @@ should be in the same directory. Licensed under the BSD 3-Clause License: -Copyright (c) 2012-2016, Geoffrey M. Poore +Copyright (c) 2012-2017, Geoffrey M. Poore All rights reserved. @@ -77,7 +77,7 @@ else: # Script parameters # Version -__version__ = '0.15' +__version__ = '0.16' @@ -1286,7 +1286,8 @@ def do_multiprocessing(data, temp_data, old_data, engine_dict): engine_dict[family].warnings, engine_dict[family].linenumbers, engine_dict[family].lookbehind, - keeptemps, hashdependencies)''' + keeptemps, hashdependencies, + pygments_settings)''' tasks.append(pool.apply_async(run_code, [encoding, outputdir, workingdir, code_dict[key], engine_dict[family].language, @@ -1299,7 +1300,8 @@ def do_multiprocessing(data, temp_data, old_data, engine_dict): engine_dict[family].warnings, engine_dict[family].linenumbers, engine_dict[family].lookbehind, - keeptemps, hashdependencies])) + keeptemps, hashdependencies, + pygments_settings])) if verbose: print(' - Code process ' + key.replace('#', ':')) @@ -1475,7 +1477,7 @@ def do_multiprocessing(data, temp_data, old_data, engine_dict): def run_code(encoding, outputdir, workingdir, code_list, language, commands, command_created, extension, makestderr, stderrfilename, code_index, errorsig, warningsig, linesig, stderrlookbehind, - keeptemps, hashdependencies): + keeptemps, hashdependencies, pygments_settings): ''' Function for multiprocessing code files ''' @@ -1526,7 +1528,10 @@ def run_code(encoding, outputdir, workingdir, code_list, language, commands, exec_cmd = shlex.split(bytes(command.format(file=script.replace('\\', '\\\\'), File=script_full.replace('\\', '\\\\'), workingdir=workingdir.replace('\\', '\\\\')))) exec_cmd = [unicode(elem) for elem in exec_cmd] else: - exec_cmd = shlex.split(command.format(file=script.replace('\\', '\\\\'), File=script_full.replace('\\', '\\\\'), workingdir=workingdir.replace('\\', '\\\\'))) + if family != 'juliacon': + exec_cmd = shlex.split(command.format(file=script.replace('\\', '\\\\'), File=script_full.replace('\\', '\\\\'), workingdir=workingdir.replace('\\', '\\\\'))) + else: + exec_cmd = shlex.split(command.format(file=script.replace('\\', '/'), File=script_full.replace('\\', '/'), workingdir=workingdir.replace('\\', '/'))) # Add any created files due to the command # This needs to be done before attempts to execute, to prevent orphans try: @@ -1563,6 +1568,22 @@ def run_code(encoding, outputdir, workingdir, code_list, language, commands, messages.append(' Missing output file for ' + key_run.replace('#', ':')) errors += 1 else: + if family == 'juliacon': + with open(out_file_name.rsplit('.', 1)[0] + '.tex', 'r', encoding=encoding) as f: + tex_data_lines = f.readlines() + inst = 0 + for n, line in enumerate(tex_data_lines): + if line.rstrip() == '\\begin{juliaterm}': + tex_data_lines[n] = '=>PYTHONTEX:STDOUT#{0}#code#\n'.format(inst) + inst += 1 + if n != 0: + tex_data_lines[n-1] = '' + if line.rstrip() == '\\end{juliaterm}': + tex_data_lines[n] = '' + tex_data_lines.append('=>PYTHONTEX:DEPENDENCIES#\n=>PYTHONTEX:CREATED#\n') + with open(out_file_name, 'w', encoding=encoding) as f: + f.write(''.join(tex_data_lines)) + f = open(out_file_name, 'r', encoding=encoding) out = f.read() f.close() @@ -1619,6 +1640,18 @@ def run_code(encoding, outputdir, workingdir, code_list, language, commands, else: dependencies[dep] = (os.path.getmtime(dep_file), '') + if family == 'juliacon': + from pygments import highlight + from pygments.lexers import get_lexer_by_name + from pygments.formatters import LatexFormatter + formatter = dict() + lexer = dict() + for codetype in pygments_settings: + if codetype != ':GLOBAL': + p = pygments_settings[codetype]['formatter_options'].copy() + p['commandprefix'] = 'PYG' + formatter[codetype] = LatexFormatter(**p) + lexer[codetype] = get_lexer_by_name(pygments_settings[codetype]['lexer'], **p) for block in out.split('=>PYTHONTEX:STDOUT#')[1:]: if block: delims, content = block.split('#\n', 1) @@ -1649,6 +1682,8 @@ def run_code(encoding, outputdir, workingdir, code_list, language, commands, # Remove newline added by printing, prevent # LaTeX from adding a space after content content = content.rsplit('\n', 1)[0] + '\\endinput\n' + if family == 'juliacon': + content = highlight(content, lexer[family], formatter[family]) f.write(content) f.close() files.append(fname) @@ -1658,6 +1693,8 @@ def run_code(encoding, outputdir, workingdir, code_list, language, commands, messages.append('* PythonTeX error') messages.append(' Missing stderr file for ' + key_run.replace('#', ':')) errors += 1 + elif family == 'juliacon': + pass else: # Open error and code files. f = open(err_file_name, encoding=encoding) @@ -2408,7 +2445,10 @@ def python_console(jobname, encoding, outputdir, workingdir, fvextfile, sys.excepthook = sys.__excepthook__ old_stdout = sys.stdout sys.stdout = self.iostdout - self.interact(self.banner) + if sys.version_info.major == 3 and sys.version_info.minor >= 6: + self.interact(self.banner, exitmsg='') + else: + self.interact(self.banner) sys.stdout = old_stdout self.session_log = self.iostdout.getvalue() diff --git a/Master/texmf-dist/scripts/pythontex/pythontex3.py b/Master/texmf-dist/scripts/pythontex/pythontex3.py index b872dbaa2c4..cb96f97d336 100755 --- a/Master/texmf-dist/scripts/pythontex/pythontex3.py +++ b/Master/texmf-dist/scripts/pythontex/pythontex3.py @@ -13,7 +13,7 @@ should be in the same directory. Licensed under the BSD 3-Clause License: -Copyright (c) 2012-2016, Geoffrey M. Poore +Copyright (c) 2012-2017, Geoffrey M. Poore All rights reserved. @@ -77,7 +77,7 @@ else: # Script parameters # Version -__version__ = '0.15' +__version__ = '0.16' @@ -1286,7 +1286,8 @@ def do_multiprocessing(data, temp_data, old_data, engine_dict): engine_dict[family].warnings, engine_dict[family].linenumbers, engine_dict[family].lookbehind, - keeptemps, hashdependencies)''' + keeptemps, hashdependencies, + pygments_settings)''' tasks.append(pool.apply_async(run_code, [encoding, outputdir, workingdir, code_dict[key], engine_dict[family].language, @@ -1299,7 +1300,8 @@ def do_multiprocessing(data, temp_data, old_data, engine_dict): engine_dict[family].warnings, engine_dict[family].linenumbers, engine_dict[family].lookbehind, - keeptemps, hashdependencies])) + keeptemps, hashdependencies, + pygments_settings])) if verbose: print(' - Code process ' + key.replace('#', ':')) @@ -1475,7 +1477,7 @@ def do_multiprocessing(data, temp_data, old_data, engine_dict): def run_code(encoding, outputdir, workingdir, code_list, language, commands, command_created, extension, makestderr, stderrfilename, code_index, errorsig, warningsig, linesig, stderrlookbehind, - keeptemps, hashdependencies): + keeptemps, hashdependencies, pygments_settings): ''' Function for multiprocessing code files ''' @@ -1526,7 +1528,10 @@ def run_code(encoding, outputdir, workingdir, code_list, language, commands, exec_cmd = shlex.split(bytes(command.format(file=script.replace('\\', '\\\\'), File=script_full.replace('\\', '\\\\'), workingdir=workingdir.replace('\\', '\\\\')))) exec_cmd = [unicode(elem) for elem in exec_cmd] else: - exec_cmd = shlex.split(command.format(file=script.replace('\\', '\\\\'), File=script_full.replace('\\', '\\\\'), workingdir=workingdir.replace('\\', '\\\\'))) + if family != 'juliacon': + exec_cmd = shlex.split(command.format(file=script.replace('\\', '\\\\'), File=script_full.replace('\\', '\\\\'), workingdir=workingdir.replace('\\', '\\\\'))) + else: + exec_cmd = shlex.split(command.format(file=script.replace('\\', '/'), File=script_full.replace('\\', '/'), workingdir=workingdir.replace('\\', '/'))) # Add any created files due to the command # This needs to be done before attempts to execute, to prevent orphans try: @@ -1563,6 +1568,22 @@ def run_code(encoding, outputdir, workingdir, code_list, language, commands, messages.append(' Missing output file for ' + key_run.replace('#', ':')) errors += 1 else: + if family == 'juliacon': + with open(out_file_name.rsplit('.', 1)[0] + '.tex', 'r', encoding=encoding) as f: + tex_data_lines = f.readlines() + inst = 0 + for n, line in enumerate(tex_data_lines): + if line.rstrip() == '\\begin{juliaterm}': + tex_data_lines[n] = '=>PYTHONTEX:STDOUT#{0}#code#\n'.format(inst) + inst += 1 + if n != 0: + tex_data_lines[n-1] = '' + if line.rstrip() == '\\end{juliaterm}': + tex_data_lines[n] = '' + tex_data_lines.append('=>PYTHONTEX:DEPENDENCIES#\n=>PYTHONTEX:CREATED#\n') + with open(out_file_name, 'w', encoding=encoding) as f: + f.write(''.join(tex_data_lines)) + f = open(out_file_name, 'r', encoding=encoding) out = f.read() f.close() @@ -1619,6 +1640,18 @@ def run_code(encoding, outputdir, workingdir, code_list, language, commands, else: dependencies[dep] = (os.path.getmtime(dep_file), '') + if family == 'juliacon': + from pygments import highlight + from pygments.lexers import get_lexer_by_name + from pygments.formatters import LatexFormatter + formatter = dict() + lexer = dict() + for codetype in pygments_settings: + if codetype != ':GLOBAL': + p = pygments_settings[codetype]['formatter_options'].copy() + p['commandprefix'] = 'PYG' + formatter[codetype] = LatexFormatter(**p) + lexer[codetype] = get_lexer_by_name(pygments_settings[codetype]['lexer'], **p) for block in out.split('=>PYTHONTEX:STDOUT#')[1:]: if block: delims, content = block.split('#\n', 1) @@ -1649,6 +1682,8 @@ def run_code(encoding, outputdir, workingdir, code_list, language, commands, # Remove newline added by printing, prevent # LaTeX from adding a space after content content = content.rsplit('\n', 1)[0] + '\\endinput\n' + if family == 'juliacon': + content = highlight(content, lexer[family], formatter[family]) f.write(content) f.close() files.append(fname) @@ -1658,6 +1693,8 @@ def run_code(encoding, outputdir, workingdir, code_list, language, commands, messages.append('* PythonTeX error') messages.append(' Missing stderr file for ' + key_run.replace('#', ':')) errors += 1 + elif family == 'juliacon': + pass else: # Open error and code files. f = open(err_file_name, encoding=encoding) @@ -2408,7 +2445,10 @@ def python_console(jobname, encoding, outputdir, workingdir, fvextfile, sys.excepthook = sys.__excepthook__ old_stdout = sys.stdout sys.stdout = self.iostdout - self.interact(self.banner) + if sys.version_info.major == 3 and sys.version_info.minor >= 6: + self.interact(self.banner, exitmsg='') + else: + self.interact(self.banner) sys.stdout = old_stdout self.session_log = self.iostdout.getvalue() diff --git a/Master/texmf-dist/scripts/pythontex/pythontex_2to3.py b/Master/texmf-dist/scripts/pythontex/pythontex_2to3.py index 166e6784676..442309c86b1 100755 --- a/Master/texmf-dist/scripts/pythontex/pythontex_2to3.py +++ b/Master/texmf-dist/scripts/pythontex/pythontex_2to3.py @@ -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 @@ -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 @@ -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()) diff --git a/Master/texmf-dist/scripts/pythontex/pythontex_engines.py b/Master/texmf-dist/scripts/pythontex/pythontex_engines.py index 6bcbd1690db..38fea5efc43 100755 --- a/Master/texmf-dist/scripts/pythontex/pythontex_engines.py +++ b/Master/texmf-dist/scripts/pythontex/pythontex_engines.py @@ -17,7 +17,7 @@ document (script for execution). -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 @@ -1113,6 +1113,12 @@ CodeEngine('julia', 'julia', '.jl', '{julia} "{file}.jl"', julia_template, SubCodeEngine('julia', 'jl') +CodeEngine('juliacon', 'julia', '.jl', '{julia} -e "using Weave; weave(\\"{File}.jl\\", \\"tex\\")"', '{body}\n', + '#+ term=true\n{code}\n', '', '', + 'ERROR:', 'WARNING:', ':{number}', True, created='{File}.tex') + + + octave_template = ''' @@ -1285,42 +1291,133 @@ CodeEngine('bash', 'bash', '.sh', rust_template = ''' // -*- coding: utf-8 -*- - #![allow(dead_code)] - #![allow(unused_imports)] - - + #![allow(dead_code, unused_imports)] + #[warn(unused_imports)] mod rust_tex_utils {{ - use std::fmt; - use std::collections; - use std::io::prelude::*; - - pub struct RustTeXUtils {{ - _formatter: Box String>, - _before: Box, - _after: Box, - pub family: &'static str, - pub session: &'static str, - pub restart: &'static str, - pub dependencies: Vec, - pub created: Vec, - pub command: &'static str, - pub context: collections::HashMap<&'static str, &'static str>, - pub args: collections::HashMap<&'static str, &'static str>, - pub instance: &'static str, - pub line: &'static str, + use std::{{borrow, collections, fmt, fs, io, iter, ops, path}}; + use self::OpenMode::{{ReadMode, WriteMode, AppendMode, TruncateMode, CreateMode, CreateNewMode}}; + pub struct UserAction<'u> {{ + _act: Box }} - - impl RustTeXUtils {{ + impl<'u> UserAction<'u> {{ + pub fn new() -> Self {{ + Self::from(|| {{}}) + }} + pub fn act(&mut self) {{ + (self._act)(); + }} + pub fn set(&mut self, f: F) {{ + self._act = Box::new(f); + }} + }} + impl<'u> Default for UserAction<'u> {{ + fn default() -> Self {{ + Self::new() + }} + }} + impl<'u, F: FnMut() + 'u> From for UserAction<'u> {{ + fn from(f: F) -> Self {{ + UserAction {{ _act: Box::new(f) }} + }} + }} + impl<'u, U: Into> + 'u> ops::Add for UserAction<'u> {{ + type Output = UserAction<'u>; + fn add(self, f: U) -> Self::Output {{ + let mut self_act: Box = self._act; + let mut other_act: Box = f.into()._act; + Self::from(move || {{ self_act.as_mut()(); other_act.as_mut()(); }}) + }} + }} + impl<'u, F: Into> + 'u> iter::FromIterator for UserAction<'u> {{ + fn from_iter(iter: T) -> Self where T: IntoIterator {{ + let mut others: Vec = iter.into_iter().map(F::into).collect(); + Self::from(move || {{ for other in others.iter_mut() {{ other.act(); }} }}) + }} + }} + impl<'u> ops::Deref for UserAction<'u> {{ + type Target = FnMut() + 'u; + fn deref(&self) -> &Self::Target {{ + &*self._act + }} + }} + impl<'u> ops::DerefMut for UserAction<'u> {{ + fn deref_mut(&mut self) -> &mut Self::Target {{ + &mut *self._act + }} + }} + pub struct RustTeXUtils<'u> {{ + _formatter: Box String + 'u>, + pub before: UserAction<'u>, + pub after: UserAction<'u>, + pub family: &'u str, + pub session: &'u str, + pub restart: &'u str, + pub dependencies: collections::HashSet>, + pub created: collections::HashSet>, + pub command: &'u str, + pub context: collections::HashMap<&'u str, borrow::Cow<'u, str>>, + pub args: collections::HashMap<&'u str, borrow::Cow<'u, str>>, + pub instance: &'u str, + pub line: &'u str, + }} + #[derive(Clone,Copy,Debug,Hash,PartialEq,Eq)] + pub enum OpenMode {{ + /// Open the file for reading + ReadMode, + /// Open the file for writing + WriteMode, + /// Open the file for appending + AppendMode, + /// Truncate the file before opening + TruncateMode, + /// Create the file before opening if necessary + CreateMode, + /// Always create the file before opening + CreateNewMode, + }} + pub mod open_mode {{ + pub use super::OpenMode::{{self, ReadMode, WriteMode, AppendMode, TruncateMode, CreateMode, CreateNewMode}}; + pub const R: &'static [OpenMode] = &[ReadMode]; + pub const W: &'static [OpenMode] = &[WriteMode]; + pub const A: &'static [OpenMode] = &[AppendMode]; + pub const WC: &'static [OpenMode] = &[WriteMode, CreateMode]; + pub const CW: &'static [OpenMode] = WC; + pub const AC: &'static [OpenMode] = &[AppendMode, CreateMode]; + pub const CA: &'static [OpenMode] = AC; + pub const WT: &'static [OpenMode] = &[WriteMode, TruncateMode]; + pub const TW: &'static [OpenMode] = WT; + pub const WCT: &'static [OpenMode] = &[WriteMode, CreateMode, TruncateMode]; + pub const WTC: &'static [OpenMode] = WCT; + pub const CWT: &'static [OpenMode] = WCT; + pub const CTW: &'static [OpenMode] = WCT; + pub const TWC: &'static [OpenMode] = WCT; + pub const TCW: &'static [OpenMode] = WCT; + pub const WN: &'static [OpenMode] = &[WriteMode, CreateNewMode]; + pub const NW: &'static [OpenMode] = WN; + pub const AN: &'static [OpenMode] = &[AppendMode, CreateNewMode]; + pub const NA: &'static [OpenMode] = AN; + }} + impl OpenMode {{ + /// The same options as `fs::File::open`. + pub fn open() -> &'static [OpenMode] {{ + open_mode::R + }} + /// The same options as `fs::File::create`. + pub fn create() -> &'static [OpenMode] {{ + open_mode::WCT + }} + }} + impl<'u> RustTeXUtils<'u> {{ pub fn new() -> Self {{ RustTeXUtils {{ _formatter: Box::new(|x: &fmt::Display| format!("{{}}", x)), - _before: Box::new(|| {{}}), - _after: Box::new(|| {{}}), + before: UserAction::new(), + after: UserAction::new(), family: "{family}", session: "{session}", restart: "{restart}", - dependencies: Vec::new(), - created: Vec::new(), + dependencies: collections::HashSet::new(), + created: collections::HashSet::new(), command: "", context: collections::HashMap::new(), args: collections::HashMap::new(), @@ -1328,53 +1425,69 @@ rust_template = ''' line: "", }} }} - - pub fn formatter(&mut self, x: A) -> String {{ - (*self._formatter)(&x) + (self._formatter)(&x) }} - pub fn set_formatter String + 'static>(&mut self, f: F) {{ + pub fn set_formatter String + 'u>(&mut self, f: F) {{ self._formatter = Box::new(f); }} - - pub fn before(&mut self) {{ - (*self._before)(); - }} - pub fn set_before(&mut self, f: F) {{ - self._before = Box::new(f); + pub fn add_dependencies(&mut self, deps: SS) + where SS::Item: Into> + {{ + self.dependencies.extend(deps.into_iter().map(SS::Item::into)); }} - - pub fn after(&mut self) {{ - (*self._after)(); - }} - pub fn set_after(&mut self, f: F) {{ - self._after = Box::new(f); - }} - - pub fn add_dependencies(&mut self, deps: SS) where SS::Item: Into {{ - self.dependencies.append(&mut deps.into_iter().map(|x| x.into()).collect()); + pub fn add_created(&mut self, crts: SS) + where SS::Item: Into> + {{ + self.created.extend(crts.into_iter().map(SS::Item::into)); }} - - pub fn add_created(&mut self, crts: SS) where SS::Item: Into {{ - self.created.append(&mut crts.into_iter().map(|x| x.into()).collect()); + pub fn open(&mut self, name: P, options: O) -> io::Result + where P: AsRef, + O: IntoIterator, + O::Item: borrow::Borrow + {{ + let opts = options.into_iter() + .map(|x| *>::borrow(&x)) + .collect::>(); + let mut options = fs::OpenOptions::new(); + if opts.contains(&ReadMode) {{ + options.read(true); + self.add_dependencies(iter::once(name.as_ref().to_owned())); + }} + if opts.contains(&WriteMode) {{ + options.write(true); + }} + if opts.contains(&AppendMode) {{ + options.append(true); + }} + if opts.contains(&TruncateMode) {{ + options.truncate(true); + }} + if opts.contains(&CreateMode) {{ + options.create(true); + self.add_created(iter::once(name.as_ref().to_owned())); + }} + if opts.contains(&CreateNewMode) {{ + options.create_new(true); + self.add_created(iter::once(name.as_ref().to_owned())); + }} + options.open(name) }} - pub fn cleanup(self) {{ println!("{{}}", "{dependencies_delim}"); for x in self.dependencies {{ - println!("{{}}", x); + println!("{{}}", x.to_str().expect(&format!("could not properly display path ({{:?}})", x))); }} println!("{{}}", "{created_delim}"); for x in self.created {{ - println!("{{}}", x); + println!("{{}}", x.to_str().expect(&format!("could not properly display path ({{:?}})", x))); }} }} - - pub fn setup_wrapper(&mut self, cmd: &'static str, cxt: &'static str, ags: &'static str, ist: &'static str, lne: &'static str) {{ - fn parse_map(kvs: &'static str) -> collections::HashMap<&'static str, &'static str> {{ + pub fn setup_wrapper(&mut self, cmd: &'u str, cxt: &'u str, ags: &'u str, ist: &'u str, lne: &'u str) {{ + fn parse_map<'w>(kvs: &'w str) -> collections::HashMap<&'w str, borrow::Cow<'w, str>> {{ kvs.split(',').filter(|s| !s.is_empty()).map(|kv| {{ let (k, v) = kv.split_at(kv.find('=').expect(&format!("Error parsing supposed key-value pair ({{}})", kv))); - (k.trim(), v[1..].trim()) + (k.trim(), v[1..].trim().into()) }}).collect() }} self.command = cmd; @@ -1384,24 +1497,23 @@ rust_template = ''' self.line = lne; }} }} + impl<'u> Default for RustTeXUtils<'u> {{ + fn default() -> Self {{ + Self::new() + }} + }} }} - - - use std::{{io, fmt, env, path, ffi, collections}}; + use std::{{borrow, collections, env, ffi, fmt, fs, hash, io, iter, ops, path}}; use std::io::prelude::*; - - + use rust_tex_utils::open_mode; #[allow(unused_mut)] fn main() {{ let mut rstex = rust_tex_utils::RustTeXUtils::new(); if env::set_current_dir(ffi::OsString::from("{workingdir}".to_string())).is_err() && env::args().all(|x| x != "--manual") {{ panic!("Could not change to the specified working directory ({workingdir})"); }} - {extend} - {body} - rstex.cleanup(); }} ''' @@ -1410,20 +1522,21 @@ rust_wrapper = ''' rstex.setup_wrapper("{command}", "{context}", "{args}", "{instance}", "{line}"); println!("{stdoutdelim}"); writeln!(io::stderr(), "{stderrdelim}").unwrap(); - rstex.before(); - + rstex.before.act(); {code} - - rstex.after(); + rstex.after.act(); ''' -rust_sub = '''println!("{field_delim}");\nprintln!("{{}}", {field});\n''' +rust_sub = ''' + println!("{field_delim}"); + println!("{{}}", {field}); + ''' CodeEngine('rust', 'rust', '.rs', # The full script name has to be used in order to make Windows and Unix behave nicely # together when naming executables. Despite appearances, using `.exe` works on Unix too. ['{rustc} --crate-type bin -o {File}.exe -L {workingdir} {file}.rs', '{File}.exe'], - rust_template, rust_wrapper, 'println!("{{}}", rstex.formatter({code}));', rust_sub, + rust_template, rust_wrapper, '{{ let val = {{ {code} }}; println!("{{}}", rstex.formatter(val)); }}', rust_sub, errors='error:', warnings='warning:', linenumbers='.rs:{number}', created='{File}.exe') diff --git a/Master/texmf-dist/source/latex/pythontex/pythontex.dtx b/Master/texmf-dist/source/latex/pythontex/pythontex.dtx index 7ec0af93c78..d91e6e1eac0 100644 --- a/Master/texmf-dist/source/latex/pythontex/pythontex.dtx +++ b/Master/texmf-dist/source/latex/pythontex/pythontex.dtx @@ -1,6 +1,6 @@ % \iffalse meta-comment % -% Copyright (C) 2012-2016 by Geoffrey M. Poore +% Copyright (C) 2012-2017 by Geoffrey M. Poore % --------------------------------------------------------------------------- % This work may be distributed and/or modified under the % conditions of the LaTeX Project Public License, either version 1.3 @@ -26,7 +26,7 @@ %\NeedsTeXFormat{LaTeX2e}[1999/12/01] %\ProvidesPackage{pythontex} %<*package> - [2016/07/21 v0.15 execute and typeset Python code and other languages] + [2017/07/20 v0.16 execute and typeset Python code and other languages] % % %<*driver> @@ -134,7 +134,7 @@ % % \fi % -% \CheckSum{3174} +% \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 @@ -153,6 +153,16 @@ % Right brace \} Tilde \~} % % + +% \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 Improved Rust support, including tracking of created files and dependencies (\#91). +% \end{itemize} +% \end{changelog} +% +% % \begin{changelog}{v0.15}{2016/07/21} % \textbf{New features} % \begin{itemize} @@ -1537,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} % @@ -1566,7 +1580,11 @@ % % Because Rust typically gives a long sequence of errors, \pytex\ processing and synchronization of |stderr| is currently verbose and may need to be improved in the future as well. There is no support for encodings other than UTF-8. Currently, executables always use the |.exe| extension, even under non-Windows systems. % -% When using |\rust| and |\rs|, keep in mind that these wrap code in |rstex.formatter()|. Because |rstex| is mutable, accessing its fields within |rstex.formatter()| will require |&rstex.|\meta{field}|.to_string()| or similar. +% Due to the way |rstex| is used in template-generated code, it needs to remain a mutable local variable. This means that, while there should be no problem using it through either shared or mutable references, taking it by value requires that the ``altered'' copy is reassigned to a new variable that shadows the old one. That is, code that needs to work with |rstex| by value should look like +% \begin{Verbatim}[commandchars=\\\{\}, gobble=2] +% let mut rstex = \meta{code}; +% \end{Verbatim} +% Additionally, when using |\rust| and |\rs|, keep in mind that these wrap code in a block, so you \emph{cannot} use |rstex| by value in these contexts (both shared and mutable references are still fine, though). % % % \subsection{Adding support for a new language} @@ -1795,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.15} +\newcommand{\pytx@packageversion}{0.16} % \end{macrocode} % % \subsection{Required packages} @@ -4063,6 +4081,24 @@ \ifstrequal{#1}{ruby}{\makepythontexfamily[pyglexer=ruby]{ruby}}{}% \ifstrequal{#1}{rb}{\makepythontexfamily[pyglexer=ruby]{rb}}{}% \ifstrequal{#1}{julia}{\makepythontexfamily[pyglexer=julia]{julia}}{}% + \ifstrequal{#1}{juliacon}{\pgfkeys{/PYTX/family, name=juliacon, default, pyglexer=jlcon}% + \expandafter\xdef\csname pytx@macroformatter@juliacon\endcsname{\pytx@tmp@pprinter}% + \expandafter\gdef\csname pytx@fvsettings@juliacon\endcsname{}% + \expandafter\xdef\csname pytx@pyglexer@juliacon\endcsname{\pytx@tmp@pyglexer}% + \expandafter\xdef\csname pytx@pygopt@juliacon\endcsname{\pytx@tmp@pygopt}% + \expandafter\xdef\csname pytx@console@juliacon\endcsname{\pytx@tmp@console}% + \AtEndDocument{\immediate\write\pytx@codefile{pygfamily=juliacon|% + \csname pytx@pyglexer@juliacon\endcsname|% + \csname pytx@pygopt@juliacon\endcsname}% + }% + \pytx@MakeCodeFV{juliacon}% + \newenvironment{juliaconsole}% + {\VerbatimEnvironment + \def\pytx@type{juliacon}% + \pytx@ConfigPygments + \begin{juliaconcode}}% + {\end{juliaconcode}% + \ifbool{pytx@opt@autoprint}{}{\printpythontex{}}}}{}% \ifstrequal{#1}{jl}{\makepythontexfamily[pyglexer=julia]{jl}}{}% \ifstrequal{#1}{matlab}{\makepythontexfamily[pyglexer=matlab]{matlab}}{}% \ifstrequal{#1}{octave}{\makepythontexfamily[pyglexer=octave]{octave}}{}% diff --git a/Master/texmf-dist/tex/latex/pythontex/pythontex.sty b/Master/texmf-dist/tex/latex/pythontex/pythontex.sty index 8331043359b..1300db470fc 100644 --- a/Master/texmf-dist/tex/latex/pythontex/pythontex.sty +++ b/Master/texmf-dist/tex/latex/pythontex/pythontex.sty @@ -20,10 +20,11 @@ %% \NeedsTeXFormat{LaTeX2e}[1999/12/01] \ProvidesPackage{pythontex} - [2016/07/21 v0.15 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.15} +\newcommand{\pytx@packageversion}{0.16} \RequirePackage{fvextra} \RequirePackage{etoolbox} \RequirePackage{xstring} @@ -1317,6 +1318,24 @@ \ifstrequal{#1}{ruby}{\makepythontexfamily[pyglexer=ruby]{ruby}}{}% \ifstrequal{#1}{rb}{\makepythontexfamily[pyglexer=ruby]{rb}}{}% \ifstrequal{#1}{julia}{\makepythontexfamily[pyglexer=julia]{julia}}{}% + \ifstrequal{#1}{juliacon}{\pgfkeys{/PYTX/family, name=juliacon, default, pyglexer=jlcon}% + \expandafter\xdef\csname pytx@macroformatter@juliacon\endcsname{\pytx@tmp@pprinter}% + \expandafter\gdef\csname pytx@fvsettings@juliacon\endcsname{}% + \expandafter\xdef\csname pytx@pyglexer@juliacon\endcsname{\pytx@tmp@pyglexer}% + \expandafter\xdef\csname pytx@pygopt@juliacon\endcsname{\pytx@tmp@pygopt}% + \expandafter\xdef\csname pytx@console@juliacon\endcsname{\pytx@tmp@console}% + \AtEndDocument{\immediate\write\pytx@codefile{pygfamily=juliacon|% + \csname pytx@pyglexer@juliacon\endcsname|% + \csname pytx@pygopt@juliacon\endcsname}% + }% + \pytx@MakeCodeFV{juliacon}% + \newenvironment{juliaconsole}% + {\VerbatimEnvironment + \def\pytx@type{juliacon}% + \pytx@ConfigPygments + \begin{juliaconcode}}% + {\end{juliaconcode}% + \ifbool{pytx@opt@autoprint}{}{\printpythontex{}}}}{}% \ifstrequal{#1}{jl}{\makepythontexfamily[pyglexer=julia]{jl}}{}% \ifstrequal{#1}{matlab}{\makepythontexfamily[pyglexer=matlab]{matlab}}{}% \ifstrequal{#1}{octave}{\makepythontexfamily[pyglexer=octave]{octave}}{}% diff --git a/Master/tlpkg/bin/tlpkg-ctan-check b/Master/tlpkg/bin/tlpkg-ctan-check index 26412f3a4a4..6590c211901 100755 --- a/Master/tlpkg/bin/tlpkg-ctan-check +++ b/Master/tlpkg/bin/tlpkg-ctan-check @@ -744,6 +744,7 @@ my @TLP_no_check = ( "lcdftypetools", # binary "luatex", # binary "makeindex", # binary + "malayalam-latex", # binary "metafont", # binary "metapost", # binary "mex", # gust, requested 2013 diff --git a/Master/tlpkg/libexec/ctan2tds b/Master/tlpkg/libexec/ctan2tds index e198c214469..da1ccac4ecc 100755 --- a/Master/tlpkg/libexec/ctan2tds +++ b/Master/tlpkg/libexec/ctan2tds @@ -135,6 +135,7 @@ chomp ($Build = `cd $Master/../Build/source && pwd`); 'aurora', "die 'skipping, nocommercial license'", 'auto1', "die 'skipping, nonfree font support'", 'autolatex', "die 'skipping, not self-locating'", + 'autosp', "die 'skipping, awaiting tl18!'", 'autotab', "die 'skipping, noinfo license, latex 2.09'", 'babel-frenchb', "die 'skipping, use babel-french'", 'babel-serbianc', "&MAKEflatten", @@ -763,6 +764,7 @@ chomp ($Build = `cd $Master/../Build/source && pwd`); 'mpdinbrief', "die 'skipping, nosell license'", 'mptopdf', "&MAKEcopy", 'msuthesis', "die 'skipping, use msu-thesis'", + 'msu-thesis', "die 'skipping, awaiting next package release'", 'mtp2lite', "die 'skipping, nonfree'", 'mtx', "die 'skipping, pascal musixtex binaries'", 'multibox', "die 'skipping, noinfo license, author deceased'", -- cgit v1.2.3