addon-sdk/source/bin/activate.bat

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/addon-sdk/source/bin/activate.bat	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,134 @@
     1.4 +@echo off
     1.5 +rem This Source Code Form is subject to the terms of the Mozilla Public
     1.6 +rem License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 +rem file, You can obtain one at http://mozilla.org/MPL/2.0/.
     1.8 +
     1.9 +set VIRTUAL_ENV=%~dp0
    1.10 +set VIRTUAL_ENV=%VIRTUAL_ENV:~0,-5%
    1.11 +set CUDDLEFISH_ROOT=%VIRTUAL_ENV%
    1.12 +
    1.13 +SET PYTHONKEY=SOFTWARE\Python\PythonCore
    1.14 +
    1.15 +rem look for 32-bit windows and python, or 64-bit windows and python
    1.16 +
    1.17 +SET PYTHONVERSION=2.7
    1.18 +call:CheckPython PYTHONINSTALL %PYTHONKEY%\%PYTHONVERSION%\InstallPath
    1.19 +if "%PYTHONINSTALL%" NEQ "" goto FoundPython
    1.20 +
    1.21 +SET PYTHONVERSION=2.6
    1.22 +call:CheckPython PYTHONINSTALL %PYTHONKEY%\%PYTHONVERSION%\InstallPath
    1.23 +if "%PYTHONINSTALL%" NEQ "" goto FoundPython
    1.24 +
    1.25 +SET PYTHONVERSION=2.5
    1.26 +call:CheckPython PYTHONINSTALL %PYTHONKEY%\%PYTHONVERSION%\InstallPath
    1.27 +if "%PYTHONINSTALL%" NEQ "" goto FoundPython
    1.28 +
    1.29 +if not defined ProgramFiles(x86) goto win32
    1.30 +
    1.31 +rem look for 32-bit python on 64-bit windows
    1.32 +
    1.33 +SET PYTHONKEY=SOFTWARE\Wow6432Node\Python\PythonCore
    1.34 +
    1.35 +SET PYTHONVERSION=2.7
    1.36 +call:CheckPython PYTHONINSTALL %PYTHONKEY%\%PYTHONVERSION%\InstallPath
    1.37 +if "%PYTHONINSTALL%" NEQ "" goto FoundPython
    1.38 +
    1.39 +SET PYTHONVERSION=2.6
    1.40 +call:CheckPython PYTHONINSTALL %PYTHONKEY%\%PYTHONVERSION%\InstallPath
    1.41 +if "%PYTHONINSTALL%" NEQ "" goto FoundPython
    1.42 +
    1.43 +SET PYTHONVERSION=2.5
    1.44 +call:CheckPython PYTHONINSTALL %PYTHONKEY%\%PYTHONVERSION%\InstallPath
    1.45 +if "%PYTHONINSTALL%" NEQ "" goto FoundPython
    1.46 +
    1.47 +:win32
    1.48 +
    1.49 +SET PYTHONVERSION=
    1.50 +set PYTHONKEY=
    1.51 +echo Warning: Failed to find Python installation directory
    1.52 +goto :EOF
    1.53 +
    1.54 +:FoundPython
    1.55 +
    1.56 +if defined _OLD_PYTHONPATH (
    1.57 +    set PYTHONPATH=%_OLD_PYTHONPATH%
    1.58 +)
    1.59 +if not defined PYTHONPATH (
    1.60 +    set PYTHONPATH=;
    1.61 +)
    1.62 +set _OLD_PYTHONPATH=%PYTHONPATH%
    1.63 +set PYTHONPATH=%VIRTUAL_ENV%\python-lib;%PYTHONPATH%
    1.64 +
    1.65 +if not defined PROMPT (
    1.66 +    set PROMPT=$P$G
    1.67 +)
    1.68 +
    1.69 +if defined _OLD_VIRTUAL_PROMPT (
    1.70 +    set PROMPT=%_OLD_VIRTUAL_PROMPT%
    1.71 +)
    1.72 +
    1.73 +set _OLD_VIRTUAL_PROMPT=%PROMPT%
    1.74 +set PROMPT=(%VIRTUAL_ENV%) %PROMPT%
    1.75 +
    1.76 +if defined _OLD_VIRTUAL_PATH goto OLDPATH
    1.77 +goto SKIPPATH
    1.78 +:OLDPATH
    1.79 +PATH %_OLD_VIRTUAL_PATH%
    1.80 +
    1.81 +:SKIPPATH
    1.82 +set _OLD_VIRTUAL_PATH=%PATH%
    1.83 +PATH %VIRTUAL_ENV%\bin;%PYTHONINSTALL%;%PATH%
    1.84 +set PYTHONKEY=
    1.85 +set PYTHONINSTALL=
    1.86 +set PYTHONVERSION=
    1.87 +set key=
    1.88 +set reg=
    1.89 +set _tokens=
    1.90 +python -c "from jetpack_sdk_env import welcome; welcome()"
    1.91 +GOTO :EOF
    1.92 +
    1.93 +:CheckPython
    1.94 +::CheckPython(retVal, key)
    1.95 +::Reads the registry at %2% and checks if a Python exists there.
    1.96 +::Checks both HKLM and HKCU, then checks the executable actually exists.
    1.97 +SET key=%2%
    1.98 +SET "%~1="
    1.99 +SET reg=reg
   1.100 +if defined ProgramFiles(x86) (
   1.101 +  rem 32-bit cmd on 64-bit windows
   1.102 +  if exist %WINDIR%\sysnative\reg.exe SET reg=%WINDIR%\sysnative\reg.exe
   1.103 +)
   1.104 +rem On Vista+, the last line of output is:
   1.105 +rem    (default)  REG_SZ  the_value
   1.106 +rem (but note the word "default" will be localized.
   1.107 +rem On XP, the last line of output is:
   1.108 +rem   <NO NAME>\tREG_SZ\tthe_value
   1.109 +rem (not sure if "NO NAME" is localized or not!)
   1.110 +rem SO: we use ")>" as the tokens to split on, then nuke
   1.111 +rem the REG_SZ and any tabs or spaces.
   1.112 +FOR /F "usebackq tokens=2 delims=)>" %%A IN (`%reg% QUERY HKLM\%key% /ve 2^>NUL`) DO SET "%~1=%%A"
   1.113 +rem Remove the REG_SZ
   1.114 +set PYTHONINSTALL=%PYTHONINSTALL:REG_SZ=%
   1.115 +rem Remove tabs (note the literal \t in the next line
   1.116 +set PYTHONINSTALL=%PYTHONINSTALL:	=%
   1.117 +rem Remove spaces.
   1.118 +set PYTHONINSTALL=%PYTHONINSTALL: =%
   1.119 +if exist %PYTHONINSTALL%\python.exe goto :EOF
   1.120 +rem It may be a 32bit Python directory built from source, in which case the
   1.121 +rem executable is in the PCBuild directory.
   1.122 +if exist %PYTHONINSTALL%\PCBuild\python.exe (set "PYTHONINSTALL=%PYTHONINSTALL%\PCBuild" & goto :EOF)
   1.123 +rem Or maybe a 64bit build directory.
   1.124 +if exist %PYTHONINSTALL%\PCBuild\amd64\python.exe (set "PYTHONINSTALL=%PYTHONINSTALL%\PCBuild\amd64" & goto :EOF)
   1.125 +
   1.126 +rem And try HKCU
   1.127 +FOR /F "usebackq tokens=2 delims=)>" %%A IN (`%reg% QUERY HKCU\%key% /ve 2^>NUL`) DO SET "%~1=%%A"
   1.128 +set PYTHONINSTALL=%PYTHONINSTALL:REG_SZ=%
   1.129 +set PYTHONINSTALL=%PYTHONINSTALL:	=%
   1.130 +set PYTHONINSTALL=%PYTHONINSTALL: =%
   1.131 +if exist %PYTHONINSTALL%\python.exe goto :EOF
   1.132 +if exist %PYTHONINSTALL%\PCBuild\python.exe (set "PYTHONINSTALL=%PYTHONINSTALL%\PCBuild" & goto :EOF)
   1.133 +if exist %PYTHONINSTALL%\PCBuild\amd64\python.exe (set "PYTHONINSTALL=%PYTHONINSTALL%\PCBuild\amd64" & goto :EOF)
   1.134 +rem can't find it here, so arrange to try the next key
   1.135 +set PYTHONINSTALL=
   1.136 +
   1.137 +GOTO :EOF

mercurial