Skip to content

Create PyInstaller .exe #21

Create PyInstaller .exe

Create PyInstaller .exe #21

Workflow file for this run

name: Create PyInstaller .exe
on:
release:
types: [created]
workflow_dispatch:
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
jobs:
build-linux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Set up python
id: setup-python
uses: actions/setup-python@v6
with:
python-version: '3.12'
#----------------------------------------------
# ----- install & configure poetry -----
#----------------------------------------------
- name: Install Poetry
uses: snok/install-poetry@v1.4.2
with:
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true
- name: install dependencies
shell: bash
run: |
poetry install --with dev
- name: build exe with pyinstaller
shell: bash
run: |
poetry run pyinstaller \
--hidden-import=scipy.io \
--copy-metadata imageio \
--clean -y \
--dist output/clickpoints_run \
--onefile \
--icon "clickpoints/icons/ClickPoints.ico" \
--splash "clickpoints/icons/Splash.png" \
--add-data "clickpoints/icons:clickpoints/icons" \
--add-data "clickpoints/addons:clickpoints/addons" \
--hidden-import clickpoints.Addon \
--hidden-import clickpoints.includes.BigImageDisplay \
--hidden-import clickpoints.includes.ImageQt_Stride \
--hidden-import clickpoints.includes.MemMap \
--hidden-import clickpoints.includes.loadExamples \
--hidden-import clickpoints.includes.loader \
--hidden-import clickpoints.includes.matplotlibwidget \
--hidden-import clickpoints.includes.qextendedgraphicsview.QExtendedGraphicsView \
clickpoints/launch.py
mv output/clickpoints_run/launch output/clickpoints_run/clickpoints
chmod +x output/clickpoints_run/clickpoints
- uses: actions/upload-artifact@v7
with:
name: clickpoints_linux
path: output/clickpoints_run
- name: Upload GitHub release assets
run: gh release upload $TAG output/clickpoints_run/clickpoints --clobber
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG: v1.10.0
build-windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v6
- name: Set up python
id: setup-python
uses: actions/setup-python@v6
with:
python-version: '3.12'
#----------------------------------------------
# ----- install & configure poetry -----
#----------------------------------------------
- name: Install Poetry
uses: snok/install-poetry@v1.4.2
with:
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true
- name: install dependencies
shell: bash
run: |
poetry install --with dev
- name: build exe with pyinstaller
shell: bash
run: |
poetry run pyinstaller \
--hidden-import=scipy.io \
--copy-metadata imageio \
--clean -y \
--dist output/clickpoints_run \
--onefile \
--icon "clickpoints/icons/ClickPoints.ico" \
--add-data "clickpoints/addons:clickpoints/addons" \
--splash "clickpoints/icons/Splash.png" \
--hidden-import clickpoints.Addon \
--hidden-import clickpoints.includes.BigImageDisplay \
--hidden-import clickpoints.includes.ImageQt_Stride \
--hidden-import clickpoints.includes.MemMap \
--hidden-import clickpoints.includes.loadExamples \
--hidden-import clickpoints.includes.loader \
--hidden-import clickpoints.includes.matplotlibwidget \
--hidden-import clickpoints.includes.qextendedgraphicsview.QExtendedGraphicsView \
clickpoints/launch.py
mv output/clickpoints_run/launch.exe output/clickpoints_run/clickpoints.exe
- uses: actions/upload-artifact@v7
with:
name: clickpoints_windows
path: output/clickpoints_run
- name: Upload GitHub release assets
run: gh release upload v1.10.0 "output\clickpoints_run\clickpoints.exe" --clobber
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG: v1.10.0
build-mac:
runs-on: macos-14
steps:
- uses: actions/checkout@v6
- name: Set up python
id: setup-python
uses: actions/setup-python@v6
with:
python-version: '3.12'
- name: Install Poetry
uses: snok/install-poetry@v1.4.2
with:
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true
- name: Install dependencies
shell: bash
run: |
poetry install --with dev
brew install create-dmg
- name: Import Apple signing certificate
shell: bash
env:
MACOS_CERTIFICATE: ${{ secrets.MACOS_CERTIFICATE }}
MACOS_CERTIFICATE_PWD: ${{ secrets.MACOS_CERTIFICATE_PWD }}
KEYCHAIN_PWD: ${{ secrets.KEYCHAIN_PWD }}
run: |
echo "$MACOS_CERTIFICATE" | base64 --decode > certificate.p12
security create-keychain -p "$KEYCHAIN_PWD" build.keychain
security default-keychain -s build.keychain
security unlock-keychain -p "$KEYCHAIN_PWD" build.keychain
security import certificate.p12 -k build.keychain -P "$MACOS_CERTIFICATE_PWD" -T /usr/bin/codesign
security set-key-partition-list -S apple-tool:,apple: -s -k "$KEYCHAIN_PWD" build.keychain
- name: Build executable with PyInstaller
shell: bash
run: |
poetry run pyinstaller \
--copy-metadata imageio \
--clean -y \
--dist output/clickpoints_run \
--windowed \
--name "ClickPoints" \
--osx-bundle-identifier "org.fabrylab.clickpoints" \
--icon "clickpoints/icons/ClickPoints.icns" \
--add-data "clickpoints/icons:clickpoints/icons" \
--hidden-import clickpoints.Addon \
--hidden-import clickpoints.includes.BigImageDisplay \
--hidden-import clickpoints.includes.ImageQt_Stride \
--hidden-import clickpoints.includes.MemMap \
--hidden-import clickpoints.includes.loadExamples \
--hidden-import clickpoints.includes.loader \
--hidden-import clickpoints.includes.matplotlibwidget \
--hidden-import clickpoints.includes.qextendedgraphicsview.QExtendedGraphicsView \
--exclude-module PyQt5 \
--exclude-module PyQt6 \
--exclude-module PySide2 \
--exclude-module PySide6.QtWebEngineCore \
--exclude-module PySide6.QtWebEngineWidgets \
clickpoints/launch.py
- name: Add macOS document type associations
shell: bash
run: |
PLIST="output/clickpoints_run/ClickPoints.app/Contents/Info.plist"
/usr/libexec/PlistBuddy -c "Set :CFBundleDisplayName ClickPoints" "$PLIST"
/usr/libexec/PlistBuddy -c "Set :CFBundleName ClickPoints" "$PLIST"
/usr/libexec/PlistBuddy -c "Delete :CFBundleDocumentTypes" "$PLIST" 2>/dev/null || true
/usr/libexec/PlistBuddy -c "Add :CFBundleDocumentTypes array" "$PLIST"
/usr/libexec/PlistBuddy -c "Add :CFBundleDocumentTypes:0 dict" "$PLIST"
/usr/libexec/PlistBuddy -c "Add :CFBundleDocumentTypes:0:CFBundleTypeName string 'ClickPoints Database'" "$PLIST"
/usr/libexec/PlistBuddy -c "Add :CFBundleDocumentTypes:0:CFBundleTypeRole string Editor" "$PLIST"
/usr/libexec/PlistBuddy -c "Add :CFBundleDocumentTypes:0:LSHandlerRank string Owner" "$PLIST"
/usr/libexec/PlistBuddy -c "Add :CFBundleDocumentTypes:0:CFBundleTypeExtensions array" "$PLIST"
/usr/libexec/PlistBuddy -c "Add :CFBundleDocumentTypes:0:CFBundleTypeExtensions:0 string cdb" "$PLIST"
/usr/libexec/PlistBuddy -c "Add :CFBundleDocumentTypes:1 dict" "$PLIST"
/usr/libexec/PlistBuddy -c "Add :CFBundleDocumentTypes:1:CFBundleTypeName string 'Image Files'" "$PLIST"
/usr/libexec/PlistBuddy -c "Add :CFBundleDocumentTypes:1:CFBundleTypeRole string Editor" "$PLIST"
/usr/libexec/PlistBuddy -c "Add :CFBundleDocumentTypes:1:LSHandlerRank string Alternate" "$PLIST"
/usr/libexec/PlistBuddy -c "Add :CFBundleDocumentTypes:1:CFBundleTypeExtensions array" "$PLIST"
for ext in tif tiff png jpg jpeg bmp gif; do
/usr/libexec/PlistBuddy -c "Add :CFBundleDocumentTypes:1:CFBundleTypeExtensions: string $ext" "$PLIST"
done
/usr/libexec/PlistBuddy -c "Add :CFBundleDocumentTypes:2 dict" "$PLIST"
/usr/libexec/PlistBuddy -c "Add :CFBundleDocumentTypes:2:CFBundleTypeName string 'Video Files'" "$PLIST"
/usr/libexec/PlistBuddy -c "Add :CFBundleDocumentTypes:2:CFBundleTypeRole string Editor" "$PLIST"
/usr/libexec/PlistBuddy -c "Add :CFBundleDocumentTypes:2:LSHandlerRank string Alternate" "$PLIST"
/usr/libexec/PlistBuddy -c "Add :CFBundleDocumentTypes:2:CFBundleTypeExtensions array" "$PLIST"
for ext in avi mp4 mov mkv; do
/usr/libexec/PlistBuddy -c "Add :CFBundleDocumentTypes:2:CFBundleTypeExtensions: string $ext" "$PLIST"
done
- name: Sign macOS app
shell: bash
env:
DEVELOPER_ID_APPLICATION: ${{ secrets.DEVELOPER_ID_APPLICATION }}
run: |
codesign --force --deep --options runtime --timestamp \
--entitlements .github/macos/entitlements.plist \
--sign "$DEVELOPER_ID_APPLICATION" \
output/clickpoints_run/ClickPoints.app
codesign --verify --deep --strict --verbose=2 output/clickpoints_run/ClickPoints.app
- name: Notarize macOS app
shell: bash
env:
APPLE_ID: ${{ secrets.APPLE_ID }}
APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.APPLE_APP_SPECIFIC_PASSWORD }}
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
run: |
ditto -c -k --keepParent output/clickpoints_run/ClickPoints.app output/clickpoints_run/ClickPoints.notary.zip
xcrun notarytool submit output/clickpoints_run/ClickPoints.notary.zip \
--apple-id "$APPLE_ID" \
--password "$APPLE_APP_SPECIFIC_PASSWORD" \
--team-id "$APPLE_TEAM_ID" \
--wait
xcrun stapler staple output/clickpoints_run/ClickPoints.app
xcrun stapler validate output/clickpoints_run/ClickPoints.app
rm output/clickpoints_run/ClickPoints.notary.zip
ditto -c -k --keepParent output/clickpoints_run/ClickPoints.app output/clickpoints_run/ClickPoints.app.zip
- name: Create notarized macOS DMG
shell: bash
env:
APPLE_ID: ${{ secrets.APPLE_ID }}
APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.APPLE_APP_SPECIFIC_PASSWORD }}
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
DEVELOPER_ID_APPLICATION: ${{ secrets.DEVELOPER_ID_APPLICATION }}
run: |
create-dmg \
--volname "ClickPoints" \
--window-pos 200 120 \
--window-size 600 400 \
--icon-size 100 \
--icon "ClickPoints.app" 175 190 \
--app-drop-link 425 190 \
"output/clickpoints_run/ClickPoints-mac.dmg" \
"output/clickpoints_run/ClickPoints.app"
codesign --force --timestamp \
--sign "$DEVELOPER_ID_APPLICATION" \
output/clickpoints_run/ClickPoints-mac.dmg
xcrun notarytool submit output/clickpoints_run/ClickPoints-mac.dmg \
--apple-id "$APPLE_ID" \
--password "$APPLE_APP_SPECIFIC_PASSWORD" \
--team-id "$APPLE_TEAM_ID" \
--wait
xcrun stapler staple output/clickpoints_run/ClickPoints-mac.dmg
xcrun stapler validate output/clickpoints_run/ClickPoints-mac.dmg
- uses: actions/upload-artifact@v7
with:
name: clickpoints_mac
path: output/clickpoints_run
- name: Upload GitHub release assets
run: |
gh release upload $TAG output/clickpoints_run/ClickPoints.app.zip --clobber
gh release upload $TAG output/clickpoints_run/ClickPoints-mac.dmg --clobber
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG: v1.10.0