From 513520b90e1e5f5612dca8edfb310b5339505cf2 Mon Sep 17 00:00:00 2001 From: Ales Erjavec Date: Thu, 26 Sep 2024 23:27:35 +0200 Subject: [PATCH] build-win-installer: Add activate.bat script --- scripts/windows/activate.bat | 11 +++++++++++ scripts/windows/build-win-installer.sh | 1 + scripts/windows/orange-install.nsi | 19 ++++++++----------- 3 files changed, 20 insertions(+), 11 deletions(-) create mode 100644 scripts/windows/activate.bat diff --git a/scripts/windows/activate.bat b/scripts/windows/activate.bat new file mode 100644 index 0000000..74fce62 --- /dev/null +++ b/scripts/windows/activate.bat @@ -0,0 +1,11 @@ +@echo off +:: get full directory path where this file is located +for /F "delims=" %%i in ( "%~dp0" ) do ( set "ENV_PATH=%%~fi" ) +:: strip trailing \ +if "%ENV_PATH:~-1%" == "\" set "ENV_PATH=%ENV_PATH:~0,-1%" +:: get directory name +for /F "delims=" %%i in ( "%ENV_PATH%" ) do ( set "ENV=%%~nxi" ) + +if not defined PROMPT set PROMPT=$P$G +set "PROMPT=(%ENV%) %PROMPT%" +set "PATH=%ENV_PATH%;%ENV_PATH%\Scripts;%PATH%" diff --git a/scripts/windows/build-win-installer.sh b/scripts/windows/build-win-installer.sh index f39b494..66a763f 100755 --- a/scripts/windows/build-win-installer.sh +++ b/scripts/windows/build-win-installer.sh @@ -369,6 +369,7 @@ fetch-python-nupkg ${PYTHON_VERSION} "${CACHEDIR:?}"/python-${PYTHON_VERSION} 7z x '-i!tools' -y -o"${BUILDBASE}/python" "${CACHEDIR:?}"/python-${PYTHON_VERSION} mv "${BUILDBASE}/python/tools" "${BASEDIR}/Python" rm -r "${BUILDBASE}/python" +cp "${DIRNAME}/activate.bat" "${BASEDIR}/Python" fetch-requirements "${PIP_ARGS[@]}" package-requirements "${PIP_ARGS[@]}" diff --git a/scripts/windows/orange-install.nsi b/scripts/windows/orange-install.nsi index 4ea08bd..3e28b62 100644 --- a/scripts/windows/orange-install.nsi +++ b/scripts/windows/orange-install.nsi @@ -576,6 +576,11 @@ Section -Icons ${EndIf} SectionEnd +!if ${PYINSTALL_TYPE} == Normal + !define ACTIVATE_PATH "$PythonScriptsPrefix\activate.bat" +!else + !define ACTIVATE_PATH "$PythonPrefix\activate.bat" +!endif # Create utility shortcut launchers in the $InstDir Section -Launchers @@ -592,22 +597,18 @@ Section -Launchers "$InstDir\${LAUNCHER_SHORTCUT_NAME} Debug.lnk" \ "%COMSPEC%" '/K "$PythonExecPrefix\python.exe" -Psm ${LAUNCHERMODULE} -l4' \ "$PythonPrefix\share\${ICONDIR}\${APPICON}" 0 -!if ${PYINSTALL_TYPE} == Normal + # A utility shortcut for activating the environment CreateShortCut \ "$InstDir\${APPNAME} Command Prompt.lnk" \ - "%COMSPEC%" '/K "$PythonScriptsPrefix\activate.bat"' -!endif - + "%COMSPEC%" '/K "${ACTIVATE_PATH}"' SectionEnd Function un.Launchers Delete "$InstDir\${LAUNCHER_SHORTCUT_NAME}.lnk" Delete "$InstDir\${LAUNCHER_SHORTCUT_NAME} Debug.lnk" -!if ${PYINSTALL_TYPE} == Normal Delete "$InstDir\${APPNAME} Command Prompt.lnk" -!endif FunctionEnd @@ -626,12 +627,10 @@ Section "Start Menu Shortcuts" SectionStartMenu "$SMPROGRAMS\$StartMenuFolder\${LAUNCHER_SHORTCUT_NAME}.lnk" \ "$PythonExecPrefix\pythonw.exe" "-Psm ${LAUNCHERMODULE}" \ "$PythonPrefix\share\${ICONDIR}\${APPICON}" 0 -!if ${PYINSTALL_TYPE} == Normal # A utility shortcut for activating the environment CreateShortCut \ "$SMPROGRAMS\$StartMenuFolder\${APPNAME} Command Prompt.lnk" \ - "%COMSPEC%" '/K "$PythonScriptsPrefix\activate.bat"' -!endif + "%COMSPEC%" '/K "${ACTIVATE_PATH}"' ${EndIf} !insertmacro MUI_STARTMENU_WRITE_END SectionEnd @@ -663,9 +662,7 @@ 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"