File: openbabel_postinstall.py

package info (click to toggle)
openbabel 2.2.0-2
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 37,188 kB
  • ctags: 47,193
  • sloc: cpp: 237,858; ansic: 85,555; cs: 22,219; java: 14,377; sh: 9,876; perl: 5,432; python: 4,319; pascal: 793; makefile: 683; xml: 97; ruby: 54
file content (27 lines) | stat: -rw-r--r-- 1,011 bytes parent folder | download
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
26
27
"""
Set BABEL_DATADIR to the location where the
openbabel_data was installed
"""

import os, sys
import _winreg

if len(sys.argv)==2 and sys.argv[1]=="-install":
    # Connect to the registry
    registry = _winreg.ConnectRegistry(None,_winreg.HKEY_LOCAL_MACHINE)
    # Open Environment key for writing
    environment =_winreg.OpenKey(registry,
       r"SYSTEM\CurrentControlSet\Control\Session Manager\Environment",
       0,_winreg.KEY_ALL_ACCESS)
    # Set the value of BABEL_DATADIR
    datadir = os.path.join(sys.prefix, "Lib", "site-packages", "openbabel_data")
    _winreg.SetValueEx(environment, "BABEL_DATADIR", 0, _winreg.REG_EXPAND_SZ,
       datadir)
    _winreg.CloseKey(environment)
    _winreg.CloseKey(registry)

    print "BABEL_DATADIR is set to %s" % datadir
    print
    print "You will need to reboot before the openbabel module"
    print "can access the new value of BABEL_DATADIR. However,"
    print "you can start using the module right away if you wish."