Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 42d5692

Browse files
committed
Merge pull request #339 from stonebig/master
powershell console step2
2 parents d8b3a0a + 3d1e372 commit 42d5692

File tree

1 file changed

+46
-26
lines changed

1 file changed

+46
-26
lines changed

make.py

Lines changed: 46 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,9 @@ def _create_launchers(self):
487487
self.create_launcher('WinPython Command Prompt.exe', 'cmd.ico',
488488
command='$SYSDIR\cmd.exe',
489489
args=r'/k cmd.bat')
490+
self.create_launcher('WinPython Powershell Prompt.exe', 'powershell.ico',
491+
command='$SYSDIR\cmd.exe',
492+
args=r'/k cmd_ps.bat')
490493

491494
self.create_launcher('WinPython Interpreter.exe', 'python.ico',
492495
command='$SYSDIR\cmd.exe',
@@ -547,7 +550,7 @@ def _create_batch_scripts_initial(self):
547550
conv = lambda path: ";".join(['%WINPYDIR%\\'+pth for pth in path])
548551
path = conv(self.prepath) + ";%PATH%;" + conv(self.postpath)
549552

550-
convps = lambda path: ";".join(['$env:WINPYDIR\\'+pth for pth in path])
553+
convps = lambda path: ";".join(["$env:WINPYDIR\\"+pth for pth in path])
551554
pathps = convps(self.prepath) + ";$env:path;" + convps(self.postpath)
552555

553556
self.create_batch_script('env.bat', r"""@echo off
@@ -605,43 +608,31 @@ def _create_batch_scripts_initial(self):
605608
###############################
606609
### WinPython_PS_Prompt.ps1 ###
607610
###############################
611+
$0 = $myInvocation.MyCommand.Definition
612+
$dp0 = [System.IO.Path]::GetDirectoryName($0)
613+
614+
# avoid double_init (will only resize screen)
615+
if (-not $env:WINPYDIR -eq "$dp0\..\python-3.4.4.amd64") {
608616
617+
# $env:WINPYDIR = '$pwd\..\python-3.4.4.amd64'
618+
$env:WINPYDIR = "$dp0\..\python-3.4.4.amd64"
609619
610-
$env:WINPYDIR = '$pwd\.."""+'\\' + self.python_name + r"""'
620+
$env:WINPYDIR = "$dp0\.."""+'\\' + self.python_name + '"' + r"""
611621
$env:WINPYVER = '""" + self.winpyver + r"""'
612-
$env:HOME = '$env:WINPYDIR\..\settings'
613-
$env:JUPYTER_DATA_DIR = '$env:HOME'
622+
$env:HOME = "$env:WINPYDIR\..\settings"
623+
$env:JUPYTER_DATA_DIR = "$env:HOME"
614624
$env:WINPYARCH = 'WIN32'
615625
if ($env:WINPYARCH.subString($env:WINPYARCH.length-5, 5) -eq 'amd64') {
616626
$env:WINPYARCH = 'WIN-AMD64' }
617627
628+
618629
if (-not $env:PATH.ToLower().Contains(";"+ $env:WINPYDIR.ToLower()+ ";")) {
619-
$env:PATH = '""" + pathps + r"""' }
630+
$env:PATH = """ + '"' + pathps + '"' + r""" }
620631
621632
#rem force default pyqt5 kit for Spyder if PyQt5 module is there
622633
if (Test-Path "$env:WINPYDIR\Lib\site-packages\PyQt5") { $env:QT_API = "pyqt5" }
623634
624635
625-
###############################
626-
### Set-WindowSize
627-
###############################
628-
Function Set-WindowSize {
629-
Param([int]$x=$host.ui.rawui.windowsize.width,
630-
[int]$y=$host.ui.rawui.windowsize.heigth,
631-
[int]$buffer=$host.UI.RawUI.BufferSize.heigth)
632-
633-
$buffersize = new-object System.Management.Automation.Host.Size($x,$buffer)
634-
$host.UI.RawUI.BufferSize = $buffersize
635-
$size = New-Object System.Management.Automation.Host.Size($x,$y)
636-
$host.ui.rawui.WindowSize = $size
637-
}
638-
639-
Set-WindowSize 150 40 6000
640-
641-
### Colorize to distinguish
642-
$host.ui.RawUI.BackgroundColor = "DarkBlue"
643-
$host.ui.RawUI.ForegroundColor = "White"
644-
645636
646637
#####################
647638
### handle R if included
@@ -678,10 +669,39 @@ def _create_batch_scripts_initial(self):
678669
"#JUPYTER_DATA_DIR = %%HOME%%" | Add-Content -Path $env:winpython_ini
679670
"#WINPYWORKDIR = %%HOMEDRIVE%%%%HOMEPATH%%\Documents\WinPython%%WINPYVER%%\Notebooks" | Add-Content -Path $env:winpython_ini
680671
}
672+
673+
674+
}
675+
###############################
676+
### Set-WindowSize
677+
###############################
678+
Function Set-WindowSize {
679+
Param([int]$x=$host.ui.rawui.windowsize.width,
680+
[int]$y=$host.ui.rawui.windowsize.heigth,
681+
[int]$buffer=$host.UI.RawUI.BufferSize.heigth)
682+
683+
$buffersize = new-object System.Management.Automation.Host.Size($x,$buffer)
684+
$host.UI.RawUI.BufferSize = $buffersize
685+
$size = New-Object System.Management.Automation.Host.Size($x,$y)
686+
$host.ui.rawui.WindowSize = $size
687+
}
688+
689+
Set-WindowSize 150 40 6000
690+
691+
### Colorize to distinguish
692+
$host.ui.RawUI.BackgroundColor = "DarkBlue"
693+
$host.ui.RawUI.ForegroundColor = "White"
694+
681695
""")
682696

697+
self.create_batch_script('cmd_ps.bat', r"""@echo off
698+
rem safe bet
699+
call "%~dp0env_for_icons.bat"
700+
Powershell.exe -executionpolicy RemoteSigned -noexit -file "%~dp0WinPython_PS_Prompt.ps1"
701+
""")
702+
683703
self.create_batch_script('WinPython_Interpreter_PS.bat', r"""@echo off
684-
rem call "%~dp0env_for_icons.bat"
704+
rem no safe bet (for comparisons)
685705
Powershell.exe -executionpolicy RemoteSigned -noexit -file "%~dp0WinPython_PS_Prompt.ps1"
686706
""")
687707

0 commit comments

Comments
 (0)