Skip to content

Commit

Permalink
build-win-installer: Add activate.bat script
Browse files Browse the repository at this point in the history
  • Loading branch information
ales-erjavec committed Sep 27, 2024
1 parent 56896e5 commit 513520b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 11 deletions.
11 changes: 11 additions & 0 deletions scripts/windows/activate.bat
Original file line number Diff line number Diff line change
@@ -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%"
1 change: 1 addition & 0 deletions scripts/windows/build-win-installer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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[@]}"
Expand Down
19 changes: 8 additions & 11 deletions scripts/windows/orange-install.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 513520b

Please sign in to comment.