diff --git a/python_appimage/__main__.py b/python_appimage/__main__.py index 2f2f94e..84b023e 100644 --- a/python_appimage/__main__.py +++ b/python_appimage/__main__.py @@ -1,6 +1,5 @@ import argparse from importlib import import_module -import logging import os import sys @@ -24,9 +23,9 @@ def main(): dest='command') parser.add_argument('-q', '--quiet', help='disable logging', - dest='verbosity', action='store_const', const=logging.ERROR) + dest='verbosity', action='store_const', const='ERROR') parser.add_argument('-v', '--verbose', help='print extra information', - dest='verbosity', action='store_const', const=logging.DEBUG) + dest='verbosity', action='store_const', const='DEBUG') install_parser = subparsers.add_parser('install', description='Install binary dependencies') @@ -89,7 +88,8 @@ def main(): # Configure the verbosity if args.verbosity: - logging.getLogger().setLevel(args.verbosity) + from .utils import log + log.set_level(args.verbosity) # check if no arguments are passed if args.command is None: diff --git a/python_appimage/commands/build/manylinux.py b/python_appimage/commands/build/manylinux.py index 85745f8..bbd1e93 100644 --- a/python_appimage/commands/build/manylinux.py +++ b/python_appimage/commands/build/manylinux.py @@ -7,6 +7,7 @@ import sys from ...appimage import build_appimage, relocate_python from ...utils.docker import docker_run from ...utils.fs import copy_tree +from ...utils.manylinux import format_appimage_name, format_tag from ...utils.tmp import TemporaryDirectory @@ -19,15 +20,6 @@ def _unpack_args(args): return args.tag, args.abi, args.contained -def _manylinux_tag(tag): - '''Format Manylinux tag - ''' - if tag.startswith('2_'): - return 'manylinux_' + tag - else: - return 'manylinux' + tag - - def _get_appimage_name(abi, tag): '''Format the Python AppImage name using the ABI and OS tags ''' @@ -36,8 +28,7 @@ def _get_appimage_name(abi, tag): fullversion = desktop[13:-8] # Finish building the AppImage on the host. See below. - return 'python{:}-{:}-{:}.AppImage'.format( - fullversion, abi, _manylinux_tag(tag)) + return format_appimage_name(abi, fullversion, tag) def execute(tag, abi, contained=False): @@ -46,7 +37,7 @@ def execute(tag, abi, contained=False): if not contained: # Forward the build to a Docker image - image = 'quay.io/pypa/' + _manylinux_tag(tag) + image = 'quay.io/pypa/' + format_tag(tag) python = '/opt/python/' + abi + '/bin/python' pwd = os.getcwd() @@ -54,7 +45,11 @@ def execute(tag, abi, contained=False): with TemporaryDirectory() as tmpdir: copy_tree(dirname, 'python_appimage') - argv = ' '.join(sys.argv[1:]) + argv = sys.argv[1:] + if argv: + argv = ' '.join(argv) + else: + argv = 'build manylinux {:} {:}'.format(tag, abi) if tag.startswith("1_"): # On manylinux1 tk is not installed script = [ diff --git a/python_appimage/commands/list.py b/python_appimage/commands/list.py index e3bb3ab..083a4d2 100644 --- a/python_appimage/commands/list.py +++ b/python_appimage/commands/list.py @@ -35,7 +35,9 @@ def execute(tag): script, capture = True ) - for line in result.split(os.linesep): - if line: - log('LIST', "{1:7} -> /opt/python/{0:}".format( - *line.split())) + pythons = [line.split() for line in result.split(os.linesep) if line] + + for (abi, version) in pythons: + log('LIST', "{:7} -> /opt/python/{:}".format(version, abi)) + + return pythons diff --git a/python_appimage/utils/log.py b/python_appimage/utils/log.py index 1151791..e5a1e37 100644 --- a/python_appimage/utils/log.py +++ b/python_appimage/utils/log.py @@ -7,17 +7,25 @@ __all__ = ['debug', 'log'] # Configure the logger logging.basicConfig( format='[%(asctime)s] %(message)s', - level=logging.INFO + level=logging.ERROR ) +logging.getLogger('python-appimage').setLevel(logging.INFO) def log(task, fmt, *args): '''Log a standard message ''' - logging.info('%-8s ' + fmt, task, *args) + logging.getLogger('python-appimage').info('%-8s ' + fmt, task, *args) def debug(task, fmt, *args): '''Report some debug information ''' - logging.debug('%-8s ' + fmt, task, *args) + logging.getLogger('python-appimage').debug('%-8s ' + fmt, task, *args) + + +def set_level(level): + '''Set the threshold for logs + ''' + level = getattr(logging, level) + logging.getLogger('python-appimage').setLevel(level)