build_exo.py 2.2 KB

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