build_exo.py 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import site
  2. import subprocess
  3. import sys
  4. import os
  5. import pkgutil
  6. def run():
  7. site_packages = site.getsitepackages()[0]
  8. command = [
  9. f"{sys.executable}", "-m", "nuitka", "exo/main.py",
  10. "--company-name=exolabs",
  11. "--product-name=exo",
  12. "--output-dir=dist",
  13. "--follow-imports",
  14. "--standalone",
  15. "--output-filename=exo",
  16. "--onefile",
  17. "--python-flag=no_site"
  18. ]
  19. if sys.platform == "darwin":
  20. command.extend([
  21. "--macos-app-name=exo",
  22. "--macos-app-mode=gui",
  23. "--macos-app-version=0.0.1",
  24. "--macos-signed-app-name=com.exolabs.exo",
  25. "--macos-sign-notarization",
  26. "--include-distribution-meta=mlx",
  27. "--include-module=mlx._reprlib_fix",
  28. "--include-module=mlx._os_warning",
  29. f"--include-data-files={site_packages}/mlx/lib/mlx.metallib=mlx/lib/mlx.metallib",
  30. f"--include-data-files={site_packages}/mlx/lib/mlx.metallib=./mlx.metallib",
  31. "--include-distribution-meta=pygments",
  32. "--nofollow-import-to=tinygrad"
  33. ])
  34. inference_modules = [
  35. name for _, name, _ in pkgutil.iter_modules(['exo/inference/models'])
  36. ]
  37. for module in inference_modules:
  38. command.append(f"--include-module=exo.inference.mlx.models.{module}")
  39. elif sys.platform == "win32":
  40. command.extend([
  41. "--windows-icon-from-ico=docs/exo-logo-win.ico",
  42. "--file-version=0.0.1",
  43. "--product-version=0.0.1"
  44. ])
  45. elif sys.platform.startswith("linux"):
  46. command.extend([
  47. "--include-distribution-metadata=pygments",
  48. "--linux-icon=docs/exo-rounded.png"
  49. ])
  50. try:
  51. subprocess.run(command, check=True)
  52. print("Build completed!")
  53. except subprocess.CalledProcessError as e:
  54. print(f"An error occurred: {e}")
  55. if __name__ == "__main__":
  56. run()