-
Notifications
You must be signed in to change notification settings - Fork 0
/
ellm_api_server.spec
134 lines (114 loc) · 3.46 KB
/
ellm_api_server.spec
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# -*- mode: python ; coding: utf-8 -*-
from pathlib import Path
from PyInstaller.utils.hooks import collect_all, collect_data_files
import importlib.metadata
import re
import sys
import os
CONDA_PATH=Path(sys.executable)
print(dir(CONDA_PATH))
print(CONDA_PATH)
print(CONDA_PATH.parent)
excluded_modules = ['torch.distributions'] # <<< ADD THIS LINE
def get_embeddedllm_backend():
try:
# Get the version of embeddedllm
version = importlib.metadata.version("embeddedllm")
# Use regex to extract the backend
match = re.search(r"\+(directml|cpu|cuda|ipex|openvino)$", version)
if match:
backend = match.group(1)
return backend
else:
return "Unknown backend"
except importlib.metadata.PackageNotFoundError:
return "embeddedllm not installed"
backend = get_embeddedllm_backend()
binaries_list = []
datas_list = [
(Path("src/embeddedllm/entrypoints/api_server.py").resolve().as_posix(), 'embeddedllm/entrypoints'),
]
datas_list.extend(collect_data_files('torch', include_py_files=True))
hiddenimports_list = ['multipart']
pathex = []
def add_package(package_name):
datas, binaries, hiddenimports = collect_all(package_name)
datas_list.extend(datas)
binaries_list.extend(binaries)
hiddenimports_list.extend(hiddenimports)
if backend in ('directml', 'cpu', 'cuda'):
add_package('onnxruntime')
add_package('onnxruntime_genai')
elif backend == 'ipex':
print(f"Backend IPEX")
add_package('ipex_llm')
add_package('torch')
add_package('torchvision')
add_package('intel_extension_for_pytorch')
add_package('trl')
add_package('embeddedllm')
add_package('numpy')
binaries_list.append((f'{CONDA_PATH.parent}/Library/bin/*', '.'))
elif backend == 'openvino':
print(f"Backend OpenVino")
add_package('onnx')
add_package('torch')
add_package('torchvision')
add_package('optimum')
add_package('optimum.intel')
add_package('embeddedllm')
add_package('numpy')
add_package('openvino')
add_package('openvino-genai')
add_package('openvino-telemetry')
add_package('openvino-tokenizers')
binaries_list.append((f'{CONDA_PATH.parent}/Library/bin/*', '.'))
binaries_list.extend([
(Path('C:\\Windows\\System32\\libomp140.x86_64.dll').as_posix(), '.'),
(Path('C:\\Windows\\System32\\libomp140d.x86_64.dll').as_posix(), '.'),
])
print(binaries_list)
with open("binary.txt", 'w') as f:
f.write(str(binaries_list))
block_cipher = None
a = Analysis(
['src\\embeddedllm\\entrypoints\\api_server.py'],
pathex=pathex,
binaries=binaries_list,
datas=datas_list,
hiddenimports=hiddenimports_list,
hookspath=[],
hooksconfig={},
runtime_hooks=[],
excludes=excluded_modules,
block_cipher=block_cipher,
noarchive=False,
optimize=1,
)
pyz = PYZ(a.pure)
exe = EXE(
pyz,
a.scripts,
[],
exclude_binaries=True,
name='ellm_api_server',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
console=True,
disable_windowed_traceback=False,
argv_emulation=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None,
)
coll = COLLECT(
exe,
a.binaries,
a.datas,
strip=False,
upx=True,
upx_exclude=[],
name='ellm_api_server',
)