Skip to content

powershell console step1 #338

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 2 commits into from
May 29, 2016
Merged
Show file tree
Hide file tree
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
89 changes: 89 additions & 0 deletions make.py
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,10 @@ def _create_batch_scripts_initial(self):
self._print("Creating batch scripts initial")
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])
pathps = convps(self.prepath) + ";$env:path;" + convps(self.postpath)

self.create_batch_script('env.bat', r"""@echo off
set WINPYDIR=%~dp0.."""+"\\" + self.python_name + r"""
set WINPYVER=""" + self.winpyver + r"""
Expand Down Expand Up @@ -595,6 +599,90 @@ def _create_batch_scripts_initial(self):
echo #JUPYTER_DATA_DIR = %%HOME%%>>"%winpython_ini%"
echo #WINPYWORKDIR = %%HOMEDRIVE%%%%HOMEPATH%%\Documents\WinPython%%WINPYVER%%\Notebooks>>"%winpython_ini%"
)
""")

self.create_batch_script('WinPython_PS_Prompt.ps1', r"""
###############################
### WinPython_PS_Prompt.ps1 ###
###############################


$env:WINPYDIR = '$pwd\.."""+'\\' + self.python_name + r"""'
$env:WINPYVER = '""" + self.winpyver + r"""'
$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"""' }

#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
#####################
if (Test-Path "$env:WINPYDIR\..\tools\R\bin") {
$env:R_HOME = "$env:WINPYDIR\..\tools\R"
$env:R_HOMEbin = "$env:R_HOME\bin\x64"
if ("$env:WINPYARCH" -eq "WIN32") {
$env:R_HOMEbin = "$env:R_HOME\bin\i386"
}
}

#####################
### handle Julia if included
#####################
if (Test-Path "$env:WINPYDIR\..\tools\Julia\bin") {
$env:JULIA_HOME = "$env:WINPYDIR\..\tools\Julia\bin\"
$env:JULIA_EXE = "julia.exe"
$env:JULIA = "$env:JULIA_HOME$env:JULIA_EXE"
$env:JULIA_PKGDIR = "$env:WINPYDIR\..\settings\.julia"
}

#####################
### WinPython.ini part (removed from nsis)
#####################
if (-not (Test-Path "$env:WINPYDIR\..\settings")) { md -Path "$env:WINPYDIR\..\settings" }
$env:winpython_ini = "$env:WINPYDIR\..\settings\winpython.ini"
if (-not (Test-Path $env:winpython_ini)) {
"[debug]" | Add-Content -Path $env:winpython_ini
"state = disabled" | Add-Content -Path $env:winpython_ini
"[environment]" | Add-Content -Path $env:winpython_ini
"## <?> Uncomment lines to override environment variables" | Add-Content -Path $env:winpython_ini
"#HOME = %%HOMEDRIVE%%%%HOMEPATH%%\Documents\WinPython%%WINPYVER%%" | Add-Content -Path $env:winpython_ini
"#JUPYTER_DATA_DIR = %%HOME%%" | Add-Content -Path $env:winpython_ini
"#WINPYWORKDIR = %%HOMEDRIVE%%%%HOMEPATH%%\Documents\WinPython%%WINPYVER%%\Notebooks" | Add-Content -Path $env:winpython_ini
}
""")

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

self.create_batch_script('env_for_icons.bat', r"""@echo off
Expand Down Expand Up @@ -766,6 +854,7 @@ def _create_batch_scripts(self):
self.create_batch_script('cmd.bat', r"""@echo off
call "%~dp0env_for_icons.bat"
cmd.exe /k""")

self.create_batch_script('python.bat',r"""@echo off
call "%~dp0env_for_icons.bat"
cd/D "%WINPYWORKDIR%"
Expand Down
Binary file added portable/icons/powershell.ico
Binary file not shown.
12 changes: 12 additions & 0 deletions winpython/data/packages.ini
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ description=Cross-platform colored terminal text
[comtypes]
description=Pure Python COM package

[commonmark]
description=Python parser for the CommonMark Markdown spec

[configparser]
description=This library brings the updated configparser from Python 3.5 to Python 2.6-3.5.

Expand Down Expand Up @@ -362,6 +365,9 @@ description=A fast and thorough lazy object proxy.
[libpython]
description=The MinGW import library for Python

[lightfm]
description=A Python implementation of LightFM, a hybrid recommendation algorithm.

[lightning-python]
description=A Python client library for the Lightning data visualization server

Expand Down Expand Up @@ -466,6 +472,9 @@ description=A system for assigning and grading notebooks.
[nbpresent]
description=Next generation slides from Jupyter Notebooks

[nbsphinx]
description=Jupyter Notebook Tools for Sphinx

[netcdf4]
description=python/numpy interface to netCDF library (versions 3 and 4)

Expand Down Expand Up @@ -808,6 +817,9 @@ description=Provides an abstraction layer on top of the various Qt bindings (PyQ
[queuelib]
description=Collection of persistent (disk-based) queues

[recommonmark]
description=A markdown parser for docutils

[redis]
description=Python client for Redis key-value store

Expand Down