From 022a0520fa7624c5225c27b5343c4d656080141b Mon Sep 17 00:00:00 2001 From: Tim Yuen Date: Sat, 10 Sep 2022 23:24:22 -0400 Subject: [PATCH] Update make_exe.bat to use a venv, explicitly add onnxruntime dll to pyinstaller binary, add debug prints during build --- .github/workflows/create-binaries.yaml | 2 +- make_exe.bat | 28 +++++++++++++++++++------- make_exe.sh | 8 +++++--- 3 files changed, 27 insertions(+), 11 deletions(-) diff --git a/.github/workflows/create-binaries.yaml b/.github/workflows/create-binaries.yaml index a705d7b..d799714 100644 --- a/.github/workflows/create-binaries.yaml +++ b/.github/workflows/create-binaries.yaml @@ -40,7 +40,7 @@ jobs: make_exe.bat - - name: Move and zip files + - name: Move files for uploading shell: bash # Using bash for all OSs should be fine, even on Windows run: | mv dist/facetracker ${{ env.dist-folder-path }} diff --git a/make_exe.bat b/make_exe.bat index 36c6f62..8c55e0b 100644 --- a/make_exe.bat +++ b/make_exe.bat @@ -1,16 +1,30 @@ +echo "Started" + +:: A venv is used so it's easy to add the onnxruntime dll to the binary + +echo "Creating venv" +python -m venv venv + +echo "Activating venv" +call venv\Scripts\activate.bat + +echo "Installing dependencies" +pip install wheel + pip install onnxruntime opencv-python==4.5.4.60 pillow numpy pyinstaller +echo "Running pyinstaller" pyinstaller facetracker.py --onedir ^ - --add-binary dshowcapture/dshowcapture_x86.dll;. ^ - --add-binary dshowcapture/dshowcapture_x64.dll;. ^ - --add-binary dshowcapture/libminibmcapture32.dll;. ^ - --add-binary dshowcapture/libminibmcapture64.dll;. ^ - --add-binary escapi/escapi_x86.dll;. ^ - --add-binary escapi/escapi_x64.dll;. ^ + --add-binary dshowcapture/*.dll;. ^ + --add-binary escapi/*.dll;. ^ + --add-binary venv/lib/site-packages/onnxruntime/capi/*.dll;onnxruntime\capi ^ --add-binary msvcp140.dll;. ^ --add-binary vcomp140.dll;. ^ --add-binary concrt140.dll;. ^ --add-binary vccorlib140.dll;. ^ --add-binary run.bat;. -del dist\facetracker\cv2\opencv_videoio_* \ No newline at end of file +echo "Deleting opencv dll" +del dist\facetracker\cv2\opencv_videoio_* + +echo "Finished" diff --git a/make_exe.sh b/make_exe.sh index dd2fd70..834d486 100755 --- a/make_exe.sh +++ b/make_exe.sh @@ -1,5 +1,7 @@ #!/bin/bash +set -e + PYTHON_BINARY=$(which python3) if [[ -z "$PYTHON_BINARY" ]]; then @@ -12,18 +14,18 @@ if [[ -z "$PYTHON_BINARY" ]]; then fi echo "Creating venv" - "$PYTHON_BINARY" -m venv venv source venv/bin/activate echo "Installing packages" +pip install wheel # Make sure this is installed beforehand pip install onnxruntime opencv-python==4.5.4.60 pillow numpy pyinstaller echo "Creating binary" - -pyinstaller --clean facetracker.py +pyinstaller --onedir --clean facetracker.py \ + --add-binary venv/lib/python3.*/site-packages/onnxruntime/capi/*.so:onnxruntime/capi echo "Files should be available in the dist/ folder" echo "Done!"