build_exo.py 1.9 KB

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