michael@0: # This Source Code Form is subject to the terms of the Mozilla Public michael@0: # License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: # file, You can obtain one at http://mozilla.org/MPL/2.0/. michael@0: michael@0: $Env:VIRTUAL_ENV = (gl); michael@0: $Env:CUDDLEFISH_ROOT = $Env:VIRTUAL_ENV; michael@0: michael@0: # http://stackoverflow.com/questions/5648931/powershell-test-if-registry-value-exists/5652674#5652674 michael@0: Function Test-RegistryValue { michael@0: param( michael@0: [Alias("PSPath")] michael@0: [Parameter(Position = 0, Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] michael@0: [String]$Path michael@0: , michael@0: [Parameter(Position = 1, Mandatory = $true)] michael@0: [String]$Name michael@0: , michael@0: [Switch]$PassThru michael@0: ) michael@0: michael@0: process { michael@0: if (Test-Path $Path) { michael@0: $Key = Get-Item -LiteralPath $Path michael@0: if ($Key.GetValue($Name, $null) -ne $null) { michael@0: if ($PassThru) { michael@0: Get-ItemProperty $Path $Name michael@0: } else { michael@0: $true michael@0: } michael@0: } else { michael@0: $false michael@0: } michael@0: } else { michael@0: $false michael@0: } michael@0: } michael@0: } michael@0: michael@0: $WINCURVERKEY = 'HKLM:SOFTWARE\Microsoft\Windows\CurrentVersion'; michael@0: $WIN64 = (Test-RegistryValue $WINCURVERKEY 'ProgramFilesDir (x86)'); michael@0: michael@0: if($WIN64) { michael@0: $PYTHONKEY='HKLM:SOFTWARE\Wow6432Node\Python\PythonCore'; michael@0: } michael@0: else { michael@0: $PYTHONKEY='HKLM:SOFTWARE\Python\PythonCore'; michael@0: } michael@0: michael@0: $Env:PYTHONVERSION = ''; michael@0: $Env:PYTHONINSTALL = ''; michael@0: michael@0: foreach ($version in @('2.6', '2.5', '2.4')) { michael@0: if (Test-RegistryValue "$PYTHONKEY\$version\InstallPath" '(default)') { michael@0: $Env:PYTHONVERSION = $version; michael@0: } michael@0: } michael@0: michael@0: if ($Env:PYTHONVERSION) { michael@0: $Env:PYTHONINSTALL = (Get-Item "$PYTHONKEY\$version\InstallPath)").'(default)'; michael@0: } michael@0: michael@0: if ($Env:PYTHONINSTALL) { michael@0: $Env:Path += ";$Env:PYTHONINSTALL"; michael@0: } michael@0: michael@0: if (Test-Path Env:_OLD_PYTHONPATH) { michael@0: $Env:PYTHONPATH = $Env:_OLD_PYTHONPATH; michael@0: } michael@0: else { michael@0: $Env:PYTHONPATH = ''; michael@0: } michael@0: michael@0: $Env:_OLD_PYTHONPATH=$Env:PYTHONPATH; michael@0: $Env:PYTHONPATH= "$Env:VIRTUAL_ENV\python-lib;$Env:PYTHONPATH"; michael@0: michael@0: if (Test-Path Function:_OLD_VIRTUAL_PROMPT) { michael@0: Set-Content Function:Prompt (Get-Content Function:_OLD_VIRTUAL_PROMPT); michael@0: } michael@0: else { michael@0: function global:_OLD_VIRTUAL_PROMPT {} michael@0: } michael@0: michael@0: Set-Content Function:_OLD_VIRTUAL_PROMPT (Get-Content Function:Prompt); michael@0: michael@0: function global:prompt { "($Env:VIRTUAL_ENV) $(_OLD_VIRTUAL_PROMPT)"; }; michael@0: michael@0: if (Test-Path Env:_OLD_VIRTUAL_PATH) { michael@0: $Env:PATH = $Env:_OLD_VIRTUAL_PATH; michael@0: } michael@0: else { michael@0: $Env:_OLD_VIRTUAL_PATH = $Env:PATH; michael@0: } michael@0: michael@0: $Env:Path="$Env:VIRTUAL_ENV\bin;$Env:Path" michael@0: michael@0: [System.Console]::WriteLine("Note: this PowerShell SDK activation script is experimental.") michael@0: michael@0: python -c "from jetpack_sdk_env import welcome; welcome()" michael@0: