1
0

__main__.py 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. import argparse
  2. from importlib import import_module
  3. import logging
  4. import os
  5. import sys
  6. __all__ = ['main']
  7. def main():
  8. # Parse arguments
  9. parser = argparse.ArgumentParser(
  10. prog='python-appimage',
  11. description='Bundle a Python installation into an AppImage')
  12. subparsers = parser.add_subparsers(title='command',
  13. help='Build or install command',
  14. dest='command')
  15. parser.add_argument('-q', '--quiet', help='disable logging',
  16. dest='verbosity', action='store_const', const=logging.ERROR)
  17. parser.add_argument('-v', '--verbose', help='print extra information',
  18. dest='verbosity', action='store_const', const=logging.DEBUG)
  19. install_parser = subparsers.add_parser('install',
  20. description='Install binary dependencies')
  21. install_parser.add_argument('binary', nargs='+',
  22. choices=('appimagetool', 'patchelf'), help='one or more binary name')
  23. local_parser = subparsers.add_parser('local',
  24. description='Bundle a local Python installation')
  25. local_parser.add_argument('-d', '--destination',
  26. help='AppImage destination')
  27. local_parser.add_argument('-p', '--python', help='python executable')
  28. manylinux_parser = subparsers.add_parser('manylinux',
  29. description='Bundle a manylinux Python installation using docker')
  30. manylinux_parser.add_argument('tag',
  31. help='manylinux image tag (e.g. 2010_x86_64)')
  32. manylinux_parser.add_argument('abi',
  33. help='python ABI (e.g. cp37-cp37m)')
  34. manylinux_parser.add_argument('--contained', help=argparse.SUPPRESS,
  35. action='store_true', default=False)
  36. args = parser.parse_args()
  37. # Configure the verbosity
  38. if args.verbosity:
  39. logging.getLogger().setLevel(args.verbosity)
  40. # Call the requested command
  41. command = import_module('.commands.' +
  42. args.command, package=__package__)
  43. command.execute(*command._unpack_args(args))
  44. if __name__ == "__main__":
  45. main()