@@ -12,12 +12,12 @@ $env:PYTHON = $env:WINPYDIRBASE+ "\python\python.exe"
1212$env: PYTHONIOENCODING = " utf-8"
1313
1414if (-not $env: PATH.ToLower ().Contains(" ;" + $env: WINPYDIR.ToLower ()+ " ;" )) {
15- $env: PATH = " $env: WINPYDIR \\ Lib\site-packages\PyQt5;$env: WINPYDIR \\ ;$env: WINPYDIR \\ DLLs;$env: WINPYDIR \\ Scripts;$env: WINPYDIR \\ ..\t;$env: WINPYDIR \ \..\n;$env: path " }
15+ $env: PATH = " $env: WINPYDIR \Lib\site-packages\PyQt5;$env: WINPYDIR \;$env: WINPYDIR \DLLs;$env: WINPYDIR \Scripts;$env: WINPYDIR \..\t;$env: WINPYDIR \..\n;$env: path " }
1616
1717# rem force default pyqt5 kit for Spyder if PyQt5 module is there
1818if (Test-Path " $env: WINPYDIR \Lib\site-packages\PyQt5\__init__.py" ) { $env: QT_API = " pyqt5" }
1919
20- $output = & ' python.exe ' ($env: WINPYDIRBASE + ' \scripts\WinPythonIni.py' )
20+ $output = & $ env: PYTHON ($env: WINPYDIRBASE + ' \scripts\WinPythonIni.py' )
2121$pairs = $output -split ' &&'
2222$pair = $pair -replace ' ^(?i)set\s+' , ' '
2323foreach ($pair in $pairs ) {
@@ -56,3 +56,22 @@ foreach ($pair in $pairs) {
5656
5757 # Write-Host "Set `$${name} = $value"
5858}
59+
60+ # directory of the running script (fallback to MyInvocation for older hosts)
61+ $scriptDir = if ($PSScriptRoot ) { $PSScriptRoot } else { Split-Path - Parent $MyInvocation.MyCommand.Definition }
62+
63+ # emulate %__CD% and build scripts\ path
64+ $envCD = Normalize- DirPath $env: __CD__
65+ $scriptsPath = if ($envCD ) { Join-Path $envCD ' scripts' } else { $null }
66+
67+ # target to change into (environment variable WINPYWORKDIR1)
68+ $target = $WINPYWORKDIR1
69+
70+ if ($target ) {
71+ if ($scriptsPath -and $scriptDir -and ($scriptsPath -eq $scriptDir )) {
72+ Set-Location - LiteralPath $target
73+ }
74+ elseif ($envCD -and $scriptDir -and ($envCD -eq $scriptDir )) {
75+ Set-Location - LiteralPath $target
76+ }
77+ }
0 commit comments