-
Notifications
You must be signed in to change notification settings - Fork 176
Convert script and directory _nsis.py subcommands into NSIS code
#1069
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
fb55d49
aa501ac
82151fb
ee9e827
5a89445
9434843
f0a7a20
e833de2
486a928
f139260
b9733c7
881f002
ffc70f2
b1a9388
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -132,6 +132,22 @@ var /global InstMode # 0 = Just Me, 1 = All Users. | |||||
| !define JUST_ME 0 | ||||||
| !define ALL_USERS 1 | ||||||
|
|
||||||
| var /global CMD_EXE | ||||||
|
|
||||||
| !macro FindCmdExe | ||||||
| # Find cmd.exe | ||||||
| ReadEnvStr $R0 SystemRoot | ||||||
| ReadEnvStr $R1 windir | ||||||
| ${If} ${FileExists} "$R0" | ||||||
| StrCpy $CMD_EXE "$R0\System32\cmd.exe" | ||||||
| ${ElseIf} ${FileExists} "$R1" | ||||||
| StrCpy $CMD_EXE "$R1\System32\cmd.exe" | ||||||
| ${Else} | ||||||
| # Cross our fingers CMD is in PATH | ||||||
| StrCpy $CMD_EXE "cmd.exe" | ||||||
| ${EndIf} | ||||||
| !macroend | ||||||
|
|
||||||
| # Include this one after our defines | ||||||
| !include "OptionsDialog.nsh" | ||||||
|
|
||||||
|
|
@@ -1226,6 +1242,8 @@ Section "Install" | |||||
| call OnDirectoryLeave | ||||||
| ${EndIf} | ||||||
|
|
||||||
| !insertmacro FindCmdExe | ||||||
|
|
||||||
| SetOutPath "$INSTDIR\Lib" | ||||||
| File "{{ NSIS_DIR }}\_nsis.py" | ||||||
| File "{{ NSIS_DIR }}\_system_path.py" | ||||||
|
|
@@ -1352,17 +1370,7 @@ Section "Install" | |||||
|
|
||||||
| IfFileExists "$INSTDIR\pkgs\pre_install.bat" 0 NoPreInstall | ||||||
| ${Print} "Running pre_install scripts..." | ||||||
| ReadEnvStr $5 SystemRoot | ||||||
| ReadEnvStr $6 windir | ||||||
| # This 'FileExists' also returns True for directories | ||||||
| ${If} ${FileExists} "$5" | ||||||
| push '"$5\System32\cmd.exe" /D /C "$INSTDIR\pkgs\pre_install.bat"' | ||||||
| ${ElseIf} ${FileExists} "$6" | ||||||
| push '"$6\System32\cmd.exe" /D /C "$INSTDIR\pkgs\pre_install.bat"' | ||||||
| ${Else} | ||||||
| # Cross our fingers CMD is in PATH | ||||||
| push 'cmd.exe /D /C "$INSTDIR\pkgs\pre_install.bat"' | ||||||
| ${EndIf} | ||||||
| push '"$CMD_EXE" /D /C "$INSTDIR\pkgs\pre_install.bat"' | ||||||
| push "Failed to run pre_install" | ||||||
| push 'WithLog' | ||||||
| call AbortRetryNSExecWait | ||||||
|
|
@@ -1414,19 +1422,20 @@ Section "Install" | |||||
| AddSize {{ SIZE }} | ||||||
|
|
||||||
| {%- if has_conda %} | ||||||
| ${Print} "Initializing conda directories..." | ||||||
| push '"$INSTDIR\pythonw.exe" -E -s "$INSTDIR\Lib\_nsis.py" mkdirs' | ||||||
| push 'Failed to initialize conda directories' | ||||||
| push 'WithLog' | ||||||
| call AbortRetryNSExecWait | ||||||
| StrCpy $R0 "$INSTDIR\envs" | ||||||
| ${IfNot} ${FileExists} "$R0" | ||||||
| CreateDirectory "$R0" | ||||||
| ${EndIf} | ||||||
| {%- endif %} | ||||||
|
|
||||||
| ${If} $Ana_PostInstall_State = ${BST_CHECKED} | ||||||
| ${Print} "Running post install..." | ||||||
| push '"$INSTDIR\pythonw.exe" -E -s "$INSTDIR\Lib\_nsis.py" post_install' | ||||||
| push 'Failed to run post install script' | ||||||
| push 'WithLog' | ||||||
| call AbortRetryNSExecWait | ||||||
| ${If} ${FileExists} "$INSTDIR\pkgs\post_install.bat" | ||||||
| ${If} $Ana_PostInstall_State = ${BST_CHECKED} | ||||||
| ${Print} "Running post install..." | ||||||
| push '"$CMD_EXE" /D /C "$INSTDIR\pkgs\post_install.bat"' | ||||||
| push "Failed to run post_install" | ||||||
| push 'WithLog' | ||||||
| call AbortRetryNSExecWait | ||||||
| ${EndIf} | ||||||
| ${EndIf} | ||||||
|
|
||||||
| ${If} $Ana_ClearPkgCache_State = ${BST_CHECKED} | ||||||
|
|
@@ -1543,6 +1552,8 @@ Section "Uninstall" | |||||
| !insertmacro un.ParseCommandLineArgs | ||||||
| ${EndIf} | ||||||
|
|
||||||
| !insertmacro FindCmdExe | ||||||
|
|
||||||
| System::Call 'kernel32::SetEnvironmentVariable(t,t)i("CONDA_ROOT_PREFIX", "$INSTDIR")".r0' | ||||||
|
|
||||||
| # ensure that MSVC runtime DLLs are on PATH during uninstallation | ||||||
|
|
@@ -1598,9 +1609,14 @@ Section "Uninstall" | |||||
| ${EndIf} | ||||||
|
|
||||||
| {%- if uninstall_with_conda_exe %} | ||||||
| !insertmacro AbortRetryNSExecWaitLibNsisCmd "pre_uninstall" | ||||||
| ${If} ${FileExists} "$INSTDIR\pkgs\pre_uninstall.bat" | ||||||
| ${Print} "Running pre_uninstall scripts..." | ||||||
| push '"$CMD_EXE" /D /C "$INSTDIR\pkgs\pre_uninstall.bat"' | ||||||
| push "Failed to run pre_uninstall" | ||||||
| push 'WithLog' | ||||||
| call un.AbortRetryNSExecWait | ||||||
| ${EndIf} | ||||||
| !insertmacro AbortRetryNSExecWaitLibNsisCmd "rmpath" | ||||||
| !insertmacro AbortRetryNSExecWaitLibNsisCmd "rmreg" | ||||||
|
|
||||||
| # Parse arguments | ||||||
| StrCpy $R0 "" | ||||||
|
|
@@ -1648,9 +1664,29 @@ Section "Uninstall" | |||||
| call un.AbortRetryNSExecWait | ||||||
| SetDetailsPrint both | ||||||
| {%- endfor %} | ||||||
| !insertmacro AbortRetryNSExecWaitLibNsisCmd "pre_uninstall" | ||||||
| ${If} ${FileExists} "$INSTDIR\pkgs\pre_uninstall.bat" | ||||||
| ${Print} "Running pre_uninstall scripts..." | ||||||
| push '"$CMD_EXE" /D /C "$INSTDIR\pkgs\pre_uninstall.bat"' | ||||||
| push "Failed to run pre_uninstall" | ||||||
| push 'WithLog' | ||||||
| call un.AbortRetryNSExecWait | ||||||
| ${EndIf} | ||||||
| !insertmacro AbortRetryNSExecWaitLibNsisCmd "rmpath" | ||||||
| !insertmacro AbortRetryNSExecWaitLibNsisCmd "rmreg" | ||||||
| {%- if has_conda %} | ||||||
| ${If} ${FileExists} "$INSTDIR\.nonadmin" | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Optional: If you prefer, you can create a new variable (maybe I have no strong opinion though, I also like the simplicity with simply using |
||||||
| StrCpy $R0 "user" | ||||||
| ${Else} | ||||||
| StrCpy $R0 "system" | ||||||
| ${EndIf} | ||||||
| # When running conda.bat directly, there is a non-fatal error | ||||||
| # that DOSKEY (called by conda_hook.bat) is not a valid command. | ||||||
| # While the operation still succeeds, this error is confusing. | ||||||
| # Calling via cmd.exe fixes that. | ||||||
| push '"$CMD_EXE" /D /C "$INSTDIR\condabin\conda.bat" init cmd.exe --reverse --$R0' | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Should we revert for both cmd and powershell (which is achieved by passing no positional arguments)?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The powershell function does not perform path validation, so it will also revert profiles that point to a different installation. The cmd.exe function, on the other hand, only reverts the autorun entry that belongs to the installation. |
||||||
| push 'Failed to clean AutoRun' | ||||||
| push 'WithLog' | ||||||
| call un.AbortRetryNSExecWait | ||||||
| {%- endif %} | ||||||
|
|
||||||
| ${Print} "Removing files and folders..." | ||||||
| nsExec::Exec 'cmd.exe /D /C RMDIR /Q /S "$INSTDIR"' | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| ### Enhancements | ||
|
|
||
| * Port script execution, AutoRun manipulation, and directory creation functions from `_nsis.py` to NSIS. (#1069) | ||
|
|
||
| ### Bug fixes | ||
|
|
||
| * <news item> | ||
|
|
||
| ### Deprecations | ||
|
|
||
| * <news item> | ||
|
|
||
| ### Docs | ||
|
|
||
| * <news item> | ||
|
|
||
| ### Other | ||
|
|
||
| * <news item> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this no longer needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was actually never needed. The uninstallation via
conda-standalonealready performs the same function during the installation process. I included that line back then by mistake.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, thanks!