Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pyinstaller branch rebase and fbs removal #238

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 35 additions & 38 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,17 @@ jobs:
runs-on: ubuntu-22.04

container:
image: ubuntu:18.04
image: ubuntu:22.04
options: --privileged
env:
LD_LIBRARY_PATH: /__w/vial-gui/vial-gui/util/python36/prefix/lib/
env:
PYTHON_VERSION: 3.12.2

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{env.PYTHON_VERSION}}
cache: pip

- name: Install dependencies
run: |
Expand All @@ -23,47 +27,40 @@ jobs:
unzip *.zip
gem install --no-document fpm

- name: Set up Python 3.6
run: ./util/setup_python36.sh

- name: Setup venv
run: |
./util/python36/prefix/bin/python3 -m venv venv
python3 -m venv venv
. venv/bin/activate
pip install -r requirements.txt

- name: Build
run: |
. venv/bin/activate
fbs freeze
fbs installer
source venv/bin/activate
pyinstaller misc/Vial.spec
rm ./dist/Vial/{libgdk-3.so.0,libfontconfig.so.1}
deactivate
./pkg2appimage-*/pkg2appimage misc/Vial.yml
mv out/Vial-*.AppImage out/Vial-x86_64.AppImage
cp src/main/icons/linux/1024.png dist/Vial/Vial.png
cp misc/Vial.desktop dist/Vial/
cp misc/AppRun dist/Vial/
./linuxdeploy-x86_64.AppImage --appdir dist/Vial --output appimage
mv Vial-*-x86_64.AppImage Vial-x86_64.AppImage

- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: vial-linux
path: out/Vial-x86_64.AppImage
path: Vial-x86_64.AppImage

build-mac:
runs-on: macos-11
env:
PYTHON_VERSION: 3.6.8
MACOSX_DEPLOYMENT_TARGET: 10.9

steps:
- uses: actions/checkout@v3

- name: Get Python
run: curl https://www.python.org/ftp/python/${PYTHON_VERSION}/python-${PYTHON_VERSION}-macosx${MACOSX_DEPLOYMENT_TARGET}.pkg -o "python.pkg"

- name: Verify download
run: shasum -a 256 -c <<< '4bcd53faffc98d193ef7cdccd5668de3829c702af4db45258819a84a2cab60d0 *python.pkg'

- name: Install Python
run: |
sudo installer -pkg python.pkg -target /
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{env.PYTHON_VERSION}}
cache: pip

- name: Setup venv
run: |
Expand All @@ -74,10 +71,10 @@ jobs:
- name: Build
run: |
source venv/bin/activate
fbs freeze
pyinstaller misc/Vial.spec
hdiutil create -volname Vial -srcfolder "target/Vial.app" -ov -format UDZO vial-mac.dmg

- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: vial-mac
path: vial-mac.dmg
Expand All @@ -86,10 +83,10 @@ jobs:
runs-on: windows-2019

steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.6.x'
python-version: ${{env.PYTHON_VERSION}}

- name: Setup venv
run: |
Expand All @@ -106,21 +103,21 @@ jobs:
- name: Build
run: |
. .\venv\Scripts\activate.ps1
fbs freeze
Compress-Archive -Path "target\Vial" -DestinationPath vial-win.zip
pyinstaller misc/Vial.spec
Compress-Archive -Path "dist/Vial" -DestinationPath vial-win.zip

- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: vial-win
path: vial-win.zip

- name: Create installer
run: |
$env:Path += ";C:\Program Files (x86)\NSIS"
. .\venv\Scripts\activate.ps1
fbs installer
cd dist/Vial
makensis ../../src/installer/windows/Installer.nsi

- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: vial-win-installer
path: target\VialSetup.exe
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ target
__pycache__
*.pyc
.idea
build/
dist/
2 changes: 1 addition & 1 deletion .python-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.6.0
3.12
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Visit https://get.vial.today/ to download a binary release of Vial.

#### Development

Python 3.6 is recommended (3.6 is the latest version that is officially supported by `fbs`).
Python 3.12 is recommended.

Install dependencies:

Expand All @@ -33,5 +33,6 @@ To launch the application afterwards:

```
source venv/bin/activate
fbs run
pyinstaller misc/Vial.spec
./dist/Vial/Vial
```
4 changes: 4 additions & 0 deletions misc/AppRun
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
HERE=$(dirname $(readlink -f "${0}"))
export QT_QPA_PLATFORM=xcb
exec "${HERE}/Vial" "$@"
29 changes: 29 additions & 0 deletions misc/README.pyinstaller.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Command Line to generate a spec

These are the command-line options used to generate the .spec file for pyinstaller:

```
pyi-makespec \
--specpath=misc \
--name=Vial \
--add-data="../src/main/resources/base/qmk_settings.json:resources/base" \
--add-data="../src/build/settings/base.json:resources/settings" \
--add-data="../src/build/settings/linux.json:resources/settings" \
--add-data="../src/build/settings/mac.json:resources/settings" \
--windowed \
--noupx \
--icon="../src/main/icons/Icon.ico"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
--icon="../src/main/icons/Icon.ico"
--icon="../src/main/icons/Icon.ico" \

Added a missing trailing slash, which is needed for the CLI to run.

--argv-emulation \
./src/main/python/main.py
```


If you are upgrading pyinstaller and want to use new default options, you must
either delete the old spec or rename it to force pyi-makespec to use updated
default options.

## Building from the spec

```
pyinstaller misc/Vial.spec
```
9 changes: 9 additions & 0 deletions misc/Vial.desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[Desktop Entry]
Name=Vial
Type=Application
Exec=Vial
Terminal=false
NoDisplay=false
Categories=Utility;
Version=1.0
Icon=Vial
44 changes: 44 additions & 0 deletions misc/Vial.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# -*- mode: python ; coding: utf-8 -*-


a = Analysis(
['../src/main/python/main.py'],
pathex=[],
binaries=[],
datas=[('../src/main/resources/base/qmk_settings.json', 'resources/base'), ('../src/build/settings/base.json', 'resources/settings'), ('../src/build/settings/linux.json', 'resources/settings'), ('../src/build/settings/mac.json', 'resources/settings')],
hiddenimports=[],
hookspath=[],
hooksconfig={},
runtime_hooks=[],
excludes=[],
noarchive=False,
)
pyz = PYZ(a.pure)

exe = EXE(
pyz,
a.scripts,
[],
exclude_binaries=True,
name='Vial',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=False,
console=True,
disable_windowed_traceback=False,
argv_emulation=True,
target_arch=None,
codesign_identity=None,
entitlements_file=None,
icon=['../src/main/icons/Icon.ico'],
)
coll = COLLECT(
exe,
a.binaries,
a.datas,
strip=False,
upx=False,
upx_exclude=[],
name='Vial',
)
21 changes: 0 additions & 21 deletions misc/Vial.yml

This file was deleted.

13 changes: 13 additions & 0 deletions misc/build_spec.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
REM Only useful to regenerate or add options to Vial.spec
pyi-makespec ^
--specpath=misc ^
--name=Vial ^
--add-data="../src/main/resources/base/qmk_settings.json:resources/base" ^
--add-data="../src/build/settings/base.json:resources/settings" ^
--add-data="../src/build/settings/linux.json:resources/settings" ^
--add-data="../src/build/settings/mac.json:resources/settings" ^
--console ^
--noupx ^
--icon="../src/main/icons/Icon.ico" ^
--argv-emulation ^
./src/main/python/main.py
27 changes: 16 additions & 11 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
altgraph==0.17
fbs==0.9.0
future==0.18.2
git+https://github.com/vial-kb/cython-hidapi@88d8983b3dc65b9ef84238abe3f46004b0ef2fd0#egg=hidapi
altgraph==0.17.4
certifi==2024.2.2
future==1.0.0
hidapi==0.14.0
keyboard==0.13.5
macholib==1.14
pefile==2019.4.18
PyInstaller==3.4
PyQt5==5.9.2
https://github.com/danthedeckie/simpleeval/archive/41c99b8e224a7a0ae0ac59c773598fe79a4470db.zip
sip==4.19.8
pywin32==303; sys_platform == 'win32'
certifi
packaging==24.0
pefile==2023.2.7
pyinstaller==6.5.0
pyinstaller-hooks-contrib==2024.3
PyQt5==5.15.7
PyQt5-Qt5==5.15.2
PyQt5-sip==12.13.0
pywin32==306; sys_platform == 'win32'
pywin32-ctypes==0.2.2
setuptools==69.2.0
simpleeval==0.9.13
sip==6.8.3
1 change: 1 addition & 0 deletions src/build/settings/base.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"app_name": "Vial",
"organization_name": "Vial-kb",
"author": "xyz",
"main_module": "src/main/python/main.py",
"version": "0.7.1"
Expand Down
3 changes: 2 additions & 1 deletion src/build/settings/mac.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"mac_bundle_identifier": ""
"mac_bundle_identifier": "",
"organization_domain": "vial.today"
}
3 changes: 1 addition & 2 deletions src/main/python/macro/macro_recorder_linux.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from PyQt5 import QtCore
from PyQt5.QtCore import pyqtSignal, QProcess
from PyQt5.QtWidgets import QWidget, QVBoxLayout, QPushButton, QApplication
from fbs_runtime.application_context import is_frozen

from keycodes.keycodes import Keycode
from macro.macro_key import KeyUp, KeyDown
Expand Down Expand Up @@ -41,7 +40,7 @@ def start(self):
args = [sys.executable]
if os.getenv("APPIMAGE"):
args = [os.getenv("APPIMAGE")]
elif is_frozen():
elif getattr(sys, 'frozen', False):
args += sys.argv[1:]
else:
args += sys.argv
Expand Down
Loading