Merge pull request #47 from you-win/feature/add-github-workflow

add build workflow for windows, mac, and linux
This commit is contained in:
Emiliana 2022-09-13 16:20:35 +02:00 • committed by GitHub
commit 670df51c0d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 142 additions and 12 deletions

View file

@ -0,0 +1,26 @@
name: Upload dated artifact
description: Uploads an artifact with a datetime
inputs:
name:
description: The name of the artifact
required: true
path:
description: The path to the file/folder to upload
required: true
runs:
using: composite
steps:
# https://stackoverflow.com/questions/60942067/get-current-date-and-time-in-github-workflows
- name: Get current datetime
id: date
shell: bash
run: echo "::set-output name=date::$(date '+%Y-%m-%d_%H-%M-%S')"
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: ${{ inputs.name }}_${{ steps.date.outputs.date }}
path: ${{ inputs.path }}
if-no-files-found: error

87
.github/workflows/create-binaries.yaml vendored Normal file
View file

@ -0,0 +1,87 @@
name: Package using PyInstaller
on:
push:
tags:
- v**
workflow_dispatch:
jobs:
build-windows:
env:
dist-path: dist/OpenSeeFace
runs-on: windows-latest
steps:
- name: Pull OpenSeeFace
uses: actions/checkout@v3
- name: Create binary
shell: cmd
run: |
choco install vcredist140
xcopy c:\Windows\System32\msvcp140.dll .
xcopy c:\Windows\System32\vcomp140.dll .
xcopy c:\Windows\System32\concrt140.dll .
xcopy c:\Windows\System32\vccorlib140.dll .
make_exe.bat
- name: Move files for uploading
shell: bash
run: |
# Prevents the parent dist/ directory from being included
mv dist/facetracker ${{ env.dist-path }}
cp -r models ${{ env.dist-path }}
- name: Upload artifact
uses: ./.github/actions/upload-dated-artifact
with:
name: windows
path: dist # Add the parent directory to prevent a tarbomb
# Files must be packed into a tar in order for file permissions to be preserved
build-unix:
env:
artifact-path: OpenSeeFace
tar-path: OpenSeeFace.tar
strategy:
fail-fast: false
matrix:
include:
- name: linux
os: ubuntu-latest
- name: mac
os: macos-latest
runs-on: ${{ matrix.os }}
steps:
- name: Pull OpenSeeFace
uses: actions/checkout@v3
- name: Create binary
shell: bash
run: |
chmod +x make_exe.sh
./make_exe.sh
- name: Move files for uploading
shell: bash
run: |
# Prevents the parent dist/ directory from being included
mv dist/facetracker ${{ env.artifact-path }}
cp -r models ${{ env.artifact-path }}
- name: Fix permissions from PyInstaller
shell: bash
run: |
find ${{ env.artifact-path }} -type f -exec chmod -x {} +
chmod +x ${{ env.artifact-path }}/facetracker
- name: Pack files into tar
shell: bash
run: tar -cvf ${{ env.tar-path }} ${{ env.artifact-path }}
- name: Upload artifact
uses: ./.github/actions/upload-dated-artifact
with:
name: ${{ matrix.name }}
path: ${{ env.tar-path }}

View file

@ -1,16 +1,31 @@
pyinstaller facetracker.spec --onedir ^ echo "Started"
--add-binary dshowcapture/dshowcapture_x86.dll;. ^
--add-binary dshowcapture/dshowcapture_x64.dll;. ^ :: A venv is used so it's easy to add the onnxruntime dll to the binary
--add-binary dshowcapture/libminibmcapture32.dll;. ^
--add-binary dshowcapture/libminibmcapture64.dll;. ^ echo "Creating venv"
--add-binary escapi/escapi_x86.dll;. ^ python -m venv venv
--add-binary escapi/escapi_x64.dll;. ^
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 --clean ^
--onedir ^
--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 msvcp140.dll;. ^
--add-binary vcomp140.dll;. ^ --add-binary vcomp140.dll;. ^
--add-binary concrt140.dll;. ^ --add-binary concrt140.dll;. ^
--add-binary vccorlib140.dll;. ^ --add-binary vccorlib140.dll;. ^
--add-binary run.bat;. --add-binary run.bat;.
del dist\facetracker\cv2\opencv_videoio_ffmpeg420_64.dll echo "Deleting opencv dll"
del dist\facetracker\cv2\opencv_videoio_*
pause echo "Finished"

View file

@ -1,5 +1,7 @@
#!/bin/bash #!/bin/bash
set -e
PYTHON_BINARY=$(which python3) PYTHON_BINARY=$(which python3)
if [[ -z "$PYTHON_BINARY" ]]; then if [[ -z "$PYTHON_BINARY" ]]; then
@ -12,18 +14,18 @@ if [[ -z "$PYTHON_BINARY" ]]; then
fi fi
echo "Creating venv" echo "Creating venv"
"$PYTHON_BINARY" -m venv venv "$PYTHON_BINARY" -m venv venv
source venv/bin/activate source venv/bin/activate
echo "Installing packages" echo "Installing packages"
pip install wheel # Make sure this is installed beforehand
pip install onnxruntime opencv-python==4.5.4.60 pillow numpy pyinstaller pip install onnxruntime opencv-python==4.5.4.60 pillow numpy pyinstaller
echo "Creating binary" echo "Creating binary"
pyinstaller --onedir --clean facetracker.py \
pyinstaller --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 "Files should be available in the dist/ folder"
echo "Done!" echo "Done!"