From f6b33c88739d7646b4f5effd3532da57e9404978 Mon Sep 17 00:00:00 2001 From: e71828 Date: Thu, 27 Apr 2023 22:51:43 +0800 Subject: [PATCH 1/2] msys2 --- .github/workflows/msys2.yml | 74 ++++++++++++++++++++++++++++++++++ VERSION | 1 + comtool-portable.spec | 44 +++++++++++++++++++++ comtool.nsi | 79 +++++++++++++++++++++++++++++++++++++ pack.py | 7 ++-- 5 files changed, 202 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/msys2.yml create mode 100644 VERSION create mode 100644 comtool-portable.spec create mode 100644 comtool.nsi diff --git a/.github/workflows/msys2.yml b/.github/workflows/msys2.yml new file mode 100644 index 0000000..98d21da --- /dev/null +++ b/.github/workflows/msys2.yml @@ -0,0 +1,74 @@ + +name: msys2 +on: push +jobs: + Deploy-on-windows: + runs-on: windows-latest + defaults: + run: + shell: msys2 {0} + steps: + - uses: msys2/setup-msys2@v2 + with: + msystem: UCRT64 + update: true + install: >- + base-devel + git + mingw-w64-ucrt-x86_64-python-pip + mingw-w64-ucrt-x86_64-nsis + mingw-w64-ucrt-x86_64-nsis-nsisunz + mingw-w64-ucrt-x86_64-gcc + zip + unzip + p7zip + mingw-w64-ucrt-x86_64-python-pyqt5 + python-setuptools + mingw-w64-ucrt-x86_64-python-pyserial + mingw-w64-ucrt-x86_64-python-requests + mingw-w64-ucrt-x86_64-python-babel + mingw-w64-ucrt-x86_64-python-qtawesome + mingw-w64-ucrt-x86_64-python-paramiko + mingw-w64-ucrt-x86_64-python-pyperclip + mingw-w64-ucrt-x86_64-python-pyqtgraph + - name: Check out repository code + uses: actions/checkout@v3 + - name: Running pyinstaller without pack.py + run: | + APP=comtool + if [ ! -d venv ]; then + python3 -m venv --system-site-packages venv + . venv/bin/activate + python3 -m pip install --upgrade pip + PYINSTALLER_COMPILE_BOOTLOADER=1 PYI_STATIC_ZLIB=1 python3 -m pip install -r requirements.txt + python3 -m pip install git+https://github.com/pyinstaller/pyinstaller.git + else + . venv/bin/activate + fi + + python3 -m pip install wheel pyinstaller-hooks-contrib + python3 setup.py sdist bdist_wheel + python3 pack.py + # python3 -m PyInstaller $APP.spec -y + # echo "Preparing app..." + # cd dist/$APP + # zip -r $APP.zip * + # mv $APP.zip ../.. + # cd ../.. + echo $(du -sk dist/$APP | cut -f 1) > INSTALLSIZE + echo $(uname -m) > ARCH + echo "Running makensis..." + makensis $APP.nsi + + python3 -m PyInstaller $APP-portable.spec + echo "Preparing app..." + version=$(cat VERSION) + mv dist/$APP.exe ./$APP-$version-$(uname -m)-portable.exe + - name: List files + run: ls -R + - name: Upload output files + uses: actions/upload-artifact@v3 + with: + name: EXE + path: comtool*.exe + retention-days: 5 diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..e4604e3 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +3.2.1 diff --git a/comtool-portable.spec b/comtool-portable.spec new file mode 100644 index 0000000..16af575 --- /dev/null +++ b/comtool-portable.spec @@ -0,0 +1,44 @@ +# -*- mode: python ; coding: utf-8 -*- + +block_cipher = None + +a = Analysis( + ['COMTool/Main.py'], + pathex=[], + binaries=[], + datas=[ + ('COMTool', 'COMTOOL'), + ('LICENSE', '.'), + ('VERSION', '.') + ], + hiddenimports=["babel.numbers"], + hookspath=[], + runtime_hooks=[], + excludes=[], + win_no_prefer_redirects=False, + win_private_assemblies=False, + cipher=block_cipher, + noarchive=False +) + +pyz = PYZ( + a.pure, + a.zipped_data, + cipher=block_cipher +) + +exe = EXE( + pyz, + a.scripts, + a.binaries, + a.zipfiles, + a.datas, + [], + name='comtool', + icon='COMTool/assets/logo.ico', + debug=False, + bootloader_ignore_signals=False, + strip=False, + upx=True, + console=False +) diff --git a/comtool.nsi b/comtool.nsi new file mode 100644 index 0000000..baa6af5 --- /dev/null +++ b/comtool.nsi @@ -0,0 +1,79 @@ +#!/usr/bin/makensis + +!define APPNAME "comtool" +!define FILENAME "comtool" +!define AUTHOR "Author name" +!define DESCRIPTION "com debug tool" + +Unicode True + +!define /file VERSION "VERSION" +!define /file INSTALLSIZE "INSTALLSIZE" +!define /file ARCH "ARCH" + +InstallDir "$PROGRAMFILES\${APPNAME}" + +Name "${APPNAME}" +Icon "COMTool/assets/logo.ico" +outFile "${FILENAME}-${VERSION}-${ARCH}.exe" + +!include LogicLib.nsh + +Page directory +Page instfiles + +!macro VerifyUserIsAdmin +UserInfo::GetAccountType +pop $0 +${If} $0 != "admin" ;Require admin rights on NT4+ + messageBox mb_iconstop "Administrator rights required!" + setErrorLevel 740 ;ERROR_ELEVATION_REQUIRED + quit +${EndIf} +!macroend + +function .onInit + setShellVarContext all + !insertmacro VerifyUserIsAdmin +functionEnd + +section "install" + + setOutPath $INSTDIR + file "COMTool\assets\logo.ico" + file "${FILENAME}.zip" + + nsisunz::Unzip "$INSTDIR\${FILENAME}.zip" "$INSTDIR" + + delete "$INSTDIR\${FILENAME}.zip" + + writeUninstaller "$INSTDIR\uninstall.exe" + + createDirectory "$SMPROGRAMS\${APPNAME}" + createShortCut "$SMPROGRAMS\${APPNAME}\${APPNAME}.lnk" "$INSTDIR\${FILENAME}.exe" "" "$INSTDIR\COMTool\assets\logo.ico.ico" + + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "DisplayName" "${APPNAME}" + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "UninstallString" "$\"$INSTDIR\uninstall.exe$\"" + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "QuietUninstallString" "$\"$INSTDIR\uninstall.exe$\" /S" + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "InstallLocation" "$\"$INSTDIR$\"" + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "DisplayIcon" "$\"$INSTDIR\COMTool\assets\logo.ico$\"" + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "Publisher" "${AUTHOR}" + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "DisplayVersion" "${VERSION}" + WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "NoModify" 1 + WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "NoRepair" 1 + WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "EstimatedSize" ${INSTALLSIZE} +sectionEnd + +function un.onInit + SetShellVarContext all + MessageBox MB_OKCANCEL "Permanently remove ${APPNAME}?" IDOK next + Abort + next: + !insertmacro VerifyUserIsAdmin +functionEnd + +section "uninstall" + rmDir /r /REBOOTOK "$SMPROGRAMS\${APPNAME}" + rmDir /r /REBOOTOK $INSTDIR + DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" +sectionEnd diff --git a/pack.py b/pack.py index b50210d..8065fea 100644 --- a/pack.py +++ b/pack.py @@ -21,7 +21,8 @@ linux_out = "comtool_ubuntu_v{}.tar.xz".format(version.__version__) macos_out = "comtool_macos_v{}.dmg".format(version.__version__) -windows_out = "comtool_windows_v{}.7z".format(version.__version__) +windows_out_7z = "comtool_windows_v{}.7z".format(version.__version__) +windows_out_zip = "comtool.zip" def zip(out, path): out = os.path.abspath(out) @@ -135,8 +136,8 @@ def pack(): print("files in dist dir:", os.listdir("dist")) shutil.copyfile("./dist/comtool 0.0.0.dmg", macos_out) elif sys.platform.startswith("win32"): - # zip(windows_out, "dist/comtool") - zip_7z(windows_out, "dist/comtool") + zip(windows_out_zip, "dist/comtool") + # zip_7z(windows_out_7z, "dist/comtool") else: cmd = "cd dist && tar -Jcf {} comtool/ && mv {} ../ && cd ..".format(linux_out, linux_out) ret = os.system(cmd) From afad4042c1bf7b857a239d4b112cd542e2f0a81f Mon Sep 17 00:00:00 2001 From: e71828 Date: Fri, 28 Apr 2023 12:51:44 +0800 Subject: [PATCH 2/2] cp spec --- comtool-portable.spec | 66 ++++++++++++++++++++----------------------- 1 file changed, 31 insertions(+), 35 deletions(-) diff --git a/comtool-portable.spec b/comtool-portable.spec index 16af575..a4485fa 100644 --- a/comtool-portable.spec +++ b/comtool-portable.spec @@ -1,44 +1,40 @@ # -*- mode: python ; coding: utf-8 -*- + block_cipher = None -a = Analysis( - ['COMTool/Main.py'], - pathex=[], - binaries=[], - datas=[ - ('COMTool', 'COMTOOL'), - ('LICENSE', '.'), - ('VERSION', '.') - ], - hiddenimports=["babel.numbers"], - hookspath=[], - runtime_hooks=[], - excludes=[], - win_no_prefer_redirects=False, - win_private_assemblies=False, - cipher=block_cipher, - noarchive=False -) -pyz = PYZ( - a.pure, - a.zipped_data, - cipher=block_cipher +a = Analysis( + ['COMTool/Main.py'], + pathex=['COMTool'], + binaries=[], + datas=[('COMTool/assets', 'assets'), ('COMTool/locales', 'locales'), ('COMTool/protocols', 'protocols'), ('README.MD', './'), ('README_ZH.MD', './')], + hiddenimports=['babel.numbers'], + hookspath=[], + hooksconfig={}, + runtime_hooks=[], + excludes=[], + win_no_prefer_redirects=False, + win_private_assemblies=False, + cipher=block_cipher, + noarchive=False, ) +pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher) exe = EXE( - pyz, - a.scripts, - a.binaries, - a.zipfiles, - a.datas, - [], - name='comtool', - icon='COMTool/assets/logo.ico', - debug=False, - bootloader_ignore_signals=False, - strip=False, - upx=True, - console=False + pyz, + a.scripts, + [], + name='comtool', + debug=False, + bootloader_ignore_signals=False, + strip=False, + upx=True, + console=False, + disable_windowed_traceback=False, + argv_emulation=False, + target_arch=None, + codesign_identity=None, + entitlements_file=None, + icon=['COMTool/assets/logo.ico'], )