|
4 | 4 |
|
5 | 5 | import packaging_utils |
6 | 6 |
|
| 7 | +# ---------------------------------------------------------------------------------------------------------------------- |
| 8 | +# Windows - Inno Setup |
| 9 | +# ---------------------------------------------------------------------------------------------------------------------- |
| 10 | + |
| 11 | + |
| 12 | +def make_inno_setup_script(version, base_path): |
| 13 | + """{} are required in text so easier to use this method""" |
| 14 | + file_body = ( |
| 15 | + r""" |
| 16 | + ; Script generated by the Inno Setup Script Wizard. |
| 17 | + ; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES! |
| 18 | +
|
| 19 | + #define MyAppName "Datashuttle" |
| 20 | + #define MyAppVersion """ |
| 21 | + + '"' |
| 22 | + + version |
| 23 | + + """" |
| 24 | + #define MyAppPublisher "Neuroinformatics Unit, Sainsbury Wellcome Centre, London, UK." |
| 25 | + #define MyAppURL "www.datashuttle.neuroinformatics.dev" |
| 26 | + #define MyAppExeName "terminal_launcher.exe" |
| 27 | +
|
| 28 | + [Setup] |
| 29 | + ; NOTE: The value of AppId uniquely identifies this application. Do not use the same AppId value in installers for other applications. |
| 30 | + ; (To generate a new GUID, click Tools | Generate GUID inside the IDE.) |
| 31 | + AppId={{D063D197-9D21-426B-BF8C-D5612C74DF15} |
| 32 | + AppName={#MyAppName} |
| 33 | + AppVersion={#MyAppVersion} |
| 34 | + ;AppVerName={#MyAppName} {#MyAppVersion} |
| 35 | + AppPublisher={#MyAppPublisher} |
| 36 | + AppPublisherURL={#MyAppURL} |
| 37 | + AppSupportURL={#MyAppURL} |
| 38 | + AppUpdatesURL={#MyAppURL} |
| 39 | + DefaultDirName={autopf}\DataShuttle |
| 40 | + DisableProgramGroupPage=yes |
| 41 | + LicenseFile=""" |
| 42 | + + base_path |
| 43 | + + """\dist\license.txt |
| 44 | + ; Uncomment the following line to run in non administrative install mode (install for current user only.) |
| 45 | + ;PrivilegesRequired=lowest |
| 46 | + PrivilegesRequiredOverridesAllowed=dialog |
| 47 | + OutputBaseFilename=datashuttle_""" |
| 48 | + + version |
| 49 | + + """ |
| 50 | + SetupIconFile=""" |
| 51 | + + base_path |
| 52 | + + r"""\dist\NeuroBlueprint_icon.ico |
| 53 | + UninstallDisplayIcon={app}\NeuroBlueprint_icon.ico |
| 54 | + Compression=lzma |
| 55 | + SolidCompression=yes |
| 56 | + WizardStyle=modern |
| 57 | +
|
| 58 | + [Languages] |
| 59 | + Name: "english"; MessagesFile: "compiler:Default.isl" |
| 60 | +
|
| 61 | + [Tasks] |
| 62 | + Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked |
| 63 | +
|
| 64 | + [Files] |
| 65 | + Source: """ |
| 66 | + + '"' |
| 67 | + + base_path |
| 68 | + + r"""\dist\terminal_launcher.exe"; DestDir: "{app}"; Flags: ignoreversion |
| 69 | + Source: """ |
| 70 | + + '"' |
| 71 | + + base_path |
| 72 | + + """\dist\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs |
| 73 | + ; NOTE: Don't use "Flags: ignoreversion" on any shared system files |
| 74 | +
|
| 75 | + [Icons] |
| 76 | + Name: "{autoprograms}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}" |
| 77 | + Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon |
| 78 | +
|
| 79 | + [Run] |
| 80 | + Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent |
| 81 | + """ |
| 82 | + ) |
| 83 | + |
| 84 | + return file_body |
| 85 | + |
| 86 | + |
7 | 87 | # Constants |
8 | 88 | WEZTERM_VERSION = packaging_utils.get_wezterm_version() |
9 | 89 | WEZTERM_FOLDERNAME = f"WezTerm-windows-{WEZTERM_VERSION}" |
|
29 | 109 | shell=True, |
30 | 110 | ) |
31 | 111 |
|
32 | | -# Step 3: Copy WezTerm into dist/_vendored |
| 112 | + |
| 113 | +# Paths |
33 | 114 | dist_dir = project_root / "dist" |
| 115 | +launcher_subdir = dist_dir / "terminal_launcher" |
| 116 | + |
| 117 | +# Copy contents of dist/terminal_launcher/ into dist/ |
| 118 | +for item in launcher_subdir.iterdir(): |
| 119 | + dest = dist_dir / item.name |
| 120 | + if item.is_dir(): |
| 121 | + if dest.exists(): |
| 122 | + shutil.rmtree(dest) |
| 123 | + shutil.copytree(item, dest) |
| 124 | + else: |
| 125 | + shutil.copy2(item, dest) |
| 126 | + |
| 127 | +# Optional: Remove the now-empty terminal_launcher folder |
| 128 | +shutil.rmtree(launcher_subdir) |
| 129 | + |
| 130 | + |
| 131 | +# Step 3: Copy WezTerm into dist/_vendored |
34 | 132 | terminal_launcher_dist_dir = dist_dir / "terminal_launcher" |
35 | 133 | vendored_output_path = dist_dir / "_vendored" / WEZTERM_FOLDERNAME |
36 | 134 |
|
37 | 135 | shutil.copytree( |
38 | 136 | vendored_dir / WEZTERM_FOLDERNAME, vendored_output_path, dirs_exist_ok=True |
39 | 137 | ) |
| 138 | + |
| 139 | +shutil.copy(project_root / "license.txt", dist_dir) |
| 140 | +shutil.copy(project_root / "NeuroBlueprint_icon.ico", dist_dir) |
| 141 | + |
| 142 | +shutil.copy( |
| 143 | + project_root / "wezterm_config.lua", |
| 144 | + project_root / "dist" / "_vendored" / WEZTERM_FOLDERNAME, |
| 145 | +) |
| 146 | + |
| 147 | +import os |
| 148 | + |
| 149 | +inno_path = project_root / "inno_complie_script.iss" |
| 150 | + |
| 151 | +if os.path.isfile(inno_path): |
| 152 | + os.remove(inno_path) |
| 153 | +f = open(inno_path, "a") |
| 154 | + |
| 155 | +text = make_inno_setup_script("0.0.0", str(project_root)) # TODO: version |
| 156 | + |
| 157 | +f.write(text.strip()) |
| 158 | +f.close() |
| 159 | + |
| 160 | +# TODO: set up downloader |
| 161 | + |
| 162 | +subprocess.call(rf"C:\Program Files (x86)\Inno Setup 6\iscc {inno_path}") |
0 commit comments