Skip to content

Commit d46a237

Browse files
committed
WinPython_PS_Prompt.ps1 not using env_for_icons.bat
closer to a DOS-less launcher
1 parent 99ff831 commit d46a237

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

winpython/portable/launchers_final/scripts/WinPython_PS_Prompt.ps1

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ $env:PYTHON = $env:WINPYDIRBASE+ "\python\python.exe"
1212
$env:PYTHONIOENCODING = "utf-8"
1313

1414
if (-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
1818
if (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+',''
2323
foreach ($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+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
@echo off
2-
call "%~dp0env_for_icons.bat"
2+
rem call "%~dp0env_for_icons.bat"
33
Powershell.exe -Command "& {Start-Process PowerShell.exe -ArgumentList '-ExecutionPolicy RemoteSigned -noexit -File ""%~dp0WinPython_PS_Prompt.ps1""'}"

0 commit comments

Comments
 (0)