-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy.py
98 lines (88 loc) · 3.3 KB
/
deploy.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
__author__ = "Tomáš Pazdiora"
__description__ = "Head Tracking Controller"
__app_name__ = "CamController"
__full_name__ = "Camera Controller"
__version__ = "1.1.2"
__app_main__ = "cam_controller.py"
__app_icon__ = "app.ico"
__app_data__ = ["data", "README.md", "LICENSE"]
__guid__ = "{644245e2-c43e-4628-b4a3-bb6767ee6f98}"
import os
import platform
import subprocess
from cx_Freeze import setup, Executable
# Get third-party licenses
if not os.path.exists('build'):
os.makedirs('build')
subprocess.call(['pip-licenses', '--with-license-file', '--format=markdown', '--no-license-path', '--output-file=build/THIRDPARTY_LICENSES'])
# PyInstaller
class PyInstallerExecutable(Executable):
def __init__(self, script, initScript = None, base = None,
targetName = None, icon = None, shortcutName = None,
shortcutDir = None, copyright = None, trademarks = None):
subprocess.call(['pyinstaller',
'--specpath=build',
'--clean', '--onedir',
'--noconsole', '--windowed',
'--icon=../{}'.format(icon),
'--name={}'.format(targetName),
script], shell=True)
if not os.path.exists('build'):
os.makedirs('build')
ext = ""
if platform.system().lower().startswith('windows'):
ext = ".exe"
elif platform.system().lower().startswith('darwin'):
ext = ".app"
with open('build/launcher.py', 'w') as file:
file.write('import sys, subprocess; subprocess.call(["{}{}", *sys.argv[1:]], shell=True)'.format(targetName, ext))
if base is None:
base = "Win32GUI" if platform.system().lower().startswith('windows') else None
super().__init__('build/launcher.py', initScript, base, "launcher",
icon, shortcutName, shortcutDir, copyright, trademarks)
# cx_Freeze setup
setup(
name = __app_name__,
version = __version__,
description = __description__,
author=__author__,
executables = [
PyInstallerExecutable(
__app_main__,
icon = __app_icon__,
targetName = __app_name__,
shortcutName = __full_name__,
shortcutDir = "DesktopFolder",
)
],
options = {
'build_exe' : {
'include_files' : [
('dist/{}/'.format(__app_name__), '.'),
('build/THIRDPARTY_LICENSES', 'THIRDPARTY_LICENSES')] +
[(file, '') for file in __app_data__],
'include_msvcr' : True
},
'bdist_msi': {
'install_icon': __app_icon__,
'upgrade_code': __guid__,
'add_to_path': False,
'initial_target_dir': r'[ProgramFilesFolder]\{}'.format(__app_name__),
'data': {"Shortcut": [(
'DesktopShortcut','DesktopFolder', __full_name__,
'TARGETDIR', '[TARGETDIR]launcher.exe', None,
__description__, None, None, None, None, 'TARGETDIR')]}
},
'bdist_mac': {
'iconfile': __app_icon__,
'bundle_name': __app_name__
},
'bdist_dmg': {
'applications_shortcut': True
},
'bdist_rpm': {
'icon': __app_icon__,
'requires': ['python3-dev', 'libasound2-dev']
}
}
)