mirror of
https://github.com/exo-explore/exo.git
synced 2025-10-23 02:57:14 +03:00
61 lines
2.1 KiB
Python
61 lines
2.1 KiB
Python
import site
|
|
import subprocess
|
|
import sys
|
|
import os
|
|
import pkgutil
|
|
import shutil
|
|
|
|
def run():
|
|
site_packages = site.getsitepackages()[0]
|
|
command = [
|
|
f"{sys.executable}", "-m", "nuitka", "exo/main.py",
|
|
"--company-name=exolabs",
|
|
"--product-name=exo",
|
|
"--output-dir=dist",
|
|
"--follow-imports",
|
|
"--standalone",
|
|
"--output-filename=exo",
|
|
"--python-flag=no_site",
|
|
"--onefile"
|
|
]
|
|
|
|
if sys.platform == "darwin":
|
|
command.extend([
|
|
"--macos-app-name=exo",
|
|
"--macos-app-mode=gui",
|
|
"--macos-app-version=0.0.1",
|
|
"--macos-signed-app-name=com.exolabs.exo",
|
|
"--include-distribution-meta=mlx",
|
|
"--include-module=mlx._reprlib_fix",
|
|
"--include-module=mlx._os_warning",
|
|
f"--include-data-files={site_packages}/mlx/lib/mlx.metallib=mlx/lib/mlx.metallib",
|
|
f"--include-data-files={site_packages}/mlx/lib/mlx.metallib=./mlx.metallib",
|
|
"--include-distribution-meta=pygments",
|
|
"--nofollow-import-to=tinygrad"
|
|
])
|
|
inference_modules = [
|
|
name for _, name, _ in pkgutil.iter_modules(['exo/inference/mlx/models'])
|
|
]
|
|
for module in inference_modules:
|
|
command.append(f"--include-module=exo.inference.mlx.models.{module}")
|
|
elif sys.platform == "win32":
|
|
command.extend([
|
|
"--windows-icon-from-ico=docs/exo-logo-win.ico",
|
|
"--file-version=0.0.1",
|
|
"--product-version=0.0.1"
|
|
])
|
|
elif sys.platform.startswith("linux"):
|
|
command.extend([
|
|
"--include-distribution-metadata=pygments",
|
|
"--linux-icon=docs/exo-rounded.png"
|
|
])
|
|
try:
|
|
subprocess.run(command, check=True)
|
|
print("Build completed!")
|
|
os.makedirs('./dist/main.dist/transformers/models', exist_ok=True)
|
|
shutil.copytree(f"{site_packages}/transformers/models", "dist/main.dist/transformers/models", dirs_exist_ok=True)
|
|
except subprocess.CalledProcessError as e:
|
|
print(f"An error occurred: {e}")
|
|
|
|
if __name__ == "__main__":
|
|
run() |