Skip to content

Commit 265a69d

Browse files
committed
Windows executable seems to work again. Lets build on github worker
1 parent 7084a33 commit 265a69d

File tree

3 files changed

+111
-2
lines changed

3 files changed

+111
-2
lines changed

.github/workflows/build.yml

Lines changed: 94 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Publish Python 🐍 distributions 📦 to PyPI
1+
name: Build executables and publish 🐍 package 📦 to PyPI
22

33
on:
44
workflow_dispatch:
@@ -7,6 +7,99 @@ on:
77
- "published"
88

99
jobs:
10+
build:
11+
strategy:
12+
fail-fast: false
13+
matrix:
14+
os:
15+
- "windows-latest"
16+
#- "macos-latest"
17+
#- "ubuntu-latest"
18+
python:
19+
- "3.10.x"
20+
cx-freeze:
21+
- "v6.14.2"
22+
name: "Build exe for ${{ matrix.os }}"
23+
runs-on: "${{ matrix.os }}"
24+
steps:
25+
26+
# === SETUP ===
27+
28+
- name: "Setup python"
29+
uses: "actions/setup-python@v4"
30+
with:
31+
python-version: "${{ matrix.python }}"
32+
33+
- name: "Install cx_Freeze bootloader"
34+
run: |
35+
python -m pip install cx_Freeze==${{ matrix.cx-freeze }}
36+
37+
# === BUILD ===
38+
39+
- name: "Clone repo"
40+
uses: "actions/checkout@v3"
41+
with:
42+
path: "./src/"
43+
44+
- name: "Install requirements"
45+
run: |
46+
cd ./src/
47+
python -m pip install -U -r ./requirements.txt
48+
49+
- name: "Build"
50+
if: "runner.os != 'macOS'"
51+
run: |
52+
cd ./src/
53+
python ./buildGUI.py build
54+
mv ./build/*/ ./dist/
55+
56+
- name: "Build macOS"
57+
if: "runner.os == 'macOS'"
58+
run: |
59+
cd ./src/
60+
python ./buildGUI.py bdist_mac
61+
mkdir ./dist/
62+
mv ./build/*.app/ ./dist/
63+
64+
- name: "Resolve symlinks"
65+
if: "runner.os != 'Windows'"
66+
run: |
67+
cd ./src/dist/
68+
find ./ -type l -exec echo Resolving {} \; -exec sed -i '' {} \;
69+
70+
# export Apple development certificate from Xcode: https://help.apple.com/xcode/mac/current/#/dev154b28f09
71+
# base64 CERTIFICATE.p12 | pbcopy -> secrets.CODESIGN_P12_BASE64
72+
- name: "Import macOS codesign certificate"
73+
if: "runner.os == 'macOS'"
74+
uses: "apple-actions/import-codesign-certs@v1"
75+
with:
76+
p12-file-base64: "${{ secrets.CODESIGN_P12_BASE64 }}"
77+
p12-password: "${{ secrets.CODESIGN_P12_PASSWORD }}"
78+
79+
# security find-identity, returns something like:
80+
# A30C8432FADE0B3E7D5BA54034EF2ECA39A0BDD0 "Apple Development: [email protected] (6LR9J7UR6F)"
81+
# the first hex string is your identity -> secrets.CODESIGN_P12_NAME
82+
- name: "Codesign macOS"
83+
if: "runner.os == 'macOS'"
84+
run: |
85+
cd ./src/dist/
86+
find ./ -type f -empty -delete
87+
codesign -s "${{ secrets.CODESIGN_P12_NAME }}" --deep -f ./*.app
88+
89+
# === ARTIFACT ===
90+
91+
- name: "Zip artifact"
92+
run: |
93+
7z a -r ./${{ github.event.repository.name }}-${{ runner.os }}.zip ./src/dist/*
94+
95+
- name: "Upload release artifact"
96+
uses: "softprops/action-gh-release@v1"
97+
env:
98+
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
99+
with:
100+
files: "./${{ github.event.repository.name }}-${{ runner.os }}.zip"
101+
102+
10103
wheel:
11104
name: Package 📦 wheel
12105
runs-on: ubuntu-latest

buildGUI.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@ def get_include_files():
1717
for f in d.iterdir():
1818
if f.is_file() and f.suffix=='' or f.suffix in ['.dll']:
1919
files.append((f,pathlib.Path('lib')/f.name))
20+
# opencv dll
21+
for d in site.getsitepackages():
22+
d=pathlib.Path(d)/'cv2'
23+
if d.is_dir():
24+
for f in d.iterdir():
25+
if f.is_file() and f.suffix=='' or f.suffix in ['.dll']:
26+
files.append((f,pathlib.Path('lib')/f.name))
2027
# ffpyplayer bin deps
2128
for d in site.getsitepackages():
2229
d=pathlib.Path(d)/'share'/'ffpyplayer'

main.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
11
#!/usr/bin/env python
22
import sys
3+
import multiprocessing
34

45
if getattr(sys, "frozen", False):
5-
raise RuntimeError('No freeze support for this code')
6+
if not sys.platform.startswith("win"):
7+
raise "Executable is only supported on Windows"
8+
9+
# need to call this so that code in __init__ of ffpyplayer
10+
# doesn't encounter a None in site.USER_BASE
11+
import site
12+
site.getuserbase()
613

714
if __name__=="__main__":
15+
multiprocessing.freeze_support()
16+
817
import glassesValidator
918
glassesValidator.GUI.run()

0 commit comments

Comments
 (0)