@@ -32,9 +32,16 @@ $env:PYTHONIOENCODING = "utf-8"
3232
3333$env: HOME = " $env: WINPYDIRBASE \settings"
3434
35- $env: WINPYDIRBASE = " "
3635$env: JUPYTER_DATA_DIR = " $env: HOME "
3736
37+ # keep Variables alive !
38+ Set-Variable - Name " WINPYDIRBASE" - Value $env: WINPYDIRBASE - Scope Global
39+ Set-Variable - Name " WINPYDIR" - Value $env: WINPYDIR - Scope Global
40+ Set-Variable - Name " PYTHON" - Value $env: PYTHON - Scope Global
41+ Set-Variable - Name " PYTHONIOENCODING" - Value $env: PYTHONIOENCODING - Scope Global
42+ # Set-Variable -Name "HOME" -Value $env:HOME -Scope Global
43+ Set-Variable - Name " JUPYTER_DATA_DIR" - Value $env: JUPYTER_DATA_DIR - Scope Global
44+
3845if (-not $env: PATH.ToLower ().Contains(" ;" + $env: WINPYDIR.ToLower ()+ " ;" )) {
3946 $env: PATH = " $env: WINPYDIR \\Lib\site-packages\PyQt5;$env: WINPYDIR \\;$env: WINPYDIR \\DLLs;$env: WINPYDIR \\Scripts;$env: WINPYDIR \\..\t;$env: WINPYDIR \\..\n;$env: path " }
4047
@@ -44,7 +51,50 @@ if (Test-Path "$env:WINPYDIR\Lib\site-packages\PyQt5\__init__.py") { $env:QT_API
4451
4552# PyQt5 qt.conf creation and winpython.ini creation done via Winpythonini.py (called per env_for_icons.bat for now)
4653# Start-Process -FilePath $env:PYTHON -ArgumentList ($env:WINPYDIRBASE + '\scripts\WinPythonIni.py')
54+ $output = & ' python.exe' ($env: WINPYDIRBASE + ' \scripts\WinPythonIni.py' )
55+ $pairs = $output -split ' &&'
56+ $pair = $pair -replace ' ^(?i)set\s+' , ' '
57+ foreach ($pair in $pairs ) {
58+ $pair = $pair.Trim ()
59+ if ($pair -eq ' ' ) { continue }
60+
61+ # Remove leading "set " (case-insensitive)
62+ $pair = $pair -replace ' ^(?i)set\s+' , ' '
63+
64+ # Find first '=' so values can contain '='
65+ $idx = $pair.IndexOf (' =' )
66+ if ($idx -lt 0 ) {
67+ Write-Warning " Skipping invalid pair (no '='): '$pair '"
68+ continue
69+ }
4770
71+ $name = $pair.Substring (0 , $idx ).Trim()
72+ $value = $pair.Substring ($idx + 1 ).Trim()
73+
74+ # Unquote a quoted value (single or double quotes)
75+ if ($value -match ' ^(["'' ])(.*)\1$' ) { $value = $Matches [2 ] }
76+
77+ # Basic validation for variable name (optional)
78+ if ($name -notmatch ' ^[a-zA-Z_][a-zA-Z0-9_]*$' ) {
79+ Write-Warning " Variable name '$name ' is unusual. Still setting it, but consider sanitizing."
80+ }
81+
82+ # Set as a PowerShell global variable
83+ Set-Variable - Name $name - Value $value - Scope Global - Force
84+
85+ # Also set as environment variable for child processes
86+ $env: name = $value
87+
88+ # If running in GH Actions, also append to GITHUB_ENV so future steps see it
89+ if ($env: GITHUB_ENV ) {
90+ # Use Add-Content to append "NAME=value" to the GITHUB_ENV file
91+ # Escape any newlines in $value to avoid breaking the file format
92+ $escapedValue = $value -replace " `n " , ' %0A' -replace " `r " , ' '
93+ Add-Content - Path $env: GITHUB_ENV - Value " $name =$escapedValue "
94+ }
95+
96+ # Write-Host "Set `$${name} = $value"
97+ }
4898
4999# ## Set-WindowSize
50100
0 commit comments