From e8ac6085104bed4bcc0b3f56e830fa806f034def Mon Sep 17 00:00:00 2001 From: Volker Braun Date: Sat, 28 Feb 2015 15:12:47 +0100 Subject: [PATCH 1/5] Initial version of the TeXlive install script --- src/ext/texlive/SPKG.txt | 33 ++++++++ src/ext/texlive/package-list.txt | 42 ++++++++++ src/ext/texlive/texlive-install | 127 +++++++++++++++++++++++++++++++ 3 files changed, 202 insertions(+) create mode 100644 src/ext/texlive/SPKG.txt create mode 100644 src/ext/texlive/package-list.txt create mode 100755 src/ext/texlive/texlive-install diff --git a/src/ext/texlive/SPKG.txt b/src/ext/texlive/SPKG.txt new file mode 100644 index 00000000000..52ddc9aec9b --- /dev/null +++ b/src/ext/texlive/SPKG.txt @@ -0,0 +1,33 @@ += TeXlive = + +== Description == + +TeX Live is an easy way to get up and running with the TeX document +production system. It provides a comprehensive TeX system with +binaries for most flavors of Unix, including GNU/Linux, and also +Windows. It includes all the major TeX-related programs, macro +packages, and fonts that are free software, including support for many +languages around the world. + +This package installs all texlive packages requried to build Sage. If +necessary, texlive itself is installed. + +== License == + +Various FSF-approved free software licenses. See +https://www.tug.org/texlive/copying.html for details. + +== Upstream Contact == + +Hoem page: https://www.tug.org/texlive + +== Dependencies == + +Put a bulleted list of dependencies here: + +* python + +== Special Update/Build Instructions == + +This package requires internet access to download texlive packages for +the TeX mirrors. diff --git a/src/ext/texlive/package-list.txt b/src/ext/texlive/package-list.txt new file mode 100644 index 00000000000..6975cc59973 --- /dev/null +++ b/src/ext/texlive/package-list.txt @@ -0,0 +1,42 @@ +# Here is the list of TeXlive packages required by Sage. +# +# Note: +# - Dependencies are installed automatically by TeXlive. +# - Whitespace and Lines starting with a hash are ignored. + + +latex +titlesec +framed +threeparttable +wrapfig +multirow +makecmds +collection-fontsrecommended + +# Some dependencies that TeXlive 2014 missed +cmap +fancybox +fancyvrb +mdwtools +parskip +jknapltx +etoolbox + +# Language support for localizations of the Sage docs +collection-langcyrillic +babel-basque +babel-catalan +babel-czech +babel-english +babel-french +babel-galician +babel-german +babel-hungarian +babel-italian +babel-polish +babel-portuges +babel-russian +babel-slovak +babel-spanish + diff --git a/src/ext/texlive/texlive-install b/src/ext/texlive/texlive-install new file mode 100755 index 00000000000..8fd2ccf73f0 --- /dev/null +++ b/src/ext/texlive/texlive-install @@ -0,0 +1,127 @@ +#!/usr/bin/env python + +import os +import sys +import glob +from subprocess import check_call, CalledProcessError + +try: + SAGE_LOCAL = os.environ['SAGE_LOCAL'] + DOT_SAGE = os.environ['DOT_SAGE'] +except KeyError: + print('You need to run this script in a Sage shell ("sage -sh")') + sys.exit(1) + + +TEXLIVE_INSTALL_UNIX_URL = \ + 'http://mirror.ctan.org/systems/texlive/tlnet/install-tl-unx.tar.gz' + +TEXLIVE_PROFILE_TEMPLATE = \ +""" +selected_scheme scheme-minimal +TEXDIR {SAGE_LOCAL}/share/texlive +TEXMFLOCAL {SAGE_LOCAL}/share/texlive/texmf-local +TEXMFSYSCONFIG {SAGE_LOCAL}/share/texlive/texmf-config +TEXMFSYSVAR {SAGE_LOCAL}/share/texlive/texmf-var +TEXMFCONFIG {DOT_SAGE}/texlive/texmf-config +TEXMFHOME {DOT_SAGE}/texlive/texmf-home +TEXMFVAR {DOT_SAGE}/texlive/texmf-var +collection-basic 1 +in_place 0 +option_adjustrepo 1 +option_autobackup 1 +option_backupdir tlpkg/backups +option_desktop_integration 1 +option_doc 1 +option_file_assocs 1 +option_fmt 1 +option_letter 0 +option_menu_integration 1 +option_path 1 +option_post_code 1 +option_src 1 +option_sys_bin {SAGE_LOCAL}/bin +option_sys_info {SAGE_LOCAL}/share/info +option_sys_man {SAGE_LOCAL}/share/man +option_w32_multi_user 1 +option_write18_restricted 1 +portable 0 +""" + + +def have_texlive(): + try: + check_call(['tlmgr', '--version']) + return True + except (OSError, CalledProcessError): + return False + + +def download_install_script(tarball): + try: + from urllib import urlretrieve + except ImportError: + from urllib.request import urlretrieve + urlretrieve(TEXLIVE_INSTALL_UNIX_URL, tarball) + + +def write_profile(filename): + profile = TEXLIVE_PROFILE_TEMPLATE.format( + SAGE_LOCAL=SAGE_LOCAL, DOT_SAGE=DOT_SAGE) + with open(filename, 'w') as f: + f.write(profile) + print('TeXlive unattended install profile: {0}'.format(filename)) + +def install_texlive(): + import tempfile + tmp_dir = tempfile.mkdtemp() + tarball = os.path.join(tmp_dir, 'install-tl-unx.tar.gz') + profile = os.path.join(tmp_dir, 'sage.profile') + download_install_script(tarball) + write_profile(profile) + + original_dir = os.getcwd() + os.chdir(tmp_dir) + check_call(['tar', '-x', '-z', '-f', tarball]) + install_dir = glob.glob('install-tl-*')[0] + os.chdir(install_dir) + + check_call([ + './install-tl', + '-profile', + profile + ]) + os.chdir(original_dir) + + +def install_packages(): + package_list_txt = os.path.join( + os.path.dirname(__file__), + 'package-list.txt' + ) + with open(package_list_txt) as f: + package_list = f.read() + packages = [] + for pkg in package_list.splitlines(): + pkg = pkg.strip() + if len(pkg) == 0: + continue + if pkg.startswith('#'): + continue + packages.append(pkg) + print('installing the following TeXlive packages:') + for pkg in packages: + print(' * ' + pkg) + check_call(['tlmgr', 'install'] + packages) + check_call(['tlmgr', 'path', 'add']) + + +if __name__ == '__main__': + if have_texlive(): + print('Using your own texlive install (see "tlmgr --version")') + else: + print('Performing minimal texlive install into {0}' + .format(SAGE_LOCAL)) + install_texlive() + install_packages() + From 2fc1cbbc5d266752d731ac223ab47b1b6ee7d1b7 Mon Sep 17 00:00:00 2001 From: Volker Braun Date: Mon, 2 Mar 2015 21:02:26 +0100 Subject: [PATCH 2/5] Spell checking --- src/ext/texlive/SPKG.txt | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/ext/texlive/SPKG.txt b/src/ext/texlive/SPKG.txt index 52ddc9aec9b..36e2c9825bd 100644 --- a/src/ext/texlive/SPKG.txt +++ b/src/ext/texlive/SPKG.txt @@ -9,7 +9,7 @@ Windows. It includes all the major TeX-related programs, macro packages, and fonts that are free software, including support for many languages around the world. -This package installs all texlive packages requried to build Sage. If +This package installs all texlive packages required to build Sage. If necessary, texlive itself is installed. == License == @@ -19,12 +19,10 @@ https://www.tug.org/texlive/copying.html for details. == Upstream Contact == -Hoem page: https://www.tug.org/texlive +Home page: https://www.tug.org/texlive == Dependencies == -Put a bulleted list of dependencies here: - * python == Special Update/Build Instructions == From c287be678c89084476ab6996396dabb513bd9b06 Mon Sep 17 00:00:00 2001 From: Volker Braun Date: Mon, 9 Mar 2015 09:36:57 +0100 Subject: [PATCH 3/5] only cd into a directory --- src/ext/texlive/texlive-install | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/ext/texlive/texlive-install b/src/ext/texlive/texlive-install index 8fd2ccf73f0..bf404653103 100755 --- a/src/ext/texlive/texlive-install +++ b/src/ext/texlive/texlive-install @@ -72,6 +72,15 @@ def write_profile(filename): f.write(profile) print('TeXlive unattended install profile: {0}'.format(filename)) +def first_dir(glob_pattern): + """ + Return the first directory matching ``glob_pattern`` + """ + for dirent in glob.glob(glob_pattern): + if os.path.isdir(dirent): + return dirent + raise RuntimeError('no directory found: {0}'.format(glob_pattern)) + def install_texlive(): import tempfile tmp_dir = tempfile.mkdtemp() @@ -83,7 +92,7 @@ def install_texlive(): original_dir = os.getcwd() os.chdir(tmp_dir) check_call(['tar', '-x', '-z', '-f', tarball]) - install_dir = glob.glob('install-tl-*')[0] + install_dir = first_dir('install-tl-*') os.chdir(install_dir) check_call([ From ef0319feee59186bf4139673e72c1234434aeba6 Mon Sep 17 00:00:00 2001 From: Volker Braun Date: Sun, 15 Mar 2015 20:07:06 +0100 Subject: [PATCH 4/5] add packages required by IPython nbconvert --- src/ext/texlive/package-list.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/ext/texlive/package-list.txt b/src/ext/texlive/package-list.txt index 6975cc59973..3fd38ca9581 100644 --- a/src/ext/texlive/package-list.txt +++ b/src/ext/texlive/package-list.txt @@ -23,6 +23,12 @@ parskip jknapltx etoolbox +# Used by IPython nbconvert (ipynb -> latex -> pdf conversion) +adjustbox +extension +collectbox +ucs + # Language support for localizations of the Sage docs collection-langcyrillic babel-basque From a0540a9c78e66a754a77dc4438512e5d83922461 Mon Sep 17 00:00:00 2001 From: Volker Braun Date: Sun, 15 Mar 2015 20:23:26 +0100 Subject: [PATCH 5/5] add to the documentation --- src/doc/en/installation/source.rst | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/doc/en/installation/source.rst b/src/doc/en/installation/source.rst index 982e1c710bf..be7c93714b6 100644 --- a/src/doc/en/installation/source.rst +++ b/src/doc/en/installation/source.rst @@ -310,15 +310,22 @@ It is highly recommended that you have `Latex `_ installed, but it is not required. -On Linux systems, it is usually provided by packages derived from -`TeX Live `_ and can be installed using:: +The most popular packaging is `TeX Live `_ , +which you can install locally inside Sage with the commands:: - sudo apt-get install texlive + sage -sh -c '$SAGE_ROOT/src/ext/texlive/texlive-install' -or similar commands. +On Linux systems you can alternatively install your distribution's +texlive packages:: + + sudo apt-get install texlive # debian + sudo yum install texlive # redhat -On other systems it might be necessary to install TeX Live from source code, -which is quite easy, though a rather time-consuming process. +or similar commands. In addition to the base texlive install you will +probably need a number of optional texlive packages, for example +country-specific babel packages for the localized Sage +documentation. The required texlive packages are listed in +`SAGE_ROOT/src/ext/texlive/package-list.txt`. If you don't have either ImageMagick or ffmpeg, you won't be able to view animations.