diff --git a/python_appimage/__main__.py b/python_appimage/__main__.py index 9a2471b..6e11fec 100644 --- a/python_appimage/__main__.py +++ b/python_appimage/__main__.py @@ -9,6 +9,13 @@ __all__ = ['main'] def main(): + '''Entry point for the CLI + ''' + + # Binary dependencies + binaries = ('appimagetool', 'patchelf') + + # Parse arguments parser = argparse.ArgumentParser( prog='python-appimage', @@ -25,7 +32,7 @@ def main(): install_parser = subparsers.add_parser('install', description='Install binary dependencies') install_parser.add_argument('binary', nargs='+', - choices=('appimagetool', 'patchelf'), help='one or more binary name') + choices=binaries, help='one or more binary name') local_parser = subparsers.add_parser('local', description='Bundle a local Python installation') @@ -43,6 +50,11 @@ def main(): manylinux_parser.add_argument('--contained', help=argparse.SUPPRESS, action='store_true', default=False) + which_parser = subparsers.add_parser('which', + description='Locate a binary dependency') + which_parser.add_argument('binary', choices=binaries, + help='name of the binary to locate') + args = parser.parse_args() # Configure the verbosity diff --git a/python_appimage/commands/install.py b/python_appimage/commands/install.py index d5fce3b..4c16303 100644 --- a/python_appimage/commands/install.py +++ b/python_appimage/commands/install.py @@ -4,8 +4,6 @@ from ..utils import deps from ..utils.log import log - - __all__ = ['execute'] diff --git a/python_appimage/commands/which.py b/python_appimage/commands/which.py new file mode 100644 index 0000000..6e159e2 --- /dev/null +++ b/python_appimage/commands/which.py @@ -0,0 +1,21 @@ +import os + +from ..utils import deps +from ..utils.log import log + + +__all__ = ['execute'] + + +def _unpack_args(args): + '''Unpack command line arguments + ''' + return (args.binary,) + + +def execute(binary): + '''Print the location of a binary dependency + ''' + path = os.path.join(os.path.dirname(deps.PATCHELF), binary) + if os.path.exists(path): + print(path)