Skip to content

powershell console step2 #339

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
May 29, 2016
Merged
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
72 changes: 46 additions & 26 deletions make.py
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,9 @@ def _create_launchers(self):
self.create_launcher('WinPython Command Prompt.exe', 'cmd.ico',
command='$SYSDIR\cmd.exe',
args=r'/k cmd.bat')
self.create_launcher('WinPython Powershell Prompt.exe', 'powershell.ico',
command='$SYSDIR\cmd.exe',
args=r'/k cmd_ps.bat')

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

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

self.create_batch_script('env.bat', r"""@echo off
Expand Down Expand Up @@ -605,43 +608,31 @@ def _create_batch_scripts_initial(self):
###############################
### WinPython_PS_Prompt.ps1 ###
###############################
$0 = $myInvocation.MyCommand.Definition
$dp0 = [System.IO.Path]::GetDirectoryName($0)

# avoid double_init (will only resize screen)
if (-not $env:WINPYDIR -eq "$dp0\..\python-3.4.4.amd64") {

# $env:WINPYDIR = '$pwd\..\python-3.4.4.amd64'
$env:WINPYDIR = "$dp0\..\python-3.4.4.amd64"

$env:WINPYDIR = '$pwd\.."""+'\\' + self.python_name + r"""'
$env:WINPYDIR = "$dp0\.."""+'\\' + self.python_name + '"' + r"""
$env:WINPYVER = '""" + self.winpyver + r"""'
$env:HOME = '$env:WINPYDIR\..\settings'
$env:JUPYTER_DATA_DIR = '$env:HOME'
$env:HOME = "$env:WINPYDIR\..\settings"
$env:JUPYTER_DATA_DIR = "$env:HOME"
$env:WINPYARCH = 'WIN32'
if ($env:WINPYARCH.subString($env:WINPYARCH.length-5, 5) -eq 'amd64') {
$env:WINPYARCH = 'WIN-AMD64' }


if (-not $env:PATH.ToLower().Contains(";"+ $env:WINPYDIR.ToLower()+ ";")) {
$env:PATH = '""" + pathps + r"""' }
$env:PATH = """ + '"' + pathps + '"' + r""" }

#rem force default pyqt5 kit for Spyder if PyQt5 module is there
if (Test-Path "$env:WINPYDIR\Lib\site-packages\PyQt5") { $env:QT_API = "pyqt5" }


###############################
### Set-WindowSize
###############################
Function Set-WindowSize {
Param([int]$x=$host.ui.rawui.windowsize.width,
[int]$y=$host.ui.rawui.windowsize.heigth,
[int]$buffer=$host.UI.RawUI.BufferSize.heigth)

$buffersize = new-object System.Management.Automation.Host.Size($x,$buffer)
$host.UI.RawUI.BufferSize = $buffersize
$size = New-Object System.Management.Automation.Host.Size($x,$y)
$host.ui.rawui.WindowSize = $size
}

Set-WindowSize 150 40 6000

### Colorize to distinguish
$host.ui.RawUI.BackgroundColor = "DarkBlue"
$host.ui.RawUI.ForegroundColor = "White"


#####################
### handle R if included
Expand Down Expand Up @@ -678,10 +669,39 @@ def _create_batch_scripts_initial(self):
"#JUPYTER_DATA_DIR = %%HOME%%" | Add-Content -Path $env:winpython_ini
"#WINPYWORKDIR = %%HOMEDRIVE%%%%HOMEPATH%%\Documents\WinPython%%WINPYVER%%\Notebooks" | Add-Content -Path $env:winpython_ini
}


}
###############################
### Set-WindowSize
###############################
Function Set-WindowSize {
Param([int]$x=$host.ui.rawui.windowsize.width,
[int]$y=$host.ui.rawui.windowsize.heigth,
[int]$buffer=$host.UI.RawUI.BufferSize.heigth)

$buffersize = new-object System.Management.Automation.Host.Size($x,$buffer)
$host.UI.RawUI.BufferSize = $buffersize
$size = New-Object System.Management.Automation.Host.Size($x,$y)
$host.ui.rawui.WindowSize = $size
}

Set-WindowSize 150 40 6000

### Colorize to distinguish
$host.ui.RawUI.BackgroundColor = "DarkBlue"
$host.ui.RawUI.ForegroundColor = "White"

""")

self.create_batch_script('cmd_ps.bat', r"""@echo off
rem safe bet
call "%~dp0env_for_icons.bat"
Powershell.exe -executionpolicy RemoteSigned -noexit -file "%~dp0WinPython_PS_Prompt.ps1"
""")

self.create_batch_script('WinPython_Interpreter_PS.bat', r"""@echo off
rem call "%~dp0env_for_icons.bat"
rem no safe bet (for comparisons)
Powershell.exe -executionpolicy RemoteSigned -noexit -file "%~dp0WinPython_PS_Prompt.ps1"
""")

Expand Down