Skip to content

Commit dedfcb2

Browse files
authored
Merge pull request winpython#1499 from stonebig/master
move "env_for_icons.bat" out of make.py
2 parents dbcd1f7 + 48cc0c4 commit dedfcb2

File tree

2 files changed

+44
-48
lines changed

2 files changed

+44
-48
lines changed

make.py

Lines changed: 2 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ def _copy_documentation(self):
489489
self._print_action_done()
490490

491491

492-
def _create_launchers(self):
492+
def _copy_launchers(self):
493493
"""Copies pre-made launchers to the WinPython directory."""
494494
self._print_action("Creating launchers")
495495
launchers_source_dir = PORTABLE_DIR / "launchers_final"
@@ -636,52 +636,6 @@ def _create_initial_batch_scripts(self):
636636
"""
637637
self.create_batch_script("WinPython_PS_Prompt.ps1", ps1_content, replacements=batch_replacements)
638638

639-
640-
env_for_icons_bat_content = r"""@echo off
641-
call "%~dp0env.bat"
642-
643-
rem default is as before: Winpython ..\Notebooks
644-
set WINPYWORKDIR=%WINPYDIRBASE%\Notebooks
645-
set WINPYWORKDIR1=%WINPYWORKDIR%
646-
647-
rem if we have a file or directory in %1 parameter, we use that directory to define WINPYWORKDIR1
648-
if not "%~1"=="" (
649-
if exist "%~1" (
650-
if exist "%~1\" (
651-
rem echo it is a directory %~1
652-
set WINPYWORKDIR1=%~1
653-
) else (
654-
rem echo it is a file %~1, so we take the directory %~dp1
655-
set WINPYWORKDIR1=%~dp1
656-
)
657-
)
658-
) else (
659-
rem if it is launched from another directory than icon origin , we keep it that one echo %__CD__%
660-
if not "%__CD__%"=="%~dp0" if not "%__CD__%scripts\"=="%~dp0" set WINPYWORKDIR1="%__CD__%"
661-
)
662-
rem remove potential doublequote
663-
set WINPYWORKDIR1=%WINPYWORKDIR1:"=%
664-
rem remove some potential last \
665-
if "%WINPYWORKDIR1:~-1%"=="\" set WINPYWORKDIR1=%WINPYWORKDIR1:~0,-1%
666-
667-
rem you can use winpython.ini to change defaults
668-
FOR /F "delims=" %%i IN ('""%WINPYDIR%\python.exe" "%~dp0WinpythonIni.py""') DO set winpythontoexec=%%i
669-
%winpythontoexec%set winpythontoexec=
670-
671-
672-
rem Preventive Working Directories creation if needed
673-
if not "%WINPYWORKDIR%"=="" if not exist "%WINPYWORKDIR%" mkdir "%WINPYWORKDIR%"
674-
if not "%WINPYWORKDIR1%"=="" if not exist "%WINPYWORKDIR1%" mkdir "%WINPYWORKDIR1%"
675-
676-
rem Change of directory only if we are in a launcher directory
677-
if "%__CD__%scripts\"=="%~dp0" cd/D %WINPYWORKDIR1%
678-
if "%__CD__%"=="%~dp0" cd/D %WINPYWORKDIR1%
679-
680-
if not exist "%HOME%\.spyder-py%WINPYVER:~0,1%" mkdir "%HOME%\.spyder-py%WINPYVER:~0,1%"
681-
if not exist "%HOME%\.spyder-py%WINPYVER:~0,1%\workingdir" echo %HOME%\Notebooks>"%HOME%\.spyder-py%WINPYVER:~0,1%\workingdir"
682-
"""
683-
self.create_batch_script("env_for_icons.bat", env_for_icons_bat_content, replacements=batch_replacements)
684-
685639
self._print_action_done()
686640

687641

@@ -756,7 +710,7 @@ def build(self, remove_existing: bool = True, requirements=None, winpy_dirname:
756710
self._create_initial_batch_scripts()
757711
self._copy_default_scripts()
758712
self._create_standard_batch_scripts()
759-
self._create_launchers()
713+
self._copy_launchers()
760714

761715
utils.python_execmodule("ensurepip", self.distribution.target) # Ensure pip is installed for PyPy
762716
self.distribution.patch_standard_packages("pip")

portable/scripts/env_for_icons.bat

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
@echo off
2+
call "%~dp0env.bat"
3+
4+
rem default is as before: Winpython ..\Notebooks
5+
set WINPYWORKDIR=%WINPYDIRBASE%\Notebooks
6+
set WINPYWORKDIR1=%WINPYWORKDIR%
7+
8+
rem if we have a file or directory in %1 parameter, we use that directory to define WINPYWORKDIR1
9+
if not "%~1"=="" (
10+
if exist "%~1" (
11+
if exist "%~1\" (
12+
rem echo it is a directory %~1
13+
set WINPYWORKDIR1=%~1
14+
) else (
15+
rem echo it is a file %~1, so we take the directory %~dp1
16+
set WINPYWORKDIR1=%~dp1
17+
)
18+
)
19+
) else (
20+
rem if it is launched from another directory than icon origin , we keep it that one echo %__CD__%
21+
if not "%__CD__%"=="%~dp0" if not "%__CD__%scripts\"=="%~dp0" set WINPYWORKDIR1="%__CD__%"
22+
)
23+
rem remove potential doublequote
24+
set WINPYWORKDIR1=%WINPYWORKDIR1:"=%
25+
rem remove some potential last \
26+
if "%WINPYWORKDIR1:~-1%"=="\" set WINPYWORKDIR1=%WINPYWORKDIR1:~0,-1%
27+
28+
rem you can use winpython.ini to change defaults
29+
FOR /F "delims=" %%i IN ('""%WINPYDIR%\python.exe" "%~dp0WinpythonIni.py""') DO set winpythontoexec=%%i
30+
%winpythontoexec%set winpythontoexec=
31+
32+
33+
rem Preventive Working Directories creation if needed
34+
if not "%WINPYWORKDIR%"=="" if not exist "%WINPYWORKDIR%" mkdir "%WINPYWORKDIR%"
35+
if not "%WINPYWORKDIR1%"=="" if not exist "%WINPYWORKDIR1%" mkdir "%WINPYWORKDIR1%"
36+
37+
rem Change of directory only if we are in a launcher directory
38+
if "%__CD__%scripts\"=="%~dp0" cd/D %WINPYWORKDIR1%
39+
if "%__CD__%"=="%~dp0" cd/D %WINPYWORKDIR1%
40+
41+
if not exist "%HOME%\.spyder-py%WINPYVER:~0,1%" mkdir "%HOME%\.spyder-py%WINPYVER:~0,1%"
42+
if not exist "%HOME%\.spyder-py%WINPYVER:~0,1%\workingdir" echo %HOME%\Notebooks>"%HOME%\.spyder-py%WINPYVER:~0,1%\workingdir"

0 commit comments

Comments
 (0)