8000 correct the default launcher case that was no more working · winpython/winpython@7691d69 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7691d69

Browse files
committed
correct the default launcher case that was no more working
1 parent c0a027c commit 7691d69

File tree

1 file changed

+22
-6
lines changed

1 file changed

+22
-6
lines changed

make.py

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1327,13 +1327,27 @@ def _create_batch_scripts_initial(self):
13271327
call "%~dp0env.bat"
13281328
set WINPYWORKDIR=%~dp0..\Notebooks
13291329
1330-
set WINPYWORKDIR1=%~dp1
1331-
if "%WINPYWORKDIR1:~-1%"=="\" set WINPYWORKDIR1=%WINPYWORKDIR1:~0,-1%
1332-
1333-
if "%WINPYWORKDIR1%"=="" (
1334-
if not "%CD%\"=="%~dp0" set WINPYWORKDIR1=%CD%
1330+
rem default is as before: Winpython ..\Notebooks
1331+
set WINPYWORKDIR1=%WINPYWORKDIR%
1332+
1333+
rem if we have a file or directory in %1 parameter, we use that directory
1334+
if not "%~1"=="" (
1335+
if exist "%~1" (
1336+
if exist "%~1\" (
1337+
rem echo it is a directory %~1
1338+
set WINPYWORKDIR1=%~1
1339+
) else (
1340+
rem echo it is a file %~1, so we take the directory %~dp1
1341+
set WINPYWORKDIR1=%~dp1
1342+
)
1343+
)
1344+
) else (
1345+
rem if it it launched from another directory , we keep it that one echo %CD%
1346+
if not "%CD%\"=="%~dp0" set WINPYWORKDIR1=%CD%
13351347
)
1336-
if "%WINPYWORKDIR1%"=="" set WINPYWORKDIR1=%WINPYWORKDIR%
1348+
1349+
rem remove some potential last \
1350+
if "%WINPYWORKDIR1:~-1%"=="\" set WINPYWORKDIR1=%WINPYWORKDIR1:~0,-1%
13371351
13381352
FOR /F "delims=" %%i IN ('cscript /nologo "%~dp0WinpythonIni.vbs"') DO set winpythontoexec=%%i
13391353
%winpythontoexec%set winpythontoexec=
@@ -1559,6 +1573,7 @@ def _create_batch_scripts(self):
15591573
'cmd.bat',
15601574
r"""@echo off
15611575
call "%~dp0env_for_icons.bat" %*
1576+
if not "%WINPYWORKDIR%"=="%WINPYWORKDIR1%" cd %WINPYWORKDIR1%
15621577
cmd.exe /k""",
15631578
)
15641579

@@ -1567,6 +1582,7 @@ def _create_batch_scripts(self):
15671582
r"""@echo off
15681583
call "%~dp0env_for_icons.bat" %*
15691584
rem backward compatibility for python command-line users
1585+
if not "%WINPYWORKDIR%"=="%WINPYWORKDIR1%" cd %WINPYWORKDIR1%
15701586
"%WINPYDIR%\python.exe" %*
15711587
""",
15721588
)

0 commit comments

Comments
 (0)
0