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 #618

Merged
merged 27 commits into from
Feb 23, 2019
Merged
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
16 changes: 12 additions & 4 deletions data/azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,17 +126,25 @@ jobs:
displayName: "Build extensions"

- script: |
pip install wheel twine six appdirs packaging cx_freeze
pip install --upgrade wheel twine six appdirs packaging setuptools pyinstaller pywin32
pip install "pyaudio; python_version < '3.7'"
python -c "import tempfile, os; open(os.path.join(tempfile.gettempdir(), 'urh_releasing'), 'w').close()"
displayName: "Install build dependencies"

- script: python setup.py bdist_wheel
displayName: "Build python wheel"

- script: python data\build_cx.py
- script: python data/pyinstaller_helper.py
condition: eq(variables['python.version'], '3.6')
displayName: "Build MSI"
displayName: "Run PyInstaller"

- script: |
choco install innosetup
python src/urh/version.py > C:\urh_version.txt
set /p URHVERSION=<C:\urh_version.txt
iscc /dMyAppVersion=%URHVERSION% /dArch=$(python.arch) data/inno.iss
condition: eq(variables['python.version'], '3.6')
displayName: "Create setup.exe"

- task: PublishBuildArtifacts@1
inputs:
Expand All @@ -160,7 +168,7 @@ jobs:
action: 'edit'
tag: $(Build.SourceBranchName)
repositoryName: jopohl/urh
assets: 'dist/*.msi'
assets: 'dist/*.exe'
assetUploadMode: 'replace'
addChangeLog: true

Expand Down
117 changes: 0 additions & 117 deletions data/build_cx.py

This file was deleted.

38 changes: 38 additions & 0 deletions data/inno.iss
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
[Setup]
; NOTE: The value of AppId uniquely identifies this application.
; Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={{8A0E36A6-DE56-46B8-BCC3-C16D1BC759CC}
AppName=Universal Radio Hacker
AppVersion={#MyAppVersion}
VersionInfoVersion={#MyAppVersion}
ArchitecturesInstallIn64BitMode=x64
UninstallDisplayName=Universal Radio Hacker
AppPublisher=Johannes Pohl
AppPublisherURL=https://github.com/jopohl/urh
AppSupportURL=https://github.com/jopohl/urh
AppUpdatesURL=https://github.com/jopohl/urh
DefaultDirName={pf}\Universal Radio Hacker
DisableProgramGroupPage=yes
LicenseFile=..\LICENSE
OutputDir=..\dist
OutputBaseFilename=Universal.Radio.Hacker-{#Arch}
Compression=lzma2/ultra
SolidCompression=yes

[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"

[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked

[Files]
Source: "..\pyinstaller\urh\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
; NOTE: Don't use "Flags: ignoreversion" on any shared system files

[Icons]
Name: "{commonprograms}\Universal Radio Hacker"; Filename: "{app}\urh.exe"
Name: "{commondesktop}\Universal Radio Hacker"; Filename: "{app}\urh.exe"; Tasks: desktopicon

[Run]
Filename: "{app}\urh.exe"; Description: "{cm:LaunchProgram,Universal Radio Hacker}"; Flags: nowait postinstall skipifsilent
43 changes: 43 additions & 0 deletions data/pyinstaller_helper.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import os
import shutil
import sys
from subprocess import call

HIDDEN_IMPORTS = ["packaging.specifiers", "packaging.requirements",
"numpy.core._methods", "numpy.core._dtype_ctypes"]
DATA = [("src/urh/dev/native/lib/shared", "."), ("src/urh/plugins", "urh/plugins"), ]
EXCLUDE = ["matplotlib"]

cmd = ["pyinstaller"]
if sys.platform == "darwin":
cmd.append("--onefile")

for hidden_import in HIDDEN_IMPORTS:
cmd.append("--hidden-import={}".format(hidden_import))

for src, dst in DATA:
cmd.append("--add-data")
cmd.append('"{}{}{}"'.format(src, os.pathsep, dst))

for exclude in EXCLUDE:
cmd.append("--exclude-module={}".format(exclude))

urh_path = os.path.realpath(os.path.join(os.path.dirname(__file__), ".."))
cmd.append('--icon="{}"'.format(os.path.join(urh_path, "data/icons/appicon.ico")))

cmd.extend(["--distpath", "./pyinstaller"])

shutil.copy(os.path.join(urh_path, "src/urh/main.py"), os.path.join(urh_path, "src/urh/urh.py"))
shutil.copy(os.path.join(urh_path, "src/urh/main.py"), os.path.join(urh_path, "src/urh/urh_debug.py"))
urh_cmd = cmd + ["--windowed", os.path.join(urh_path, "src/urh/urh.py")]
urh_debug_cmd = cmd + [os.path.join(urh_path, "src/urh/urh_debug.py")]
cli_cmd = cmd + [os.path.join(urh_path, "src/urh/cli/urh_cli.py")]

for cmd in (urh_cmd, cli_cmd, urh_debug_cmd):
cmd = " ".join(cmd)
print(cmd)
sys.stdout.flush()
call(cmd, shell=True)

shutil.copy("./pyinstaller/urh_cli/urh_cli.exe", "./pyinstaller/urh/urh_cli.exe")
shutil.copy("./pyinstaller/urh_debug/urh_debug.exe", "./pyinstaller/urh/urh_debug.exe")
10 changes: 6 additions & 4 deletions src/urh/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import re
import os
import sys
import multiprocessing


from PyQt5.QtCore import QTimer, Qt
from PyQt5.QtGui import QPalette, QIcon, QColor
Expand Down Expand Up @@ -153,9 +155,8 @@ def main():
constants.SEND_INDICATOR_COLOR = selection_color

main_window = MainController()
import multiprocessing as mp
# allow usage of prange (OpenMP) in Processes
mp.set_start_method("spawn")
multiprocessing.set_start_method("spawn")

if sys.platform == "darwin":
menu_bar = main_window.menuBar()
Expand All @@ -164,8 +165,6 @@ def main():
# Ensure we get the app icon in windows taskbar
import ctypes
ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID("jopohl.urh")
import multiprocessing as mp
mp.freeze_support()

main_window.showMaximized()
# main_window.setFixedSize(1920, 1080 - 30) # Youtube
Expand All @@ -182,4 +181,7 @@ def main():


if __name__ == "__main__":
if hasattr(sys, "frozen"):
multiprocessing.freeze_support()

main()
4 changes: 4 additions & 0 deletions src/urh/version.py
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
VERSION = "2.5.5"

if __name__ == '__main__':
# To read out version easy on command line for InnoSetup
print(VERSION)