-
Notifications
You must be signed in to change notification settings - Fork 176
Improve handling of initialize_conda / register_python including its default values #1105
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
355a508
e8af358
44c9f5f
c9f9320
77f8c5e
bc6a315
db68a7c
666c2e3
bf24d45
83ed89a
16ffe6e
a913928
cf93b7a
d6236a0
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 |
|---|---|---|
|
|
@@ -7,42 +7,104 @@ | |
|
|
||
| Var mui_AnaCustomOptions | ||
| Var mui_AnaCustomOptions.AddToPath | ||
| Var mui_AnaCustomOptions.RegisterSystemPython | ||
| Var mui_AnaCustomOptions.PostInstall | ||
| Var mui_AnaCustomOptions.PreInstall | ||
| Var mui_AnaCustomOptions.ClearPkgCache | ||
| Var mui_AnaCustomOptions.CreateShortcuts | ||
|
|
||
| # These are the checkbox states, to be used by the installer | ||
| Var Ana_AddToPath_State | ||
| Var Ana_RegisterSystemPython_State | ||
| Var Ana_PostInstall_State | ||
| Var Ana_PreInstall_State | ||
| Var Ana_ClearPkgCache_State | ||
| Var Ana_CreateShortcuts_State | ||
|
|
||
| Var Ana_AddToPath_Label | ||
| Var Ana_RegisterSystemPython_Label | ||
| Var Ana_ClearPkgCache_Label | ||
| Var Ana_PostInstall_Label | ||
| Var Ana_PreInstall_Label | ||
|
|
||
|
|
||
| !if ${REGISTER_PYTHON_OPTION} == 1 | ||
| Var mui_AnaCustomOptions.RegisterSystemPython | ||
| Var Ana_RegisterSystemPython_Label | ||
|
|
||
| Function RegisterSystemPython_OnClick | ||
| Pop $0 | ||
|
|
||
| # Sync UI with variable | ||
| ${NSD_GetState} $0 $1 | ||
| ${If} $1 == ${BST_CHECKED} | ||
| StrCpy $REG_PY 1 | ||
| ${Else} | ||
| StrCpy $REG_PY 0 | ||
| ${EndIf} | ||
|
|
||
| ShowWindow $Ana_RegisterSystemPython_Label ${SW_HIDE} | ||
| ${If} $REG_PY == 1 | ||
| SetCtlColors $Ana_RegisterSystemPython_Label ff0000 transparent | ||
| ${Else} | ||
| SetCtlColors $Ana_RegisterSystemPython_Label 000000 transparent | ||
| ${EndIf} | ||
| ShowWindow $Ana_RegisterSystemPython_Label ${SW_SHOW} | ||
|
|
||
| # If the button was checked, make sure we're not conflicting | ||
| # with another system installed Python | ||
| ${If} $REG_PY == 1 | ||
| # Check if a Python of the version we're installing | ||
| # already exists, in which case warn the user before | ||
| # proceeding. | ||
| ReadRegStr $2 SHCTX "Software\Python\PythonCore\${PY_VER}\InstallPath" "" | ||
| ${If} "$2" != "" | ||
| ${AndIf} ${FileExists} "$2\Python.exe" | ||
| MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION|MB_DEFBUTTON2 \ | ||
| "A version of Python ${PY_VER} (${ARCH}) is already at$\n\ | ||
| $2$\n\ | ||
| We recommend that if you want ${NAME} registered as your $\n\ | ||
| system Python, you unregister this Python first. If you really$\n\ | ||
| know this is what you want, click OK, otherwise$\n\ | ||
| click cancel to continue.$\n$\n\ | ||
| NOTE: Anaconda 1.3 and earlier lacked an uninstall, if$\n\ | ||
| you are upgrading an old Anaconda, please delete the$\n\ | ||
| directory manually." \ | ||
| IDOK KeepSettingLabel | ||
| # If they don't click OK, uncheck it | ||
| StrCpy $REG_PY 0 | ||
| ${NSD_Uncheck} $0 | ||
|
|
||
| KeepSettingLabel: | ||
|
|
||
| ${EndIf} | ||
| ${EndIf} | ||
| FunctionEnd | ||
| !endif | ||
|
|
||
| Function mui_AnaCustomOptions_InitDefaults | ||
| # Initialize defaults | ||
| ${If} $Ana_AddToPath_State == "" | ||
| StrCpy $Ana_AddToPath_State ${BST_UNCHECKED} | ||
| # AddToPath / conda init default | ||
| !if ${INIT_CONDA_OPTION} == 1 | ||
marcoesters marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| # Ensure we initialize from compile-time default value | ||
| StrCpy $INIT_CONDA ${INIT_CONDA_DEFAULT_VALUE} | ||
| !else | ||
| StrCpy $INIT_CONDA 0 | ||
|
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. We need to update the documentation in the schema that the default values have no effect if
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. So for And for Are you thinking of anything else in addition to this?
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. Ah, I didn't see those isolated paragraphs, my bad. The release notes should be updated though since this is new for Windows. The documentation should be updated either way to emphasize that these values only apply to interactive installations and are
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. Updated again in db68a7c
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. I left some feedback to be more user-oriented. We also need to update the description in the schema so that this is documented in
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. Okay so I have made a couple of changes, and there is already some text in the documentation I think already explains the situation. I'll try to explain it so we are aligned. First here are the changes from last 2 commits I've just done: https://github.com/conda/constructor/pull/1105/files/db68a7c3cdeaeaf53a0d832b100eb3bd666ca424..bf24d45b2aadbf0010e26118f5b89a380a107d34
Finally, this leaves us with the following: Let me know what you think.
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.
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. Changed back here 16ffe6e.
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. See latest commit a913928 |
||
| !endif | ||
|
|
||
| # Register Python default while accounting for existing installations | ||
| !if ${REGISTER_PYTHON_OPTION} == 1 | ||
| # Ensure we initialize from compile-time default value | ||
| StrCpy $REG_PY ${REGISTER_PYTHON_DEFAULT_VALUE} | ||
| # Default whether to register as system python as: | ||
| # Enabled - if no system python is registered, OR | ||
| # a system python which does not exist is registered. | ||
| # Disabled - If a system python which exists is registered. | ||
| ReadRegStr $2 SHCTX "Software\Python\PythonCore\${PY_VER}\InstallPath" "" | ||
| ${If} "$2" != "" | ||
| ${AndIf} ${FileExists} "$2\Python.exe" | ||
| StrCpy $Ana_RegisterSystemPython_State ${BST_UNCHECKED} | ||
| ${Else} | ||
| StrCpy $Ana_RegisterSystemPython_State ${BST_CHECKED} | ||
| StrCpy $REG_PY 0 | ||
| ${EndIf} | ||
| ${EndIf} | ||
| !else | ||
| StrCpy $REG_PY 0 | ||
| !endif | ||
|
|
||
| # Shortcuts defaults | ||
| ${If} $Ana_CreateShortcuts_State == "" | ||
| ${If} "${ENABLE_SHORTCUTS}" == "yes" | ||
| StrCpy $Ana_CreateShortcuts_State ${BST_CHECKED} | ||
|
|
@@ -57,7 +119,7 @@ FunctionEnd | |
|
|
||
| Function mui_AnaCustomOptions_Show | ||
| ; Enforce that the defaults were initialized | ||
| ${If} $Ana_AddToPath_State == "" | ||
| ${If} $INIT_CONDA == "" | ||
| Abort | ||
| ${EndIf} | ||
|
|
||
|
|
@@ -84,17 +146,26 @@ Function mui_AnaCustomOptions_Show | |
| ${NSD_OnClick} $mui_AnaCustomOptions.CreateShortcuts CreateShortcuts_OnClick | ||
| ${EndIf} | ||
|
|
||
| ${If} "${SHOW_ADD_TO_PATH}" != "no" | ||
| !if ${INIT_CONDA_OPTION} == 1 | ||
| # AddToPath is only an option for JustMe installations; it is disabled for AllUsers | ||
| # installations. (Addresses CVE-2022-26526) | ||
| ${If} $InstMode = ${JUST_ME} | ||
| ${NSD_CreateCheckbox} 0 "$5u" 100% 11u "Add installation to my &PATH \ | ||
| environment variable" | ||
| IntOp $5 $5 + 11 | ||
| Pop $mui_AnaCustomOptions.AddToPath | ||
| ${NSD_SetState} $mui_AnaCustomOptions.AddToPath $Ana_AddToPath_State | ||
|
|
||
| # Set state of check-box | ||
| ${If} $INIT_CONDA == 1 | ||
| ${NSD_Check} $mui_AnaCustomOptions.AddToPath | ||
| ${Else} | ||
| ${NSD_Uncheck} $mui_AnaCustomOptions.AddToPath | ||
| ${EndIf} | ||
|
|
||
| ${NSD_OnClick} $mui_AnaCustomOptions.AddToPath AddToPath_OnClick | ||
| ${If} "${SHOW_ADD_TO_PATH}" == "condabin" | ||
|
|
||
| # Account for the conda mode | ||
| ${If} "${INIT_CONDA_MODE}" == "condabin" | ||
| ${NSD_CreateLabel} 5% "$5u" 90% 20u \ | ||
| "Adds condabin/, which only contains the 'conda' executables, to PATH. \ | ||
| Does not require special shortcuts but activation needs \ | ||
|
|
@@ -107,26 +178,54 @@ Function mui_AnaCustomOptions_Show | |
| ${EndIf} | ||
| IntOp $5 $5 + 20 | ||
| Pop $Ana_AddToPath_Label | ||
|
|
||
| # Color the label if needed; even if the user has not interacted with the checkbox yet | ||
| ${If} $INIT_CONDA = 1 | ||
| ${If} "${INIT_CONDA_MODE}" == "classic" | ||
| SetCtlColors $Ana_AddToPath_Label ff0000 transparent | ||
| ${Else} | ||
| # Here INIT_CONDA_MODE equals condabin | ||
| SetCtlColors $Ana_AddToPath_Label 000000 transparent | ||
| ${EndIf} | ||
| ${Else} | ||
| SetCtlColors $Ana_AddToPath_Label 000000 transparent | ||
| ${EndIf} | ||
| ${EndIf} | ||
| ${EndIf} | ||
| !endif | ||
|
|
||
| ${If} "${SHOW_REGISTER_PYTHON}" == "yes" | ||
| !if ${REGISTER_PYTHON_OPTION} == 1 | ||
| ${If} $InstMode = ${JUST_ME} | ||
| StrCpy $1 "my default" | ||
| ${Else} | ||
| StrCpy $1 "the system" | ||
| ${EndIf} | ||
|
|
||
| ${NSD_CreateCheckbox} 0 "$5u" 100% 11u "&Register ${NAME} as $1 Python ${PY_VER}" | ||
| IntOp $5 $5 + 11 | ||
| Pop $mui_AnaCustomOptions.RegisterSystemPython | ||
| ${NSD_SetState} $mui_AnaCustomOptions.RegisterSystemPython $Ana_RegisterSystemPython_State | ||
|
|
||
| # Set state of check-box | ||
| ${If} $REG_PY == 1 | ||
| ${NSD_Check} $mui_AnaCustomOptions.RegisterSystemPython | ||
| ${Else} | ||
| ${NSD_Uncheck} $mui_AnaCustomOptions.RegisterSystemPython | ||
| ${EndIf} | ||
|
|
||
| ${NSD_OnClick} $mui_AnaCustomOptions.RegisterSystemPython RegisterSystemPython_OnClick | ||
|
|
||
| ${NSD_CreateLabel} 5% "$5u" 90% 20u \ | ||
| "Allows other programs, such as VSCode, PyCharm, etc. to automatically \ | ||
| detect ${NAME} as the primary Python ${PY_VER} on the system." | ||
| IntOp $5 $5 + 20 | ||
| Pop $Ana_RegisterSystemPython_Label | ||
| ${EndIf} | ||
|
|
||
| # Color the label if needed; even if the user has not interacted with the checkbox yet | ||
| ${If} $REG_PY = 1 | ||
| SetCtlColors $Ana_RegisterSystemPython_Label ff0000 transparent | ||
| ${Else} | ||
| SetCtlColors $Ana_RegisterSystemPython_Label 000000 transparent | ||
| ${EndIf} | ||
| !endif | ||
|
|
||
|
|
||
| ${NSD_CreateCheckbox} 0 "$5u" 100% 11u "Clear the package cache upon completion" | ||
|
|
@@ -167,58 +266,24 @@ FunctionEnd | |
| Function AddToPath_OnClick | ||
| Pop $0 | ||
|
|
||
| ShowWindow $Ana_AddToPath_Label ${SW_HIDE} | ||
| ${NSD_GetState} $0 $Ana_AddToPath_State | ||
| ${If} $Ana_AddToPath_State == ${BST_UNCHECKED} | ||
| ${Else} | ||
| ${If} "${SHOW_ADD_TO_PATH}" == "condabin" | ||
| SetCtlColors $Ana_AddToPath_Label 000000 transparent | ||
| ${Else} | ||
| SetCtlColors $Ana_AddToPath_Label ff0000 transparent | ||
| ${EndIf} | ||
| ${EndIf} | ||
| ShowWindow $Ana_AddToPath_Label ${SW_SHOW} | ||
| FunctionEnd | ||
|
|
||
| Function RegisterSystemPython_OnClick | ||
| Pop $0 | ||
|
|
||
| ShowWindow $Ana_RegisterSystemPython_Label ${SW_HIDE} | ||
| ${NSD_GetState} $0 $Ana_RegisterSystemPython_State | ||
| ${If} $Ana_RegisterSystemPython_State == ${BST_UNCHECKED} | ||
| SetCtlColors $Ana_RegisterSystemPython_Label ff0000 transparent | ||
| # Sync UI with variable | ||
| ${NSD_GetState} $0 $1 | ||
| ${If} $1 == ${BST_CHECKED} | ||
| StrCpy $INIT_CONDA 1 | ||
| ${Else} | ||
| SetCtlColors $Ana_RegisterSystemPython_Label 000000 transparent | ||
| StrCpy $INIT_CONDA 0 | ||
| ${EndIf} | ||
| ShowWindow $Ana_RegisterSystemPython_Label ${SW_SHOW} | ||
|
|
||
| # If the button was checked, make sure we're not conflicting | ||
| # with another system installed Python | ||
| ${If} $Ana_RegisterSystemPython_State == ${BST_CHECKED} | ||
| # Check if a Python of the version we're installing | ||
| # already exists, in which case warn the user before | ||
| # proceeding. | ||
| ReadRegStr $2 SHCTX "Software\Python\PythonCore\${PY_VER}\InstallPath" "" | ||
| ${If} "$2" != "" | ||
| ${AndIf} ${FileExists} "$2\Python.exe" | ||
| MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION|MB_DEFBUTTON2 \ | ||
| "A version of Python ${PY_VER} (${ARCH}) is already at$\n\ | ||
| $2$\n\ | ||
| We recommend that if you want ${NAME} registered as your $\n\ | ||
| system Python, you unregister this Python first. If you really$\n\ | ||
| know this is what you want, click OK, otherwise$\n\ | ||
| click cancel to continue.$\n$\n\ | ||
| NOTE: Anaconda 1.3 and earlier lacked an uninstall, if$\n\ | ||
| you are upgrading an old Anaconda, please delete the$\n\ | ||
| directory manually." \ | ||
| IDOK KeepSettingLabel | ||
| # If they don't click OK, uncheck it | ||
| StrCpy $Ana_RegisterSystemPython_State ${BST_UNCHECKED} | ||
| ${NSD_SetState} $0 $Ana_RegisterSystemPython_State | ||
| KeepSettingLabel: | ||
|
|
||
| ShowWindow $Ana_AddToPath_Label ${SW_HIDE} | ||
| # Only color it red if it's classic | ||
| ${If} $INIT_CONDA == 1 | ||
marcoesters marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ${If} "${INIT_CONDA_MODE}" == "classic" | ||
| SetCtlColors $Ana_AddToPath_Label ff0000 transparent | ||
| ${EndIf} | ||
| ${Else} | ||
| SetCtlColors $Ana_AddToPath_Label 000000 transparent | ||
| ${EndIf} | ||
| ShowWindow $Ana_AddToPath_Label ${SW_SHOW} | ||
| FunctionEnd | ||
|
|
||
| Function PostInstall_OnClick | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.