refine build scripts

This commit is contained in:
Alex Bezdieniezhnykh
2025-04-30 10:23:06 +03:00
parent 4e2d3c7e4f
commit be8e8bdc56
3 changed files with 24 additions and 135 deletions
-75
View File
@@ -1,75 +0,0 @@
# -*- mode: python ; coding: utf-8 -*-
from PyInstaller.utils.hooks import collect_all
datas = []
binaries = []
hiddenimports = ['constants', 'annotation', 'credentials', 'file_data', 'user', 'security', 'secure_model', 'cdn_manager', 'api_client', 'hardware_service', 'remote_command', 'ai_config', 'inference_engine', 'inference', 'remote_command_handler']
tmp_ret = collect_all('jwt')
datas += tmp_ret[0]; binaries += tmp_ret[1]; hiddenimports += tmp_ret[2]
tmp_ret = collect_all('requests')
datas += tmp_ret[0]; binaries += tmp_ret[1]; hiddenimports += tmp_ret[2]
tmp_ret = collect_all('psutil')
datas += tmp_ret[0]; binaries += tmp_ret[1]; hiddenimports += tmp_ret[2]
tmp_ret = collect_all('msgpack')
datas += tmp_ret[0]; binaries += tmp_ret[1]; hiddenimports += tmp_ret[2]
tmp_ret = collect_all('zmq')
datas += tmp_ret[0]; binaries += tmp_ret[1]; hiddenimports += tmp_ret[2]
tmp_ret = collect_all('cryptography')
datas += tmp_ret[0]; binaries += tmp_ret[1]; hiddenimports += tmp_ret[2]
tmp_ret = collect_all('cv2')
datas += tmp_ret[0]; binaries += tmp_ret[1]; hiddenimports += tmp_ret[2]
tmp_ret = collect_all('onnxruntime')
datas += tmp_ret[0]; binaries += tmp_ret[1]; hiddenimports += tmp_ret[2]
tmp_ret = collect_all('tensorrt')
datas += tmp_ret[0]; binaries += tmp_ret[1]; hiddenimports += tmp_ret[2]
tmp_ret = collect_all('pycuda')
datas += tmp_ret[0]; binaries += tmp_ret[1]; hiddenimports += tmp_ret[2]
tmp_ret = collect_all('pynvml')
datas += tmp_ret[0]; binaries += tmp_ret[1]; hiddenimports += tmp_ret[2]
tmp_ret = collect_all('re')
datas += tmp_ret[0]; binaries += tmp_ret[1]; hiddenimports += tmp_ret[2]
tmp_ret = collect_all('boto3')
datas += tmp_ret[0]; binaries += tmp_ret[1]; hiddenimports += tmp_ret[2]
a = Analysis(
['start.py'],
pathex=[],
binaries=binaries,
datas=datas,
hiddenimports=hiddenimports,
hookspath=[],
hooksconfig={},
runtime_hooks=[],
excludes=[],
noarchive=False,
optimize=0,
)
pyz = PYZ(a.pure)
exe = EXE(
pyz,
a.scripts,
[],
exclude_binaries=True,
name='azaion-inference',
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='azaion-inference',
)
+23 -7
View File
@@ -1,7 +1,23 @@
venv\Scripts\python setup.py build_ext echo Build Cython app
rmdir dist /s /q
pyinstaller --name=azaion-inference ^ cd %~dp0
--collect-all pyyaml ^
echo remove dist folder:
if exist dist rmdir dist /s /q
if exist build rmdir build /s /q
if exist venv rmdir venv /s /q
echo install python and dependencies
python -m venv venv
venv\Scripts\python -m pip install --upgrade pip
venv\Scripts\pip install -r requirements.txt
venv\Scripts\pip install --upgrade pyinstaller pyinstaller-hooks-contrib
venv\Scripts\python setup.py build_ext --inplace
echo install azaion-inference
venv\Scripts\pyinstaller --name=azaion-inference ^
--collect-all jwt ^ --collect-all jwt ^
--collect-all requests ^ --collect-all requests ^
--collect-all psutil ^ --collect-all psutil ^
@@ -9,6 +25,7 @@ pyinstaller --name=azaion-inference ^
--collect-all zmq ^ --collect-all zmq ^
--collect-all cryptography ^ --collect-all cryptography ^
--collect-all cv2 ^ --collect-all cv2 ^
--collect-all numpy ^
--collect-all onnxruntime ^ --collect-all onnxruntime ^
--collect-all tensorrt ^ --collect-all tensorrt ^
--collect-all pycuda ^ --collect-all pycuda ^
@@ -32,6 +49,5 @@ pyinstaller --name=azaion-inference ^
--hidden-import remote_command_handler ^ --hidden-import remote_command_handler ^
start.py start.py
copy venv\Lib\site-packages\tensorrt_libs\nvinfer_10.dll .\dist\azaion-inference\ xcopy /E dist\azaion-inference ..\dist\
copy venv\Lib\site-packages\tensorrt_libs\nvinfer_plugin_10.dll .\dist\azaion-inference\ copy config.production.yaml ..\dist\config.yaml
copy venv\Lib\site-packages\tensorrt_libs\nvonnxparser_10.dll .\dist\azaion-inference\
+1 -53
View File
@@ -20,59 +20,7 @@ mkdir dist\dummy
move dist\Azaion.Annotator.dll dist\dummy\ move dist\Azaion.Annotator.dll dist\dummy\
move dist\Azaion.Dataset.dll dist\dummy\ move dist\Azaion.Dataset.dll dist\dummy\
echo Build Cython app call Azaion.Inference\build.cmd
cd Azaion.Inference
echo remove dist folder:
if exist dist rmdir dist /s /q
echo install python and dependencies
python -m venv venv
venv\Scripts\pip install -r requirements.txt
venv\Scripts\pip uninstall -y opencv-python
venv\Scripts\pip install opencv-python
venv\Scripts\python setup.py build_ext --inplace
echo install azaion-inference
venv\Scripts\pyinstaller --name=azaion-inference ^
--collect-all jwt ^
--collect-all requests ^
--collect-all psutil ^
--collect-all msgpack ^
--collect-all zmq ^
--collect-all cryptography ^
--collect-all cv2 ^
--collect-all onnxruntime ^
--collect-all tensorrt ^
--collect-all pycuda ^
--collect-all pynvml ^
--collect-all re ^
--collect-all boto3 ^
--hidden-import constants ^
--hidden-import annotation ^
--hidden-import credentials ^
--hidden-import file_data ^
--hidden-import user ^
--hidden-import security ^
--hidden-import secure_model ^
--hidden-import cdn_manager ^
--hidden-import api_client ^
--hidden-import hardware_service ^
--hidden-import remote_command ^
--hidden-import ai_config ^
--hidden-import inference_engine ^
--hidden-import inference ^
--hidden-import remote_command_handler ^
start.py
xcopy /E dist\azaion-inference ..\dist\
copy venv\Lib\site-packages\tensorrt_libs\nvinfer_10.dll ..\dist
copy venv\Lib\site-packages\tensorrt_libs\nvinfer_plugin_10.dll ..\dist
copy venv\Lib\site-packages\tensorrt_libs\nvonnxparser_10.dll ..\dist
copy config.production.yaml ..\dist\config.yaml
cd..
echo Download onnx model echo Download onnx model
cd build cd build