build_exo.py 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import site
  2. import subprocess
  3. import sys
  4. import os
  5. import pkgutil
  6. import shutil
  7. def run():
  8. site_packages = site.getsitepackages()[0]
  9. command = [
  10. f"{sys.executable}", "-m", "nuitka", "exo/main.py",
  11. "--company-name=exolabs",
  12. "--product-name=exo",
  13. "--output-dir=dist",
  14. "--follow-imports",
  15. "--standalone",
  16. "--output-filename=exo",
  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. "--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. os.makedirs('./dist/main.dist/transformers/models', exist_ok=True)
  53. shutil.copytree(f"{site_packages}/transformers/models", "dist/main.dist/transformers/models", dirs_exist_ok=True)
  54. except subprocess.CalledProcessError as e:
  55. print(f"An error occurred: {e}")
  56. if __name__ == "__main__":
  57. run()