From 834c973cb5352c3961d58d4cf6a1fc7c089aa8e4 Mon Sep 17 00:00:00 2001 From: RP Date: Tue, 7 Mar 2023 15:58:42 -0800 Subject: [PATCH 1/4] mac build options; fix demo launching on mac --- tsuchinoko.spec | 45 +++++++++++++++++++++----------- tsuchinoko/widgets/mainwindow.py | 3 ++- 2 files changed, 32 insertions(+), 16 deletions(-) diff --git a/tsuchinoko.spec b/tsuchinoko.spec index 8eab841..895c0a9 100644 --- a/tsuchinoko.spec +++ b/tsuchinoko.spec @@ -5,6 +5,7 @@ import glob import dask import distributed import event_model +import torch from tsuchinoko import assets, examples import tsuchinoko @@ -36,11 +37,16 @@ datas_dst.append('tsuchinoko/examples') datas_src.append(os.path.join(examples.__path__[0], 'peak2.png')) datas_dst.append('tsuchinoko/examples') +# functorch +datas_src.append(os.path.join(torch.__path__[0],'lib','libiomp5.dylib')) +datas_dst.append('functools/.dylibs') + + print('extras:') print(list(zip(datas_src, datas_dst))) a = Analysis( - ['tsuchinoko\\examples\\client_demo.py'], + [os.path.join('tsuchinoko','examples','client_demo.py')], pathex=[], binaries=[], datas=zip(datas_src, datas_dst), @@ -52,7 +58,7 @@ a = Analysis( 'tsuchinoko.examples.quadtree_demo', 'tsuchinoko.examples.server_demo', 'tsuchinoko.examples.server_demo_bluesky', - 'tsuchinoko.examples.vector_metric_demo'], + 'tsuchinoko.examples.vector_metric_demo',], hookspath=[], hooksconfig={}, runtime_hooks=[], @@ -64,7 +70,7 @@ a = Analysis( ) a2 = Analysis( - ['tsuchinoko\\examples\\_launch_demo.py'], + [os.path.join('tsuchinoko','examples','_launch_demo.py')], pathex=[], binaries=[], datas=zip(datas_src, datas_dst), @@ -76,7 +82,7 @@ a2 = Analysis( 'tsuchinoko.examples.quadtree_demo', 'tsuchinoko.examples.server_demo', 'tsuchinoko.examples.server_demo_bluesky', - 'tsuchinoko.examples.vector_metric_demo'], + 'tsuchinoko.examples.vector_metric_demo',], hookspath=[], hooksconfig={}, runtime_hooks=[], @@ -96,12 +102,12 @@ exe = EXE( a.scripts, [], exclude_binaries=True, - name='Tsuchinoko', + name='tsuchinoko_client', debug=False, bootloader_ignore_signals=False, strip=False, upx=True, - console=True, + console=False, disable_windowed_traceback=False, argv_emulation=False, target_arch=None, @@ -120,7 +126,7 @@ exe2 = EXE( bootloader_ignore_signals=False, strip=False, upx=True, - console=True, + console=False, disable_windowed_traceback=False, argv_emulation=False, target_arch=None, @@ -129,13 +135,22 @@ exe2 = EXE( icon=assets.path('tsuchinoko.png') ) -coll = COLLECT( - exe, exe2, - a.binaries, a2.binaries, - a.zipfiles, a2.zipfiles, - a.datas, a2.datas, - strip=False, - upx=True, - upx_exclude=[], +#coll = COLLECT( +# exe, exe2, +# a.binaries, a2.binaries, +# a.zipfiles, a2.zipfiles, +# a.datas, a2.datas, +# strip=False, +# upx=True, +# upx_exclude=[], +# name='Tsuchinoko', +#) + +app = BUNDLE( + exe, exe2, a.binaries, a2.binaries, a.zipfiles, a2.zipfiles, a.datas, a2.datas, name='Tsuchinoko', + icon=assets.path('tsuchinoko.png'), + bundle_identifier=None, ) + + diff --git a/tsuchinoko/widgets/mainwindow.py b/tsuchinoko/widgets/mainwindow.py index fcebc8e..8e8d11d 100644 --- a/tsuchinoko/widgets/mainwindow.py +++ b/tsuchinoko/widgets/mainwindow.py @@ -385,6 +385,7 @@ def start_demo(self, demo_key): if result == QMessageBox.Cancel: return - demo_exe = (Path(sys.executable).parent/'tsuchinoko_demo').with_suffix(Path(sys.executable).suffix) + suffix = Path(sys.executable).suffix + demo_exe = (Path(sys.executable).parent/'tsuchinoko_demo').with_suffix(suffix if suffix=='.exe' else '') print(demo_exe) self._server = subprocess.Popen([demo_exe, demo_key]) From 6492243e5499aedd3a2b062cf37dd44e4740ccc6 Mon Sep 17 00:00:00 2001 From: Ronald Pandolfi Date: Wed, 8 Mar 2023 09:41:31 -0800 Subject: [PATCH 2/4] combine win and mac pyinstaller compat --- install.nsi | 2 +- tsuchinoko.spec | 37 ++++++++++++++++++++----------------- 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/install.nsi b/install.nsi index 25c8334..c0fd41c 100644 --- a/install.nsi +++ b/install.nsi @@ -5,7 +5,7 @@ !include "x64.nsh" !define MUI_BRANDINGTEXT "Tsuchinoko ${VERSION}" !define MUI_PRODUCT "Tsuchinoko" - !define MUI_FILE "Tsuchinoko" + !define MUI_FILE "tsuchinoko_client" CRCCheck On ;--------------------------------- diff --git a/tsuchinoko.spec b/tsuchinoko.spec index 895c0a9..1c5f8a5 100644 --- a/tsuchinoko.spec +++ b/tsuchinoko.spec @@ -1,6 +1,7 @@ # -*- mode: python ; coding: utf-8 -*- import os import glob +import sys import dask import distributed @@ -135,22 +136,24 @@ exe2 = EXE( icon=assets.path('tsuchinoko.png') ) -#coll = COLLECT( -# exe, exe2, -# a.binaries, a2.binaries, -# a.zipfiles, a2.zipfiles, -# a.datas, a2.datas, -# strip=False, -# upx=True, -# upx_exclude=[], -# name='Tsuchinoko', -#) - -app = BUNDLE( - exe, exe2, a.binaries, a2.binaries, a.zipfiles, a2.zipfiles, a.datas, a2.datas, - name='Tsuchinoko', - icon=assets.path('tsuchinoko.png'), - bundle_identifier=None, -) +print(f'platform: {sys.platform}') +if sys.platform == 'win32': + coll = COLLECT( + exe, exe2, + a.binaries, a2.binaries, + a.zipfiles, a2.zipfiles, + a.datas, a2.datas, + strip=False, + upx=True, + upx_exclude=[], + name='Tsuchinoko', + ) +elif sys.platform == 'darwin': + app = BUNDLE( + exe, exe2, a.binaries, a2.binaries, a.zipfiles, a2.zipfiles, a.datas, a2.datas, + name='Tsuchinoko', + icon=assets.path('tsuchinoko.png'), + bundle_identifier=None, + ) From 3c7047fde37f09cc16ae48acb5522b7ea9018caa Mon Sep 17 00:00:00 2001 From: Ronald Pandolfi Date: Wed, 8 Mar 2023 09:46:31 -0800 Subject: [PATCH 3/4] add mac build actions --- .github/workflows/main.yml | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 76178d2..2376b2c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -109,3 +109,36 @@ jobs: token: ${{ secrets.GITHUB_TOKEN }} draft: true files: Tsuchinoko*.exe + macbuild: + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') + needs: test + runs-on: macos-latest + strategy: + matrix: + python-version: [ '3.9' ] + steps: + - uses: actions/checkout@v2 + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + + - name: Install dependencies + run: | + pip install -e .[dev] + + - name: pyinstaller + run: | + pyinstaller --noconfirm --clean tsuchinoko.spec + + - name: rename to .app + run: | + mv dist/Tsuchinoko dist/Tsuchinoko.app + + - name: Release + uses: softprops/action-gh-release@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + draft: true + files: dist/Tsuchinoko.app \ No newline at end of file From 35e6fc1d10b30c33334048f9fd25a4f15a21662f Mon Sep 17 00:00:00 2001 From: Ronald Pandolfi Date: Wed, 8 Mar 2023 10:37:18 -0800 Subject: [PATCH 4/4] only package dylibs on mac --- tsuchinoko.spec | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tsuchinoko.spec b/tsuchinoko.spec index 1c5f8a5..bc72832 100644 --- a/tsuchinoko.spec +++ b/tsuchinoko.spec @@ -38,9 +38,10 @@ datas_dst.append('tsuchinoko/examples') datas_src.append(os.path.join(examples.__path__[0], 'peak2.png')) datas_dst.append('tsuchinoko/examples') -# functorch -datas_src.append(os.path.join(torch.__path__[0],'lib','libiomp5.dylib')) -datas_dst.append('functools/.dylibs') +# functorch (mac only) +if sys.platform == 'darwin': + datas_src.append(os.path.join(torch.__path__[0],'lib','libiomp5.dylib')) + datas_dst.append('functools/.dylibs') print('extras:')