Skip to content

'setlocal enabledelayedexpansion' doesn't work #1717

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 13, 2025
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
12 changes: 6 additions & 6 deletions winpython/portable/launchers_final/scripts/WinPythonIni.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import subprocess
from pathlib import Path

winpython_inidefault=r'''
winpython_inidefault = r'''
[debug]
state = disabled
[env.bat]
Expand All @@ -24,6 +24,7 @@
JUPYTER_DATA_DIR = %HOME%
WINPYWORKDIR = %HOMEDRIVE%%HOMEPATH%\Documents\WinPython%WINPYVER%\Notebooks
[inactive_environment_common]
## <?> changing this segment to [inactive_environment_common] makes this segment of lines active
USERPROFILE = %HOME%
[environment]
## <?> Uncomment lines to override environment variables
Expand All @@ -37,7 +38,6 @@
#JULIA=%JULIA_HOME%%JULIA_EXE%
#JULIA_PKGDIR=%WINPYDIRBASE%\settings\.julia
#QT_PLUGIN_PATH=%WINPYDIR%\Lib\site-packages\pyqt5_tools\Qt\plugins

'''

def get_file(file_name):
Expand Down Expand Up @@ -152,7 +152,6 @@ def main():
file.write(qt_conf)

# setting both the variable if downard, and the associated list if upward
prefix, postfix ="" , "\n"
for l in my_lines:
if l.startswith("["):
segment = l[1:].split("]")[0]
Expand All @@ -161,10 +160,10 @@ def main():
if segment == "debug" and data[0].strip() == "state":
data[0] = "WINPYDEBUG"
if segment in ["env.bat", "environment", "debug", "active_environment_per_user", "active_environment_common"]:
txt += f"{prefix}{data[0].strip()}={translate(data[1].strip(), env)}{postfix}"
txt += f"{data[0].strip()}={translate(data[1].strip(), env)}"
env[data[0].strip()] = translate(data[1].strip(), env)
if segment == "debug" and data[0].strip() == "state":
txt += f"{prefix}WINPYDEBUG={data[1].strip()}{postfix}"
txt += f"WINPYDEBUG={data[1].strip()}"

# create potential directory need
for i in ('HOME', 'WINPYWORKDIR', 'WINPYWORKDIR1'):
Expand All @@ -179,7 +178,8 @@ def main():
file.write(f"{Path(env['HOME']) / "Notebooks"}")

# output to push change upward
print(txt)
for l in self.output_lines:
print(rf"set {l}" , end="&&")

# later_version:
# p = subprocess.Popen(["start", "cmd", "/k", "set"], shell = True)
Expand Down
11 changes: 2 additions & 9 deletions winpython/portable/launchers_final/scripts/env_for_icons.bat
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
@echo off
call "%~dp0env.bat"
setlocal enabledelayedexpansion
rem you can use winpython.ini to change defaults
for /f "tokens=1,* delims==" %%A in (
'cmd /c ""%~dp0..\python\python.exe" "%~dp0WinpythonIni.py" %*"'
) do (
set "key=%%A"
set "value=%%B"
set "!key!=!value!"
)
FOR /F "delims=" %%i IN ('""%WINPYDIR%\python.exe" "%~dp0WinpythonIni.py" %* "') DO set winpythontoexec=%%i
%winpythontoexec%set winpythontoexec=

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