forked from pyrevitlabs/pyRevit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpyrevit.iss
More file actions
177 lines (165 loc) · 8.05 KB
/
Copy pathpyrevit.iss
File metadata and controls
177 lines (165 loc) · 8.05 KB
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
#define MyAppName "pyRevit"
#define MyAppUUID "f2a3da53-6f34-41d5-abbd-389ffa7f4d5f"
#define MyAppVersion "6.5.3.26176"
#define MyAppPublisher "pyRevitLabs"
#define MyAppURL "pyrevitlabs.io"
#include "CodeDependencies.iss"
[Setup]
; App information
AppId={#MyAppUUID}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
AppCopyright=Copyright © 2014-2026 pyRevitLabs.io
LicenseFile=..\LICENSE.txt
; Installer
DefaultGroupName={#MyAppName}
DisableDirPage=auto
DisableStartupPrompt=yes
DisableProgramGroupPage=yes
ChangesEnvironment=yes
; path
DefaultDirName={userappdata}\{#MyAppName}-Master
UsePreviousAppDir=yes
; mode
PrivilegesRequired=lowest
; Build info
OutputDir=..\dist
; Keep this list aligned with the installer assets staged by build/.
OutputBaseFilename=pyRevit_{#MyAppVersion}_signed
SetupIconFile=..\bin\pyrevit.ico
Compression=lzma
SolidCompression=yes
DisableWelcomePage=no
WizardStyle=classic
WizardImageFile=.\pyrevit.bmp
WizardSmallImageFile=.\pyrevit-banner.bmp
ArchitecturesInstallIn64BitMode=x64compatible
[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
[Components]
Name: "core"; Description: "pyRevit Core Tools"; Types: full compact custom; Flags: fixed
Name: "ext"; Description: "pyRevit Extended Extensions"; Types: full custom
Name: "dev"; Description: "pyRevit Developer Extensions"; Types: custom
Name: "learn"; Description: "pyRevit Tutorials Extension"; Types: custom
[Files]
; bin\
Source: "..\bin\*"; DestDir: "{app}\bin"; Flags: ignoreversion recursesubdirs; Components: core dev learn
; extensions
Source: "..\extensions\*"; DestDir: "{app}\extensions"; Flags: ignoreversion; Components: core dev learn
Source: "..\extensions\pyRevitCore.extension\*"; DestDir: "{app}\extensions\pyRevitCore.extension"; Flags: ignoreversion recursesubdirs; Components: core
Source: "..\extensions\pyRevitTools.extension\*"; DestDir: "{app}\extensions\pyRevitTools.extension"; Flags: ignoreversion recursesubdirs; Components: core
Source: "..\extensions\pyRevitTags.extension\*"; DestDir: "{app}\extensions\pyRevitTags.extension"; Flags: ignoreversion recursesubdirs; Components: ext
Source: "..\extensions\pyRevitTemplates.extension\*"; DestDir: "{app}\extensions\pyRevitTemplates.extension"; Flags: ignoreversion recursesubdirs; Components: ext
Source: "..\extensions\pyRevitDevTools.extension\*"; DestDir: "{app}\extensions\pyRevitDevTools.extension"; Flags: ignoreversion recursesubdirs; Components: dev
Source: "..\extensions\pyRevitDevHooks.extension\*"; DestDir: "{app}\extensions\pyRevitDevHooks.extension"; Flags: ignoreversion recursesubdirs; Components: dev
Source: "..\extensions\pyRevitTutor.extension\*"; DestDir: "{app}\extensions\pyRevitTutor.extension"; Flags: ignoreversion recursesubdirs; Components: learn
Source: "..\extensions\pyRevitBundlesCreatorExtension.extension\*"; DestDir: "{app}\extensions\pyRevitBundlesCreatorExtension.extension"; Flags: ignoreversion recursesubdirs; Components: ext
; python libs
Source: "..\pyrevitlib\*"; DestDir: "{app}\pyrevitlib"; Flags: ignoreversion recursesubdirs; Components: core dev learn
; python site_packages
Source: "..\site-packages\*"; DestDir: "{app}\site-packages"; Flags: ignoreversion recursesubdirs; Components: core dev learn
; clone arguments
Source: "..\release\.pyrevitargs"; DestDir: "{app}"; Flags: ignoreversion; Components: core dev learn
Source: "..\pyRevitfile"; DestDir: "{app}"; Flags: ignoreversion; Components: core dev learn
[Registry]
; Uninstaller does not undo this change
; Multiple installs keep adding the path
; When run as admin, HKCU would be the elevated user's; PATH is set in CurStepChanged via ExecAsOriginalUser instead.
; https://stackoverflow.com/a/3431379/2350244
; https://stackoverflow.com/a/9962307/2350244 (mod path module)
Root: HKCU; Subkey: "Environment"; ValueType: expandsz; ValueName: "Path"; ValueData: "{olddata};{app}\bin"; Check: NotAdminAndPathNotExists
[Run]
Filename: "{app}\bin\pyrevit.exe"; Description: "Clearing caches..."; Parameters: "caches clear --all"; Flags: runhidden; Check: not IsAdmin
Filename: "{app}\bin\pyrevit.exe"; Description: "Detach existing clones..."; Parameters: "detach --all"; Flags: runhidden; Check: not IsAdmin
Filename: "{app}\bin\pyrevit.exe"; Description: "Registering this clone..."; Parameters: "clones add this master --force"; Flags: runhidden; Check: not IsAdmin
Filename: "{app}\bin\pyrevit.exe"; Description: "Attaching this clone..."; Parameters: "attach master default --installed"; Flags: runhidden; Check: not IsAdmin
Filename: "{app}\bin\pyrevit.exe"; Description: "Seeding extension defaults..."; Parameters: "configs seedshippeddefaults"; Flags: runhidden; Check: not IsAdmin
[UninstallRun]
Filename: "{app}\bin\pyrevit.exe"; RunOnceId: "ClearCaches"; Parameters: "caches clear --all"; Flags: runhidden
Filename: "{app}\bin\pyrevit.exe"; RunOnceId: "DetachClones"; Parameters: "detach --all"; Flags: runhidden
[Code]
function NotAdminAndPathNotExists: Boolean;
var
OrigPath: String;
AppPath: String;
begin
Result := not IsAdmin;
if Result then
begin
AppPath := ExpandConstant('{app}\bin');
if RegQueryStringValue(HKCU, 'Environment', 'Path', OrigPath) then
Result := Pos(';' + Uppercase(AppPath) + ';', ';' + Uppercase(OrigPath) + ';') = 0;
end;
end;
function RunPyRevitCommand(const Params: String): Boolean;
var
ResultCode: Integer;
PyRevitExe: String;
begin
Result := False;
PyRevitExe := ExpandConstant('{app}\bin\pyrevit.exe');
if not FileExists(PyRevitExe) then
begin
Log('pyrevit.exe not found: ' + PyRevitExe);
Exit;
end;
Result := ExecAsOriginalUser(PyRevitExe, Params, ExpandConstant('{app}\bin'), SW_HIDE, ewWaitUntilTerminated, ResultCode);
if not Result then
Log('Failed to execute pyrevit ' + Params)
else if ResultCode <> 0 then
begin
Log('pyrevit exited with code ' + IntToStr(ResultCode) + ': ' + Params);
Result := False;
end;
end;
procedure RunElevatedUserPostInstallCommands;
begin
RunPyRevitCommand('caches clear --all');
RunPyRevitCommand('detach --all');
if not RunPyRevitCommand('clones add this master --force') then
Log('Elevated install: pyrevit clones add failed for original user');
if not RunPyRevitCommand('attach master default --installed') then
Log('Elevated install: pyrevit attach failed for original user');
if not RunPyRevitCommand('configs seedshippeddefaults') then
Log('Elevated install: pyrevit configs seedshippeddefaults failed for original user');
end;
procedure CurStepChanged(CurStep: TSetupStep);
var
Params: String;
InstallPathEscaped: String;
ResultCode: Integer;
begin
if (CurStep = ssPostInstall) and IsAdmin then
begin
RunElevatedUserPostInstallCommands;
InstallPathEscaped := ExpandConstant('{app}\bin');
StringChangeEx(InstallPathEscaped, '''', '''''', True);
Params := '-NoProfile -ExecutionPolicy Bypass -Command "' +
'$appPath = ''' + InstallPathEscaped + ''';' +
'$userPath = [Environment]::GetEnvironmentVariable(''Path'', ''User'');' +
'if ($userPath -notlike "' + '"*$appPath*"' + '") {' +
' [Environment]::SetEnvironmentVariable(''Path'', $userPath + '';'' + $appPath, ''User'')' +
'}"';
if ExecAsOriginalUser(ExpandConstant('{sys}\WindowsPowerShell\v1.0\powershell.exe'), Params, '', SW_HIDE, ewWaitUntilTerminated, ResultCode) and (ResultCode = 0) then
Log('Added install path to original user PATH')
else
begin
Log('ExecAsOriginalUser failed or non-zero exit when adding PATH');
MsgBox('pyRevit was installed, but the installer could not update the original user PATH environment variable.' + #13#10 + #13#10 + 'You may need to manually add the following folder to your user PATH, or re-run the installer without administrative privileges:' + #13#10 + ' ' + ExpandConstant('{app}\bin'), mbError, MB_OK);
end;
end;
end;
function InitializeSetup: Boolean;
begin
// .NET 8 for Revit 2025-2026
Dependency_AddDotNet80;
Dependency_AddDotNet80Desktop;
// .NET 10 for Revit 2027+
Dependency_AddDotNet100;
Dependency_AddDotNet100Desktop;
Result := True;
end;