Skip to content

Commit

Permalink
bundle: support macos (#675)
Browse files Browse the repository at this point in the history
  • Loading branch information
cosven authored Apr 19, 2023
1 parent 135d8a8 commit 875d6d2
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 11 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/macos-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Release for macos
on:
push:
tags:
- v*
workflow_dispatch:

jobs:
build-n-publish:
runs-on: macos-latest
steps:
- uses: actions/checkout@master
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: "3.10"
- name: Build
run: |
python -m pip install --upgrade pip
pip install pyqt5
pip install pyinstaller
pip install -e .[macos,battery]
- name: Install libmpv
run: |
brew install mpv
- name: Archive
run: |
# List dist to help double check if bundle is ok.
ls dist/
cd dist/ && zip FeelUOwnX.zip -r FeelUOwnX.app/
- name: Upload artifact
uses: actions/upload-artifact@master
with:
name: FeelUOwnX.zip
path: dist/FeelUOwnX.app
- name: Upload to release page
if: startsWith(github.ref, 'refs/tags/v')
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
files: dist/FeelUOwnX.zip
8 changes: 4 additions & 4 deletions .github/workflows/win-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,16 @@ jobs:
run: |
# List dist to help double check if bundle is ok.
ls dist/
powershell Compress-Archive dist/FeelUOwn dist/FeelUOwn-win64.zip
powershell Compress-Archive dist/FeelUOwn dist/FeelUOwn-windows.zip
- name: Upload artifact
uses: actions/upload-artifact@master
with:
name: FeelUOwn-win64.zip
path: dist/FeelUOwn-win64.zip
name: FeelUOwn-windows.zip
path: dist/FeelUOwn
- name: Upload to release page
if: startsWith(github.ref, 'refs/tags/v')
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
files: dist/FeelUOwn-win64.zip
files: dist/FeelUOwn-windows.zip
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

# pyinstaller
/FeelUOwn.spec
/FeelUOwnX.spec

*.mp3

Expand Down
22 changes: 17 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,30 @@ integration_test:

test: lint unittest

BUNDLE_FLAGS=
ifeq ($(OS),Windows_NT)
BUNDLE_FLAGS += --name FeelUOwn
else
# macOS: since apfs is not case-sensitive, we use FeelUOwnX instead of FeelUOwn
BUNDLE_FLAGS += --name FeelUOwnX --osx-bundle-identifier org.feeluown.FeelUOwnX
endif
# Please install pyinstaller manually.
bundle:
pyinstaller -w feeluown/pyinstaller/main.py \
--icon feeluown/gui/assets/icons/feeluown.ico \
--name FeelUOwn \
--icon feeluown/gui/assets/icons/feeluown.icns \
${BUNDLE_FLAGS} \
-w \
--noconfirm

clean:
find . -name "*~" -exec rm -f {} \;
clean: clean_py clean_emacs

clean_py:
find . -name "*.pyc" -exec rm -f {} \;
find . -name __pycache__ -delete
find . -name .mypy_cache/ -delete

clean_emacs:
find . -name "*~" -exec rm -f {} \;
find . -name "*flymake.py" -exec rm -f {} \;
find . -name "\#*.py\#" -exec rm -f {} \;
find . -name ".\#*.py\#" -exec rm -f {} \;
find . -name __pycache__ -delete
5 changes: 5 additions & 0 deletions feeluown/pyinstaller/main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import sys
import os
import feeluown.__main__


if __name__ == '__main__':
if hasattr(sys, '_MEIPASS'):
os.chdir(sys._MEIPASS)

feeluown.__main__.main()
17 changes: 15 additions & 2 deletions pyinstaller_hooks/hook-feeluown.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,34 @@
import os
import sys
import ctypes
from PyInstaller.utils.hooks import collect_data_files, collect_entry_point


assets_files = [
'**/*.png',
'**/*.qss',
'**/*.svg',
'**/*.ico',
'**/*.icns',
'**/*.colors'
]
datas, hiddenimports = collect_entry_point('fuo.plugins_v1')

# aionowplaying is conditionally imported.
if os.name == 'nt':
hiddenimports.append('aionowplaying')
# pyinstaller can't detect 'aionowplaying.interface.windows' is imported.
hiddenimports.append('aionowplaying.interface.windows')
if sys.platform == 'darwin':
hiddenimports.append('aionowplaying.interface.macos')
hiddenimports.append('feeluown.aionowplaying.macos')

# Collect feeluown's resource files, like icons, qss files, etc.
# Collect plugins' resource files.
datas += collect_data_files('feeluown')
datas += collect_data_files('feeluown', includes=assets_files)
for pkg in hiddenimports:
datas += collect_data_files(pkg)
datas += collect_data_files(pkg, includes=assets_files)


# Collect mpv dynamic-link library.
if os.name == 'nt':
Expand Down

0 comments on commit 875d6d2

Please sign in to comment.