build_exo.py 2.0 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-identity=auto",
  26. "--macos-sign-notarization",
  27. "--include-distribution-meta=mlx",
  28. "--include-module=mlx._reprlib_fix",
  29. "--include-module=mlx._os_warning",
  30. f"--include-data-files={site_packages}/mlx/lib/mlx.metallib=mlx/lib/mlx.metallib",
  31. f"--include-data-files={site_packages}/mlx/lib/mlx.metallib=./mlx.metallib",
  32. "--include-distribution-meta=pygments",
  33. "--nofollow-import-to=tinygrad"
  34. ])
  35. inference_modules = [
  36. name for _, name, _ in pkgutil.iter_modules(['exo/inference/mlx/models'])
  37. ]
  38. for module in inference_modules:
  39. command.append(f"--include-module=exo.inference.mlx.models.{module}")
  40. elif sys.platform == "win32":
  41. command.extend([
  42. "--windows-icon-from-ico=docs/exo-logo-win.ico",
  43. "--file-version=0.0.1",
  44. "--product-version=0.0.1"
  45. ])
  46. elif sys.platform.startswith("linux"):
  47. command.extend([
  48. "--include-distribution-metadata=pygments",
  49. "--linux-icon=docs/exo-rounded.png"
  50. ])
  51. try:
  52. subprocess.run(command, check=True)
  53. print("Build completed!")
  54. except subprocess.CalledProcessError as e:
  55. print(f"An error occurred: {e}")
  56. if __name__ == "__main__":
  57. run()