Repository navigation
Expand file tree
/
Copy pathwindows_create_package.bat
More file actions
250 lines (222 loc) · 10.3 KB
/
Copy pathwindows_create_package.bat
File metadata and controls
250 lines (222 loc) · 10.3 KB
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
::
:: Copyright (c) 2024 Intel Corporation
::
:: Licensed under the Apache License, Version 2.0 (the "License");
:: you may not use this file except in compliance with the License.
:: You may obtain a copy of the License at
::
:: http:::www.apache.org/licenses/LICENSE-2.0
::
:: Unless required by applicable law or agreed to in writing, software
:: distributed under the License is distributed on an "AS IS" BASIS,
:: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
:: See the License for the specific language governing permissions and
:: limitations under the License.
::
echo off
setlocal EnableExtensions EnableDelayedExpansion
set "setPath=C:\opt;C:\opt\msys64\usr\bin\;%PATH%;"
set "PATH=%setPath%"
set "libovmspython_src="
set "libpython_calculators_src="
:: Load chosen dependency versions from versions.mk
for /f "usebackq eol=# tokens=1,3" %%A in ("%cd%\versions.mk") do (
if "%%A"=="OPENCV_VERSION" if "!opencv_version!"=="" set "opencv_version=%%B"
if "%%A"=="CURL_VERSION" if "!curl_version!"=="" set "curl_version=%%B"
)
:: Build DLL suffix by removing dots (e.g. 4.14.0 -> 4140)
set "opencv_dll_ver=!opencv_version:.=!"
IF "%~1"=="" (
echo No argument provided. Using default opt path
set "output_user_root=opt"
) ELSE (
echo Argument provided: Using install path %1
set "output_user_root=%1"
)
IF "%~2"=="--with_python" (
echo Self contained Python will be included in the package
set "with_python=true"
) ELSE (
echo Self contained Python will not be included in the package
set "with_python=false"
)
:: Set default USE_OV_BINARY if not set
if "%OV_USE_BINARY%"=="" (
set "OV_USE_BINARY=1"
)
if exist dist\windows\ovms (
rmdir /s /q dist\windows\ovms
if !errorlevel! neq 0 exit /b !errorlevel!
)
md dist\windows\ovms
copy bazel-bin\src\ovms.exe dist\windows\ovms
if !errorlevel! neq 0 exit /b !errorlevel!
copy %cd%\bazel-out\x64_windows-opt\bin\src\ovms_mediapipe_runtime_shared.dll dist\windows\ovms
if !errorlevel! neq 0 exit /b !errorlevel!
copy C:\%output_user_root%\openvino\runtime\bin\intel64\Release\*.dll dist\windows\ovms
if !errorlevel! neq 0 exit /b !errorlevel!
set "dest_dir=C:\opt"
if /i "%with_python%"=="true" (
if exist %cd%\bazel-bin\src\python\libovmspython.dll (
set "libovmspython_src=%cd%\bazel-bin\src\python\libovmspython.dll"
) else if exist %cd%\bazel-out\x64_windows-opt\bin\src\python\libovmspython.dll (
set "libovmspython_src=%cd%\bazel-out\x64_windows-opt\bin\src\python\libovmspython.dll"
)
if not defined libovmspython_src (
echo Missing libovmspython.dll in bazel output. Ensure //src/python:libovmspython is built.
exit /b 1
)
if exist %cd%\bazel-bin\src\python\libpython_calculators.dll (
set "libpython_calculators_src=%cd%\bazel-bin\src\python\libpython_calculators.dll"
) else if exist %cd%\bazel-out\x64_windows-opt\bin\src\python\libpython_calculators.dll (
set "libpython_calculators_src=%cd%\bazel-out\x64_windows-opt\bin\src\python\libpython_calculators.dll"
)
if not defined libpython_calculators_src (
echo Missing libpython_calculators.dll in bazel output. Ensure //src/python:libpython_calculators is built.
exit /b 1
)
:: Copy pyovms module
md dist\windows\ovms\python
copy %cd%\bazel-out\x64_windows-opt\bin\src\python\binding\pyovms.pyd dist\windows\ovms\python
if !errorlevel! neq 0 exit /b !errorlevel!
:: Copy shared OVMS python runtime libraries required by ovms.exe when Python is enabled.
copy "!libovmspython_src!" dist\windows\ovms
if !errorlevel! neq 0 exit /b !errorlevel!
copy "!libpython_calculators_src!" dist\windows\ovms
if !errorlevel! neq 0 exit /b !errorlevel!
:: Prepare self-contained python
set "python_version=3.12.10"
call %cd%\windows_prepare_python.bat %dest_dir% !python_version!
if !errorlevel! neq 0 (
echo Error occurred when creating Python environment for the distribution.
exit /b !errorlevel!
)
:: Copy whole catalog to dist folder and install dependencies required by LLM pipelines
xcopy %dest_dir%\python-!python_version!-embed-amd64 dist\windows\ovms\python /E /I /H
if !errorlevel! neq 0 (
echo Error occurred when creating Python environment for the distribution.
exit /b !errorlevel!
)
if not exist dist\windows\ovms\python\python312.zip (
echo Packaging validation failed: embedded stdlib python312.zip is missing from dist\windows\ovms\python.
exit /b 1
)
.\dist\windows\ovms\python\python.exe -m pip install "setuptools==80.9.0" "Jinja2==3.1.6" "MarkupSafe==3.0.2"
if !errorlevel! neq 0 (
echo Error during Python dependencies for LLM installation. The package will not be fully functional.
)
)
copy C:\%output_user_root%\openvino\runtime\3rdparty\tbb\bin\tbb12.dll dist\windows\ovms
if !errorlevel! neq 0 exit /b !errorlevel!
:: Copy from bazel-out if the genai is from sources
copy %cd%\bazel-out\x64_windows-opt\bin\src\opencv_world!opencv_dll_ver!.dll dist\windows\ovms
if !errorlevel! neq 0 exit /b !errorlevel!
copy /Y %cd%\bazel-out\x64_windows-opt\bin\src\openvino_genai.dll dist\windows\ovms
if !errorlevel! neq 0 exit /b !errorlevel!
copy /Y %cd%\bazel-out\x64_windows-opt\bin\src\openvino_tokenizers.dll dist\windows\ovms
if !errorlevel! neq 0 exit /b !errorlevel!
copy /Y %cd%\bazel-out\x64_windows-opt\bin\src\libcurl-x64.dll dist\windows\ovms
if !errorlevel! neq 0 exit /b !errorlevel!
copy /Y %cd%\bazel-out\x64_windows-opt\bin\src\git2.dll dist\windows\ovms
if !errorlevel! neq 0 exit /b !errorlevel!
:: Old package had core_tokenizers
if exist %cd%\bazel-out\x64_windows-opt\bin\src\core_tokenizers.dll (
copy /Y %cd%\bazel-out\x64_windows-opt\bin\src\core_tokenizers.dll dist\windows\ovms
if !errorlevel! neq 0 exit /b !errorlevel!
)
:: Bundle espeak-ng DLL + data when it was built from source by Bazel
:: (--//:espeak=on). Picked up from the rules_foreign_cc cmake output tree.
for /f "delims=" %%D in ('dir /b /s /a:-d "%cd%\bazel-out\x64_windows-opt\bin\external\espeak_ng\espeak-ng.dll" 2^>nul') do (
copy /Y "%%D" dist\windows\ovms
if !errorlevel! neq 0 exit /b !errorlevel!
)
for /f "delims=" %%D in ('dir /b /s /a:d "%cd%\bazel-out\x64_windows-opt\bin\external\espeak_ng" 2^>nul ^| findstr /e "espeak-ng-data"') do (
xcopy "%%D" dist\windows\ovms\espeak-ng-data /E /I /H /Y
if !errorlevel! neq 0 exit /b !errorlevel!
)
copy %cd%\setupvars.* dist\windows\ovms
if !errorlevel! neq 0 exit /b !errorlevel!
copy %cd%\install_ovms_service.bat dist\windows\ovms
if !errorlevel! neq 0 exit /b !errorlevel!
:: Adding licenses
set "license_dest=%cd%\dist\windows\ovms\thirdparty-licenses\"
md %license_dest%
if !errorlevel! neq 0 exit /b !errorlevel!
copy C:\opt\opencv_!opencv_version!\etc\licenses\* %license_dest%
if !errorlevel! neq 0 exit /b !errorlevel!
IF "%OV_USE_BINARY%"=="1" (
copy C:\%output_user_root%\openvino\docs\licensing\LICENSE %license_dest%openvino.LICENSE.txt
if !errorlevel! neq 0 exit /b !errorlevel!
copy C:\%output_user_root%\openvino\docs\licensing\LICENSE-GENAI %license_dest%LICENSE-GENAI.txt
if !errorlevel! neq 0 exit /b !errorlevel!
) ELSE (
copy C:\%output_user_root%\openvino\licenses %license_dest%
if !errorlevel! neq 0 exit /b !errorlevel!
)
copy %cd%\release_files\LICENSE %cd%\dist\windows\ovms\
if !errorlevel! neq 0 exit /b !errorlevel!
copy %cd%\release_files\thirdparty-licenses\* %license_dest%
if !errorlevel! neq 0 exit /b !errorlevel!
:: Bundle eSpeak-ng license text when eSpeak artifacts are included.
set "espeak_license_src="
for /f "delims=" %%F in ('dir /b /s /a:-d "%cd%\bazel-out\x64_windows-opt\bin\external\espeak_ng\COPYING*" 2^>nul') do (
set "espeak_license_src=%%F"
goto :copy_espeak_license
)
for /f "delims=" %%F in ('dir /b /s /a:-d "%cd%\bazel-out\x64_windows-opt\bin\external\espeak_ng\LICENSE*" 2^>nul') do (
set "espeak_license_src=%%F"
goto :copy_espeak_license
)
:copy_espeak_license
if defined espeak_license_src (
copy /Y "!espeak_license_src!" "%license_dest%espeak-ng.LICENSE.txt"
if !errorlevel! neq 0 exit /b !errorlevel!
)
set "curl_dir=curl-!curl_version!-win64-mingw"
echo Adding curl licenses from !curl_dir!...
copy C:\opt\!curl_dir!\COPYING.txt %license_dest%LICENSE-CURL.txt
if !errorlevel! neq 0 exit /b !errorlevel!
copy C:\opt\!curl_dir!\dep\brotli\LICENSE.txt %license_dest%LICENSE-BROTLI.txt
if !errorlevel! neq 0 exit /b !errorlevel!
copy C:\opt\!curl_dir!\dep\certdata\LICENSE.url %license_dest%LICENSE-CERTDATA.url
if !errorlevel! neq 0 exit /b !errorlevel!
copy C:\opt\!curl_dir!\dep\libpsl\COPYING.txt %license_dest%LICENSE-LIBPSL.txt
if !errorlevel! neq 0 exit /b !errorlevel!
copy C:\opt\!curl_dir!\dep\libressl\COPYING.txt %license_dest%LICENSE-LIBRESSL.txt
if !errorlevel! neq 0 exit /b !errorlevel!
copy C:\opt\!curl_dir!\dep\libssh2\COPYING.txt %license_dest%LICENSE-LIBSSH2.txt
if !errorlevel! neq 0 exit /b !errorlevel!
copy C:\opt\!curl_dir!\dep\nghttp2\COPYING.txt %license_dest%LICENSE-NGHTTP2.txt
if !errorlevel! neq 0 exit /b !errorlevel!
copy C:\opt\!curl_dir!\dep\nghttp3\COPYING.txt %license_dest%LICENSE-NGHTTP3.txt
if !errorlevel! neq 0 exit /b !errorlevel!
copy C:\opt\!curl_dir!\dep\ngtcp2\COPYING.txt %license_dest%LICENSE-NGTCP2.txt
if !errorlevel! neq 0 exit /b !errorlevel!
copy C:\opt\!curl_dir!\dep\zlibng\LICENSE.md %license_dest%LICENSE-ZLIBNG.md
if !errorlevel! neq 0 exit /b !errorlevel!
copy C:\opt\!curl_dir!\dep\zstd\LICENSE.txt %license_dest%LICENSE-ZSTD.txt
:: Add when CAPI enabled and tested
::mkdir -vp /ovms_release/include && cp /ovms/src/ovms.h /ovms_release/include
:: Testing package
call dist\windows\ovms\setupvars.bat
if !errorlevel! neq 0 exit /b !errorlevel!
dist\windows\ovms\ovms.exe --version
if !errorlevel! neq 0 exit /b !errorlevel!
dist\windows\ovms\ovms.exe --help
if !errorlevel! neq 0 exit /b !errorlevel!
if /i "%with_python%"=="true" (
if not exist dist\windows\ovms\libovmspython.dll (
echo Packaging validation failed: libovmspython.dll is missing from dist\windows\ovms.
exit /b 1
)
if not exist dist\windows\ovms\libpython_calculators.dll (
echo Packaging validation failed: libpython_calculators.dll is missing from dist\windows\ovms.
exit /b 1
)
)
cd dist\windows
C:\Windows\System32\tar.exe -a -c -f ovms.zip ovms
if !errorlevel! neq 0 exit /b !errorlevel!
cd ..\..
dir dist\windows\ovms.zip
echo [INFO] Package created