Skip to content
This repository was archived by the owner on Jul 11, 2023. It is now read-only.

Commit 74ac7c0

Browse files
committedMay 14, 2021
Updated bundle process to avoid triggering AV products
1 parent 26be16c commit 74ac7c0

12 files changed

+67
-27
lines changed
 

‎BUILDING.md

+2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ Once you have Python installed and all the requirements, you can run the launche
1717

1818
## Building the launcher installer for distribution
1919

20+
> This guide is outdated. A updated version should soon be added to replace this one.
21+
2022
Once you have Python installed and all the requirements, you can build the launcher installer for distribution by going into the project directory and running `python setup.py create_installer`. This will use the PyInstaller package to create a frozen stand-alone executable with all the dependencies alongside. Afterwards, it will build the installer using Inno Setup. If you want the executable to support RAR archives, you will also need to have the [UnRAR command line tool](http://www.rarlab.com/rar_add.htm) in your PATH.
2123

2224
The resulting launcher installer should be in the `dist\innosetup` directory.

‎LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2015-2020 Rémy Roy
3+
Copyright (c) 2015-2021 Rémy Roy
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

‎alembic/README ‎alembicrepo/README

File renamed without changes.

‎alembic/env.py ‎alembicrepo/env.py

File renamed without changes.
File renamed without changes.

‎cddagl/sql/functions.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def get_db_url():
3333

3434

3535
def init_config(basedir):
36-
alembic_dir = os.path.join(basedir, 'alembic')
36+
alembic_dir = os.path.join(basedir, 'alembicrepo')
3737

3838
alembic_cfg = Config()
3939
alembic_cfg.set_main_option('sqlalchemy.url', get_db_url())

‎cddagl/ui/views/main.py

+13-14
Original file line numberDiff line numberDiff line change
@@ -1094,8 +1094,20 @@ def analyse_new_build(self, build):
10941094
self.exe_total_read = 0
10951095

10961096
self.exe_sha256 = hashlib.sha256()
1097-
self.last_bytes = None
10981097
self.game_version = ''
1098+
1099+
version_file = os.path.join(game_dir, 'VERSION.txt')
1100+
if os.path.isfile(version_file):
1101+
file_content = None
1102+
with open(version_file, 'r', encoding='utf8') as read_file:
1103+
file_content = read_file.read(1024)
1104+
if file_content is not None:
1105+
match = re.search(r'commit sha: (?P<commitsha>\S+)', file_content)
1106+
if match:
1107+
commit_sha = match.group('commitsha')
1108+
if len(commit_sha) >= 7:
1109+
self.game_version = commit_sha[:7]
1110+
10991111
self.opened_exe = open(self.exe_path, 'rb')
11001112

11011113
def timeout():
@@ -1143,22 +1155,9 @@ def timeout():
11431155
update_group_box.post_extraction()
11441156

11451157
else:
1146-
last_frame = bytes
1147-
if self.last_bytes is not None:
1148-
last_frame = self.last_bytes + last_frame
1149-
1150-
match = re.search(
1151-
b'(?P<version>[01]\\.[A-F](-\\d+-g[0-9a-f]+)?)\\x00',
1152-
last_frame)
1153-
if match is not None:
1154-
game_version = match.group('version').decode('ascii')
1155-
if len(game_version) > len(self.game_version):
1156-
self.game_version = game_version
1157-
11581158
self.exe_total_read += len(bytes)
11591159
self.reading_progress_bar.setValue(self.exe_total_read)
11601160
self.exe_sha256.update(bytes)
1161-
self.last_bytes = bytes
11621161

11631162
timer.timeout.connect(timeout)
11641163
timer.start(0)

‎launcher.iss

+7-6
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
#define MyAppVersion FileRead(FileOpen("cddagl\VERSION"))
33
#define MyAppPublisher "Rémy Roy"
44
#define MyAppURL "https://github.com/remyroy/CDDA-Game-Launcher"
5-
#define MyAppExeName "launcher.exe"
5+
#define MyExecutable "Launcher.bat"
6+
#define MyIcon "cddagl\resources\launcher.ico"
67

78

89
[Setup]
@@ -32,7 +33,7 @@ LicenseFile=LICENSE
3233

3334
;;;; Installer Icon, Filename & Path
3435
UninstallDisplayIcon={uninstallexe}
35-
SetupIconFile=cddagl\resources\launcher.ico
36+
SetupIconFile={#MyIcon}
3637
OutputDir=dist\innosetup
3738
OutputBaseFilename=cddagl_installer_v{#SetupSetting("AppVersion")}
3839

@@ -72,16 +73,16 @@ Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{
7273

7374

7475
[Files]
75-
Source: "dist\launcher\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
76+
Source: "build\archive\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
7677

7778

7879
[Icons]
79-
Name: "{autoprograms}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
80-
Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
80+
Name: "{autoprograms}\{#MyAppName}"; Filename: "{app}\{#MyExecutable}"; IconFilename: "{app}\{#MyIcon}"
81+
Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyExecutable}"; IconFilename: "{app}\{#MyIcon}"; Tasks: desktopicon
8182

8283

8384
[Run]
84-
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent
85+
Filename: "{app}\{#MyExecutable}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent
8586

8687

8788
[Code]

‎requirements.txt

-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
SQLAlchemy
22
alembic
33
PyQt5
4-
html5lib
5-
cssselect
64
arrow
75
rarfile
86
Babel
97
pywinutils
108
markdown2
119
Werkzeug
1210

13-
lxml
1411
pylzma

‎setup.py

+43-2
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@ def run(self):
116116
download_path.mkdir(parents=True, exist_ok=True)
117117

118118
# Download Python embeddable package
119-
120119
python_embed_url = 'https://www.python.org/ftp/python/3.9.5/python-3.9.5-embed-amd64.zip'
121120
python_embed_name = 'python-3.9.5-embed-amd64.zip'
122121

@@ -143,10 +142,22 @@ def run(self):
143142
with ZipFile(python_embed_archive, 'r') as zip_file:
144143
zip_file.extractall(archive_dir_path)
145144

145+
# Add mo files for localization
146+
self.run_other_command('compile_catalog')
147+
146148
# Copy package into archive dir
147149
archive_package_path = archive_dir_path.joinpath('cddagl')
148150
shutil.copytree(src_package_path, archive_package_path)
149151

152+
# Additional directories
153+
src_data_path = Path('data')
154+
target_data_path = archive_dir_path.joinpath('data')
155+
shutil.copytree(src_data_path, target_data_path)
156+
157+
src_alembicrepo_path = Path('alembicrepo')
158+
target_alembicrepo_path = archive_dir_path.joinpath('alembicrepo')
159+
shutil.copytree(src_alembicrepo_path, target_alembicrepo_path)
160+
150161
include_requirements(archive_dir_path)
151162

152163
# Move pywin32_system32 dlls into archive root
@@ -158,6 +169,36 @@ def run(self):
158169

159170
shutil.rmtree(pywin32_system32_path)
160171

172+
# Let's find and add unrar if available
173+
try:
174+
unrar_path = check_output(['where', 'unrar.exe'], stderr=DEVNULL)
175+
unrar_path = unrar_path.strip().decode('cp437')
176+
shutil.copy(unrar_path, archive_dir_path)
177+
except CalledProcessError:
178+
log("'unrar.exe' couldn't be found.")
179+
180+
# Remove unneeded files in archive
181+
paths_to_remove = [
182+
['bin'],
183+
['adodbapi'],
184+
['pythonwin'],
185+
['PyQt5', 'Qt5', 'qml']
186+
]
187+
for path in paths_to_remove:
188+
target_path = archive_dir_path.joinpath(*path)
189+
if target_path.is_dir():
190+
shutil.rmtree(target_path)
191+
192+
# Create batch file for starting the launcher easily
193+
batch_file_path = archive_dir_path.joinpath('Launcher.bat')
194+
with open(batch_file_path, 'w', encoding='utf8') as batch_file:
195+
batch_file.write(
196+
'''
197+
@echo off
198+
start pythonw.exe -m cddagl
199+
'''
200+
)
201+
161202
class FreezeWithPyInstaller(ExtendedCommand):
162203
description = 'Build CDDAGL with PyInstaller'
163204
user_options = [
@@ -279,7 +320,7 @@ def run(self):
279320
#### Make sure we are running Inno Setup from the project directory
280321
os.chdir(get_setup_dir())
281322

282-
self.run_other_command('freeze')
323+
self.run_other_command('bundle')
283324
inno_call = [self.compiler, '/cc', 'launcher.iss']
284325
log(f'executing {inno_call}')
285326
call(inno_call)

0 commit comments

Comments
 (0)
This repository has been archived.