pyinstaller.py 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #!/usr/bin/env python3
  2. import argparse
  3. import glob
  4. from installer import install
  5. from installer.destinations import SchemeDictionaryDestination
  6. from installer.sources import WheelFile
  7. def main():
  8. """Entry point for CLI."""
  9. ap = argparse.ArgumentParser("python pyinstaller.py")
  10. ap.add_argument("wheel_file", help="Path to a .whl file to install")
  11. ap.add_argument(
  12. "--interpreter", required=True, help="Interpreter path to be used in scripts"
  13. )
  14. ap.add_argument(
  15. "--script-kind",
  16. required=True,
  17. choices=["posix", "win-ia32", "win-amd64", "win-arm", "win-arm64"],
  18. help="Kind of launcher to create for each script",
  19. )
  20. dest_args = ap.add_argument_group("Destination directories")
  21. dest_args.add_argument(
  22. "--purelib",
  23. required=True,
  24. help="Directory for platform-independent Python modules",
  25. )
  26. dest_args.add_argument(
  27. "--platlib",
  28. help="Directory for platform-dependent Python modules (same as purelib "
  29. "if not specified)",
  30. )
  31. dest_args.add_argument(
  32. "--headers", required=True, help="Directory for C header files"
  33. )
  34. dest_args.add_argument(
  35. "--scripts", required=True, help="Directory for executable scripts"
  36. )
  37. dest_args.add_argument(
  38. "--data", required=True, help="Directory for external data files"
  39. )
  40. args = ap.parse_args()
  41. destination = SchemeDictionaryDestination(
  42. {
  43. "purelib": args.purelib,
  44. "platlib": args.platlib if args.platlib is not None else args.purelib,
  45. "headers": args.headers,
  46. "scripts": args.scripts,
  47. "data": args.data,
  48. },
  49. interpreter=args.interpreter,
  50. script_kind=args.script_kind,
  51. )
  52. with WheelFile.open(glob.glob(args.wheel_file)[0]) as source:
  53. install(
  54. source=source,
  55. destination=destination,
  56. additional_metadata={},
  57. )
  58. if __name__ == "__main__":
  59. main()