From 13bfdadd9fa951c5edd5830e6da07708bdce43e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20N=C3=B6the?= Date: Tue, 18 May 2021 12:33:19 +0200 Subject: [PATCH] Update packaging, add option to give packages in a file --- install_texlive/__init__.py | 2 ++ install_texlive/__main__.py | 26 +++++++++++++++++++------- install_texlive/parser.py | 24 ++++++++++++++++-------- pyproject.toml | 3 +++ setup.cfg | 18 ++++++++++++++++++ setup.py | 25 ++----------------------- 6 files changed, 60 insertions(+), 38 deletions(-) create mode 100644 pyproject.toml create mode 100644 setup.cfg diff --git a/install_texlive/__init__.py b/install_texlive/__init__.py index d98dd2e..7953588 100644 --- a/install_texlive/__init__.py +++ b/install_texlive/__init__.py @@ -7,6 +7,8 @@ from io import BytesIO import tarfile +__version__ = '0.3.0' + log = logging.getLogger(__name__) has_curl = sp.call(['which', 'curl'], stdout=sp.PIPE) == 0 diff --git a/install_texlive/__main__.py b/install_texlive/__main__.py index abb1e43..37bb128 100644 --- a/install_texlive/__main__.py +++ b/install_texlive/__main__.py @@ -55,7 +55,7 @@ def main(): pass try: - command(tl, 'Import settings', 'y' if args.keep else 'n', timeout=5) + command(tl, 'Import settings', 'y' if args.keep_config else 'n', timeout=5) except pexpect.TIMEOUT: log.info('No previous installation found') @@ -112,22 +112,34 @@ def main(): repo = OLDURL.format(v=version) else: repo = URL - sp.Popen( + sp.run( ['tlmgr', 'option', 'repository', repo], - env=env - ).wait() + env=env, + check=True, + ) if args.update: log.info('Start updating') - sp.Popen( + sp.run( ['tlmgr', 'update', '--self', '--all', '--reinstall-forcibly-removed'], env=env, - ).wait() + check=True, + ) log.info('Finished') + additional_packages = [] if args.install: + additional_packages.extend(args.install.split(',')) + + if args.package_file: + with open(args.package_file, 'r') as f: + additional_packages.extend(f.read().splitlines()) + + if additional_packages: log.info('Start installing addtional packages') - sp.Popen(['tlmgr', 'install', *args.install.split(',')], env=env).wait() + # tlmgr must always be up to date to install packages + sp.run(['tlmgr', 'update', '--self'], env=env, check=True) + sp.run(['tlmgr', 'install', *additional_packages], env=env, check=True) log.info('Finished') diff --git a/install_texlive/parser.py b/install_texlive/parser.py index 05205cf..d388096 100644 --- a/install_texlive/parser.py +++ b/install_texlive/parser.py @@ -1,6 +1,9 @@ from argparse import ArgumentParser +from . import __version__ -parser = ArgumentParser() +parser = ArgumentParser(prog='install_texlive') + +parser.add_argument('-V', '--version', action='version', version=__version__) parser.add_argument( '-v', '--verbose', action='store_true', help='Create more verbose output' @@ -12,22 +15,22 @@ ) parser.add_argument( - '--install-tl', dest='install_tl', + '--install-tl', help='Path to the install-tl script. If not given, TeX Live will be downloaded.', ) parser.add_argument( - '-k', '--keep-config', dest='keep', action='store_true', + '-k', '--keep-config', action='store_true', help='If an existing installation is found, keep its config', ) parser.add_argument( - '-p', '--prefix', dest='prefix', + '-p', '--prefix', help='Installation prefix, equivalent to setting TEXLIVE_INSTALL_PREFIX' ) parser.add_argument( - '-c', '--collections', dest='collections', + '-c', '--collections', help=( 'The TeX Live package collections to install.' ' E.g. -a to deselect all and only install the absolute basic TeX packages' @@ -35,20 +38,25 @@ ) parser.add_argument( - '-s', '--scheme', dest='scheme', choices=set('abcdefghijk'), + '-s', '--scheme', choices=set('abcdefghijk'), help='The TeX Live scheme to install. Default is "full"' ) parser.add_argument( - '-u', '--update', dest='update', action='store_true', + '-u', '--update', action='store_true', help='Update TeX Live after installation is finished' ) parser.add_argument( - '-i', '--install', dest='install', + '-i', '--install', help='Additional packages to install after the main Installation has finished as comma separated list' ) +parser.add_argument( + '-f', '--package-file', + help='A file with one package per line to be install after the main installation has finished' +) + parser.add_argument( '--source', action='store_true', help='Install the source tree', diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..9787c3b --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["setuptools", "wheel"] +build-backend = "setuptools.build_meta" diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..e2a5748 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,18 @@ +[metadata] +name = install_texlive +version = attr: install_texlive.__version__ +description = Install texlive without human interaction in the process +url = http://github.com/maxnoe/texlive-batch-installation +author = Maximilian Noethe +author_email = maximilian.noethe@tu-dortmund.de +license = MIT + +[options] +packages = find: +install_requires = + pexpect + requests + +[options.entry_points] +console_scripts = + install_texlive = install_texlive.__main__:main diff --git a/setup.py b/setup.py index fe780e9..8bf1ba9 100644 --- a/setup.py +++ b/setup.py @@ -1,23 +1,2 @@ -from distutils.core import setup - -setup( - name='install_texlive', - version='0.2.2', - description='Install texlive without human interaction in the process', - url='http://github.com/maxnoe/texlive-batch-installation', - author='Maximilian Noethe', - author_email='maximilian.noethe@tu-dortmund.de', - license='MIT', - packages=[ - 'install_texlive', - ], - install_requires=[ - 'pexpect', - 'requests', - ], - entry_points={ - 'console_scripts': [ - 'install_texlive = install_texlive.__main__:main', - ] - }, -) +from setuptools import setup +setup()