diff --git a/scripts/windows/PythonHelpers.nsh b/scripts/windows/PythonHelpers.nsh index 33419edd864..5650060fc95 100644 --- a/scripts/windows/PythonHelpers.nsh +++ b/scripts/windows/PythonHelpers.nsh @@ -1,29 +1,31 @@ !include TextFunc.nsh -# ${GetPythonInstall} VERSION $(user_var: INSTALL_PREFIX) $(user_var: INSTALL_MODE) +# ${GetPythonInstallPEP514} COMPANY TAG $(user_var: INSTALL_PREFIX) $(user_var: INSTALL_MODE) # -# Retrive the registered install prefix for Python -# - input: VERSION is a Major.Minor version number +# Retrive the registered install prefix for Python (as documented by PEP 514) +# - input: COMPANY distibutor (use PythonCore for default pyhton.org +# distributed python) +# - input: TAG environemnt tag (e.g 3.6 or 3.6-32; sys.winver for PythonCore) # - output: INSTALL_PREFIX installation path (e.g C:\Python35) or empty if # not found # - output: INSTALL_MODE -# 1 if Python was installed for all users or 0 if -# current user only (-1 when not installed). +# 1 if Python was installed for all users, 0 if +# current user only or -1 when not found. # # Example # ------- -# ${GetPythonInstall} 3.5 $PythonDir $InstallMode - +# ${GetPythonInstallPEP14} PythonCore 3.5 $PythonDir $InstallMode +# ${GetPythonInstallPEP14} ContinuumAnalytics Anaconda36-64 $1 $2 -!macro __GET_PYTHON_INSTALL VERSION INSTALL_PREFIX INSTALL_MODE +!macro __GET_PYTHON_INSTALL_PEP514 COMPANY TAG INSTALL_PREFIX INSTALL_MODE ReadRegStr ${INSTALL_PREFIX} \ - HKCU Software\Python\PythonCore\${VERSION}\InstallPath "" + HKCU Software\Python\${COMPANY}\${TAG}\InstallPath "" ${If} ${INSTALL_PREFIX} != "" StrCpy ${INSTALL_MODE} 0 ${Else} ReadRegStr ${INSTALL_PREFIX} \ - HKLM Software\Python\PythonCore\${VERSION}\InstallPath "" + HKLM Software\Python\${COMPANY}\${TAG}\InstallPath "" ${If} ${INSTALL_PREFIX} != "" StrCpy ${INSTALL_MODE} 1 ${Else} @@ -43,14 +45,42 @@ Pop $0 ${EndIf} !macroend -!define GetPythonInstall "!insertmacro __GET_PYTHON_INSTALL" +!define GetPythonInstallPEP514 "!insertmacro __GET_PYTHON_INSTALL_PEP514" + + +# ${GetPythonInstall} VERSION BITS $(user_var: INSTALL_PREFIX) $(user_var: INSTALL_MODE) +# +# Retrive the registered install prefix for Python +# - input: VERSION is a Major.Minor version number +# - input: BITS is 32 or 64 constant speciying which python arch to lookup +# - output: INSTALL_PREFIX installation path (e.g C:\Python35) or empty if +# not found +# - output: INSTALL_MODE +# 1 if Python was installed for all users, 0 if +# current user only or -1 when not found. +# +# Example +# ------- +# ${GetPythonInstall} 3.5 64 $PythonDir $InstallMode +!macro __GET_PYTHON_INSTALL VERSION BITS INSTALL_PREFIX INSTALL_MODE + !if ${VERSION} < 3.5 + !define __TAG ${VERSION} + !else if ${BITS} == 64 + !define __TAG ${VERSION} + !else + !define __TAG ${VERSION}-${BITS} + !endif + ${GetPythonInstallPEP514} PythonCore ${__TAG} ${INSTALL_PREFIX} ${INSTALL_MODE} + !undef __TAG +!macroend +!define GetPythonInstall "!insertmacro __GET_PYTHON_INSTALL" # ${GetAnacondaInstall} VERSIONTAG BITS $(user_var: INSTALL_PREFIX) $(user_var: INSTALL_MODE) # # Retrive the registered install prefix for Python # - input: VERSIONTAG is a MajorMinor version number (no dots) -# - input: BITS 34 or 64 (constant!) +# - input: BITS 34 or 64 (constant) # - output: INSTALL_PREFIX installation path (e.g C:\Python35) # - output: INSTALL_MODE # 1 if Python was installed for all users or 0 if @@ -58,41 +88,12 @@ # # Example # ------- -# ${GetPythonInstall} 3.5 $PythonDir $InstallMode +# ${GetAnacondaInstall} 35 64 $PythonDir $InstallMode !macro __GET_CONDA_INSTALL VERSION_TAG BITS INSTALL_PREFIX INSTALL_MODE - !define __CONDA_REG_PREFIX \ - Software\Python\ContinuumAnalytics\Anaconda${VERSION_TAG}-${BITS} - - !if "${BITS}" != 32 - !if "${BITS}" != 64 - !error "BITS must be a 32 or 64 constant" - !endif - !endif - ReadRegStr ${INSTALL_PREFIX} HKCU ${__CONDA_REG_PREFIX}\InstallPath "" - ${If} ${INSTALL_PREFIX} != "" - StrCpy ${INSTALL_MODE} 0 - ${Else} - ReadRegStr ${INSTALL_PREFIX} HKLM ${__CONDA_REG_PREFIX}\InstallPath "" - ${If} ${INSTALL_PREFIX} != "" - StrCpy ${INSTALL_MODE} 1 - ${Else} - StrCpy ${INSTALL_MODE} 0 - ${EndIf} - ${EndIf} - - ${If} ${INSTALL_PREFIX} != "" - # Strip (single) trailing '\' if present - Push $0 - StrCpy $0 ${INSTALL_PREFIX} "" -1 - ${If} $0 == "\" - StrLen $0 ${INSTALL_PREFIX} - IntOp $0 $0 - 1 - StrCpy ${INSTALL_PREFIX} ${INSTALL_PREFIX} $0 0 - ${EndIf} - Pop $0 - ${EndIf} - !undef __CONDA_REG_PREFIX + !define __TAG Anaconda${VERSION_TAG}-${BITS} + ${GetPythonInstallPEP514} ContinuumAnalytics ${__TAG} ${INSTALL_PREFIX} ${INSTALL_MODE} + !undef __TAG !macroend !define GetAnacondaInstall "!insertmacro __GET_CONDA_INSTALL" @@ -118,6 +119,8 @@ ReadRegStr $2 ${ROOT_KEY} \ "${__CONDA_REG_PREFIX}\$1\InstallPath" "" ${If} $2 != "" + ${AndIf} ${FileExists} "$2\python.exe" + ${AndIf} ${FileExists} "$2\Scripts\conda.exe" ${LogWrite} "${ROOT_KEY} ${__CONDA_REG_PREFIX}\$1\InstallPath: $2" Exch $2 # $0, $1, $2, "prefix" ${EndIf} diff --git a/scripts/windows/condainstall.bat b/scripts/windows/condainstall.bat index 1a2a62a01fd..5fa5fce3dea 100644 --- a/scripts/windows/condainstall.bat +++ b/scripts/windows/condainstall.bat @@ -30,6 +30,13 @@ rem # with a local package, we need to create it manually. echo @echo off > "%PREFIX%\Scripts\conda.bat" echo call "%CONDA%" %%* >> "%PREFIX%\Scripts\conda.bat" +rem # same for activate.bat +rem # +for %%f in ( "%CONDA%" ) do ( set "CONDA_DIR=%%~dpf" ) +echo @echo off > "%PREFIX%\Scripts\activate.bat" +echo call "%CONDA_DIR%\activate.bat" %%* >> "%PREFIX%\Scripts\activate.bat" +set CONDA_DIR= + rem # Create .condarc file that includes conda-forge channel rem # We need it so add-ons can be installed from conda-forge echo Appending conda-forge channel diff --git a/scripts/windows/orange-conda.nsi b/scripts/windows/orange-conda.nsi index 0f543801299..e4d57199693 100644 --- a/scripts/windows/orange-conda.nsi +++ b/scripts/windows/orange-conda.nsi @@ -171,6 +171,10 @@ Var StartMenuFolder # - no check box to enable/disable start menu creation # (is controled by the Components Page) !define MUI_STARTMENUPAGE_NODISABLE +# Registry key path where the selected start folder name is stored +!define MUI_STARTMENUPAGE_REGISTRY_ROOT SHELL_CONTEXT +!define MUI_STARTMENUPAGE_REGISTRY_KEY ${INSTALL_SETTINGS_KEY} +!define MUI_STARTMENUPAGE_REGISTRY_VALUENAME StartMenuFolder !insertmacro MUI_PAGE_STARTMENU StartMenuPageID $StartMenuFolder # Install Files page: @@ -574,6 +578,11 @@ Section "Start Menu Shortcuts" SectionStartMenu "$SMPROGRAMS\$StartMenuFolder\${LAUNCHER_SHORTCUT_NAME}.lnk" \ "$PythonExecPrefix\pythonw.exe" "-m Orange.canvas" \ "$PythonPrefix\share\orange3\icons\orange.ico" 0 + + # A utility shortcut for activating the environment + CreateShortCut \ + "$SMPROGRAMS\$StartMenuFolder\${APPNAME} Command Prompt.lnk" \ + "%COMSPEC%" '/S /K ""$PythonScriptsPrefix\activate.bat" "$InstDir""' ${EndIf} !insertmacro MUI_STARTMENU_WRITE_END SectionEnd @@ -604,6 +613,7 @@ Function un.Shortcuts ${LogWrite} "Removing Start Menu Shortcuts (from $SMPROGRAMS\$0)" DetailPrint "Removing Start Menu shortcuts" Delete "$SMPROGRAMS\$0\${LAUNCHER_SHORTCUT_NAME}.lnk" + Delete "$SMPROGRAMS\$0\${APPNAME} Command Prompt.lnk" RMDir "$SMPROGRAMS\$0" ${EndIf} ${LogWrite} "Removing Desktop shortcurt" @@ -743,8 +753,8 @@ Section Uninstall ${LogWrite} " PythonPrefix: $PythonPrefix" ${LogWrite} " BasePythonPrefix: $BasePythonPrefix" - Call un.Register Call un.Shortcuts + Call un.Register Call un.Launchers Call un.InstallPackages Call un.Environment diff --git a/scripts/windows/orange-install.nsi b/scripts/windows/orange-install.nsi index 0e411b10ca2..586c8e5c34d 100644 --- a/scripts/windows/orange-install.nsi +++ b/scripts/windows/orange-install.nsi @@ -189,6 +189,10 @@ Var StartMenuFolder # - no check box to enable/disable start menu creation # (is controled by the Components Page) !define MUI_STARTMENUPAGE_NODISABLE +# Registry key path where the selected start folder name is stored +!define MUI_STARTMENUPAGE_REGISTRY_ROOT SHELL_CONTEXT +!define MUI_STARTMENUPAGE_REGISTRY_KEY ${INSTALL_SETTINGS_KEY} +!define MUI_STARTMENUPAGE_REGISTRY_VALUENAME StartMenuFolder !insertmacro MUI_PAGE_STARTMENU StartMenuPageID $StartMenuFolder # Install Files page: @@ -446,7 +450,7 @@ Section "Python ${PYTHON_VERSION} (${BITS} bit)" SectionPython Abort "Python installation failed (error value: $0)" ${EndIf} ${GetPythonInstall} \ - "${PYMAJOR}.${PYMINOR}" $BasePythonPrefix $PythonInstallMode + "${PYMAJOR}.${PYMINOR}" ${BITS} $BasePythonPrefix $PythonInstallMode ${If} $BasePythonPrefix == "" Abort "Python installation failed (cannot determine Python \ installation prefix)." @@ -639,6 +643,9 @@ Function un.Shortcuts ${LogWrite} "Removing Start Menu Shortcuts (from $SMPROGRAMS\$0)" DetailPrint "Removing Start Menu shortcuts" Delete "$SMPROGRAMS\$0\${LAUNCHER_SHORTCUT_NAME}.lnk" +!if ${PYINSTALL_TYPE} == Normal + Delete "$SMPROGRAMS\$0\${APPNAME} Command Prompt.lnk" +!endif RMDir "$SMPROGRAMS\$0" ${EndIf} ${LogWrite} "Removing Desktop shortcurt" @@ -780,8 +787,8 @@ Section Uninstall ${LogWrite} " PythonPrefix: $PythonPrefix" ${LogWrite} " BasePythonPrefix: $BasePythonPrefix" - Call un.Register Call un.Shortcuts + Call un.Register Call un.Launchers Call un.InstallPackages Call un.Environment @@ -811,7 +818,8 @@ Function .onInit !insertmacro MULTIUSER_INIT !if ${PYINSTALL_TYPE} == Normal - ${GetPythonInstall} ${PYMAJOR}.${PYMINOR} $BasePythonPrefix $PythonInstallMode + ${GetPythonInstall} ${PYMAJOR}.${PYMINOR} ${BITS} \ + $BasePythonPrefix $PythonInstallMode ${LogWrite} "Python Prefix: $BasePythonPrefix" ${LogWrite} "Python Install Type: $PythonInstallMode" ${If} $BasePythonPrefix != ""