__main__.py 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import argparse
  2. from importlib import import_module
  3. import logging
  4. import os
  5. import sys
  6. from .deps import fetch_all
  7. __all__ = ['main']
  8. def main():
  9. # Parse arguments
  10. parser = argparse.ArgumentParser(
  11. description='Bundle a Python install into an AppImage')
  12. subparsers = parser.add_subparsers(title='builder',
  13. help='Appimage builder',
  14. dest='builder')
  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. parser.add_argument('--deploy', help=argparse.SUPPRESS,
  20. action='store_true', default=False)
  21. local_parser = subparsers.add_parser('local')
  22. local_parser.add_argument('-d', '--destination',
  23. help='AppImage destination')
  24. local_parser.add_argument('-p', '--python', help='python executable')
  25. manylinux_parser = subparsers.add_parser('manylinux')
  26. manylinux_parser.add_argument('tag', help='manylinux image tag')
  27. manylinux_parser.add_argument('abi', help='python ABI')
  28. manylinux_parser.add_argument('--contained', help=argparse.SUPPRESS,
  29. action='store_true', default=False)
  30. args = parser.parse_args()
  31. # Configure the verbosity
  32. if args.verbosity:
  33. logging.getLogger().setLevel(args.verbosity)
  34. if args.deploy:
  35. # Fetch dependencies and exit
  36. fetch_all()
  37. sys.exit(0)
  38. # Call the AppImage builder
  39. builder = import_module('.' + args.builder, package=__package__)
  40. builder.build(*builder._unpack_args(args))
  41. if __name__ == "__main__":
  42. main()