__main__.py 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. description='Bundle a Python install into an AppImage')
  11. subparsers = parser.add_subparsers(title='builder',
  12. help='Appimage builder',
  13. dest='builder')
  14. parser.add_argument('-q', '--quiet', help='disable logging',
  15. dest='verbosity', action='store_const', const=logging.ERROR)
  16. parser.add_argument('-v', '--verbose', help='print extra information',
  17. dest='verbosity', action='store_const', const=logging.DEBUG)
  18. local_parser = subparsers.add_parser('local')
  19. local_parser.add_argument('-d', '--destination',
  20. help='AppImage destination')
  21. local_parser.add_argument('-p', '--python', help='python executable')
  22. manylinux_parser = subparsers.add_parser('manylinux')
  23. manylinux_parser.add_argument('tag', help='manylinux image tag')
  24. manylinux_parser.add_argument('abi', help='python ABI')
  25. manylinux_parser.add_argument('--contained', help=argparse.SUPPRESS,
  26. action='store_true', default=False)
  27. args = parser.parse_args()
  28. # Configure the verbosity
  29. if args.verbosity:
  30. logging.getLogger().setLevel(args.verbosity)
  31. # Call the AppImage builder
  32. builder = import_module('.builders.' + args.builder, package=__package__)
  33. builder.build(*builder._unpack_args(args))
  34. if __name__ == "__main__":
  35. main()