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