forked from kdschlosser/EventGhost-x64-Python3.5
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheventghost_build_exe.py
106 lines (86 loc) · 3.3 KB
/
eventghost_build_exe.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
99
100
101
102
103
104
105
106
# -*- coding: utf-8 -*-
#
# This file is part of EventGhost.
# Copyright © 2005-2016 EventGhost Project <http://www.eventghost.net/>
#
# EventGhost is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free
# Software Foundation, either version 2 of the License, or (at your option)
# any later version.
#
# EventGhost is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License along
# with EventGhost. If not, see <http://www.gnu.org/licenses/>.
import sys
import os
from subprocess import Popen, PIPE
from cx_Freeze.dist import build_exe
INNO_SETUP_DEFINES = '''
#define APPNAME "{name}"
#define APPVERSION "{version}"
#define APPCOPYRIGHT "{copyright}"
#define APPPUBLISHER "{company_name}"
#define APPURL "{url}"
#define APPBUILDPATH "{build_dir}"
#define APPOUTPUTDIR "{output_dir}"
#define APPICON "{icon}"
#define APPLOGOSMALL "{logo_small}"
#define APPLOGOLARGE "{logo_large}"
'''
class BuildEXE(build_exe):
def build_extension(self, name, **_):
pass
def run(self):
command = self.distribution.get_command_obj('build_ext')
command.run()
#
# self.distribution.get_command_obj('build_docs').run()
build_exe.run(self)
from inno_setup import COMPILER_PATH
from docs import ICON, LOGO_SMALL, LOGO_LARGE
build_base = os.path.split(self.build_exe)[0]
inno_build_path = os.path.join(build_base, 'inno_setup')
base_path = os.path.dirname(__file__)
output_path = os.path.join(base_path, 'output')
inno_path = os.path.join(base_path, 'inno_setup')
copyright = self.distribution.executables[0].copyright
metadata = self.distribution.metadata
os.remove(os.path.join(self.build_exe, 'EventGhost.pyw'))
os.remove(os.path.join(self.build_exe, 'Interpreter.py'))
template = os.path.join(inno_path, 'InnoSetup.template')
script = os.path.join(inno_build_path, 'inno_setup.iss')
defines = INNO_SETUP_DEFINES.format(
name=metadata.name,
version=metadata.version,
copyright=copyright.replace('\n', ' '),
company_name=metadata.name + ' Project',
url=metadata.url,
build_dir=self.build_exe,
output_dir=output_path,
icon=ICON,
logo_small=LOGO_SMALL,
logo_large=LOGO_LARGE
)
with open(template, 'r', encoding='utf-8') as f:
template = f.read()
with open(script, 'w', encoding='utf-8') as f:
f.write(defines)
f.write(template)
print('-- building installer ' + '-' * 58)
proc = Popen(
'"{0}" "{1}"'.format(COMPILER_PATH, script),
stdout=PIPE,
stderr=PIPE
)
if sys.version_info[0] >= 3:
empty_return = b''
else:
empty_return = ''
while proc.poll() is None:
for line in iter(proc.stdout.readline, empty_return):
if line:
print(line.rstrip().decode('utf-8'))