Skip to content

Commit

Permalink
Update packaging, add option to give packages in a file
Browse files Browse the repository at this point in the history
  • Loading branch information
maxnoe committed May 18, 2021
1 parent f261956 commit 13bfdad
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 38 deletions.
2 changes: 2 additions & 0 deletions install_texlive/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
26 changes: 19 additions & 7 deletions install_texlive/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand Down Expand Up @@ -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')


Expand Down
24 changes: 16 additions & 8 deletions install_texlive/parser.py
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -12,43 +15,48 @@
)

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'
)
)

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',
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta"
18 changes: 18 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -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
25 changes: 2 additions & 23 deletions setup.py
Original file line number Diff line number Diff line change
@@ -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()

0 comments on commit 13bfdad

Please sign in to comment.