build_exo.py 2.2 KB

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