File: scientific_win32_postinstall.py

package info (click to toggle)
python-scientific 2.8-1.2
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 6,456 kB
  • ctags: 7,038
  • sloc: python: 16,436; ansic: 4,379; makefile: 135; sh: 18; csh: 1
file content (25 lines) | stat: -rw-r--r-- 686 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# Add Python DLL directory to PATH

from _winreg import *
import os
import sys

def install():
    path = r'SYSTEM\CurrentControlSet\Control\Session Manager\Environment'
    reg = ConnectRegistry(None, HKEY_LOCAL_MACHINE)
    key = OpenKey(reg, path, 0, KEY_ALL_ACCESS)

    current_path, type_id = QueryValueEx(key, "PATH")
    dll_path = os.path.join(sys.prefix, 'DLLs')

    if not dll_path.upper() in current_path.upper().split(";"):
        new_path = current_path + ';' + dll_path
        SetValueEx(key, "PATH", 0, REG_EXPAND_SZ, new_path)

    CloseKey(key)
    CloseKey(reg)

if __name__=='__main__':
    if len(sys.argv) == 2 and sys.argv[1] == '-install':
        install()