Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 2 additions & 48 deletions make.py
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ def _copy_documentation(self):
self._print_action_done()


def _create_launchers(self):
def _copy_launchers(self):
"""Copies pre-made launchers to the WinPython directory."""
self._print_action("Creating launchers")
launchers_source_dir = PORTABLE_DIR / "launchers_final"
Expand Down Expand Up @@ -636,52 +636,6 @@ def _create_initial_batch_scripts(self):
"""
self.create_batch_script("WinPython_PS_Prompt.ps1", ps1_content, replacements=batch_replacements)


env_for_icons_bat_content = r"""@echo off
call "%~dp0env.bat"

rem default is as before: Winpython ..\Notebooks
set WINPYWORKDIR=%WINPYDIRBASE%\Notebooks
set WINPYWORKDIR1=%WINPYWORKDIR%

rem if we have a file or directory in %1 parameter, we use that directory to define WINPYWORKDIR1
if not "%~1"=="" (
if exist "%~1" (
if exist "%~1\" (
rem echo it is a directory %~1
set WINPYWORKDIR1=%~1
) else (
rem echo it is a file %~1, so we take the directory %~dp1
set WINPYWORKDIR1=%~dp1
)
)
) else (
rem if it is launched from another directory than icon origin , we keep it that one echo %__CD__%
if not "%__CD__%"=="%~dp0" if not "%__CD__%scripts\"=="%~dp0" set WINPYWORKDIR1="%__CD__%"
)
rem remove potential doublequote
set WINPYWORKDIR1=%WINPYWORKDIR1:"=%
rem remove some potential last \
if "%WINPYWORKDIR1:~-1%"=="\" set WINPYWORKDIR1=%WINPYWORKDIR1:~0,-1%

rem you can use winpython.ini to change defaults
FOR /F "delims=" %%i IN ('""%WINPYDIR%\python.exe" "%~dp0WinpythonIni.py""') DO set winpythontoexec=%%i
%winpythontoexec%set winpythontoexec=


rem Preventive Working Directories creation if needed
if not "%WINPYWORKDIR%"=="" if not exist "%WINPYWORKDIR%" mkdir "%WINPYWORKDIR%"
if not "%WINPYWORKDIR1%"=="" if not exist "%WINPYWORKDIR1%" mkdir "%WINPYWORKDIR1%"

rem Change of directory only if we are in a launcher directory
if "%__CD__%scripts\"=="%~dp0" cd/D %WINPYWORKDIR1%
if "%__CD__%"=="%~dp0" cd/D %WINPYWORKDIR1%

if not exist "%HOME%\.spyder-py%WINPYVER:~0,1%" mkdir "%HOME%\.spyder-py%WINPYVER:~0,1%"
if not exist "%HOME%\.spyder-py%WINPYVER:~0,1%\workingdir" echo %HOME%\Notebooks>"%HOME%\.spyder-py%WINPYVER:~0,1%\workingdir"
"""
self.create_batch_script("env_for_icons.bat", env_for_icons_bat_content, replacements=batch_replacements)

self._print_action_done()


Expand Down Expand Up @@ -756,7 +710,7 @@ def build(self, remove_existing: bool = True, requirements=None, winpy_dirname:
self._create_initial_batch_scripts()
self._copy_default_scripts()
self._create_standard_batch_scripts()
self._create_launchers()
self._copy_launchers()

utils.python_execmodule("ensurepip", self.distribution.target) # Ensure pip is installed for PyPy
self.distribution.patch_standard_packages("pip")
Expand Down
42 changes: 42 additions & 0 deletions portable/scripts/env_for_icons.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
@echo off
call "%~dp0env.bat"

rem default is as before: Winpython ..\Notebooks
set WINPYWORKDIR=%WINPYDIRBASE%\Notebooks
set WINPYWORKDIR1=%WINPYWORKDIR%

rem if we have a file or directory in %1 parameter, we use that directory to define WINPYWORKDIR1
if not "%~1"=="" (
if exist "%~1" (
if exist "%~1\" (
rem echo it is a directory %~1
set WINPYWORKDIR1=%~1
) else (
rem echo it is a file %~1, so we take the directory %~dp1
set WINPYWORKDIR1=%~dp1
)
)
) else (
rem if it is launched from another directory than icon origin , we keep it that one echo %__CD__%
if not "%__CD__%"=="%~dp0" if not "%__CD__%scripts\"=="%~dp0" set WINPYWORKDIR1="%__CD__%"
)
rem remove potential doublequote
set WINPYWORKDIR1=%WINPYWORKDIR1:"=%
rem remove some potential last \
if "%WINPYWORKDIR1:~-1%"=="\" set WINPYWORKDIR1=%WINPYWORKDIR1:~0,-1%

rem you can use winpython.ini to change defaults
FOR /F "delims=" %%i IN ('""%WINPYDIR%\python.exe" "%~dp0WinpythonIni.py""') DO set winpythontoexec=%%i
%winpythontoexec%set winpythontoexec=


rem Preventive Working Directories creation if needed
if not "%WINPYWORKDIR%"=="" if not exist "%WINPYWORKDIR%" mkdir "%WINPYWORKDIR%"
if not "%WINPYWORKDIR1%"=="" if not exist "%WINPYWORKDIR1%" mkdir "%WINPYWORKDIR1%"

rem Change of directory only if we are in a launcher directory
if "%__CD__%scripts\"=="%~dp0" cd/D %WINPYWORKDIR1%
if "%__CD__%"=="%~dp0" cd/D %WINPYWORKDIR1%

if not exist "%HOME%\.spyder-py%WINPYVER:~0,1%" mkdir "%HOME%\.spyder-py%WINPYVER:~0,1%"
if not exist "%HOME%\.spyder-py%WINPYVER:~0,1%\workingdir" echo %HOME%\Notebooks>"%HOME%\.spyder-py%WINPYVER:~0,1%\workingdir"