/[ascend]/trunk/scons/tcl-config
ViewVC logotype

Diff of /trunk/scons/tcl-config

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1947 by jpye, Mon Nov 10 01:04:27 2008 UTC revision 1948 by jpye, Mon Nov 10 01:34:32 2008 UTC
# Line 1  Line 1 
1  #! /usr/bin/env python  #! /usr/bin/env python
2    
3  tclscript = """  tclconfigfile = None
4   foreach d [concat \  
5        [list $tcl_library \  import sys, platform, os.path
6              [lindex $tcl_pkgPath 0]] \  if platform.system()=="Windows":
7        $auto_path \      # check for ActiveState Tcl in Windows registry
8        [list [file dirname $tcl_library] \      try:
9              [file dirname [lindex $tcl_pkgPath 0]] \          import _winreg
10              [file dirname [file dirname $tcl_library]] \          x=_winreg.ConnectRegistry(None,_winreg.HKEY_LOCAL_MACHINE)
11              [file dirname [file dirname [lindex $tcl_pkgPath 0]]] \          y= _winreg.OpenKey(x,r"SOFTWARE\ActiveState\ActiveTcl")
12              [file dirname [file dirname [file dirname $tcl_library]]] \          _regversion,t = _winreg.QueryValueEx(y,"CurrentVersion")
13              [file dirname [file dirname [file dirname [lindex $tcl_pkgPath 0]]]]] \          z= _winreg.OpenKey(x,r"SOFTWARE\ActiveState\ActiveTcl\%s" % str(_regversion))
14   ] {          _regpath,t = _winreg.QueryValueEx(z,None)
15       if {[file exists [file join $d tclConfig.sh]]} {          _winreg.CloseKey(y)
16           puts "[file join $d tclConfig.sh]"          _winreg.CloseKey(z)
17           exit          _winreg.CloseKey(x)
18       }          # typically, c:\Tcl\lib\tclConfig.sh.
19   }          _regconfig = os.path.join(_regpath,os.path.join("lib","tclConfig.sh"))
20  """          if os.path.exists(_regconfig):
21                # if the file exists, good...
22  # determine location of tclConfig.sh              tclconfigfile = _regconfig
23        except:
24  import subprocess          pass
25  output = subprocess.Popen(["tclsh"], stdin=subprocess.PIPE, stdout=subprocess.PIPE).communicate(input=tclscript)[0]  
26  tclconfigfile = output.strip()  if tclconfigfile is None:
27        # use a 'tclsh' script to find location of tclConfig.sh
28        tclscript = """
29         foreach d [concat \
30              [list $tcl_library \
31                    [lindex $tcl_pkgPath 0]] \
32              $auto_path \
33              [list [file dirname $tcl_library] \
34                    [file dirname [lindex $tcl_pkgPath 0]] \
35                    [file dirname [file dirname $tcl_library]] \
36                    [file dirname [file dirname [lindex $tcl_pkgPath 0]]] \
37                    [file dirname [file dirname [file dirname $tcl_library]]] \
38                    [file dirname [file dirname [file dirname [lindex $tcl_pkgPath 0]]]]] \
39         ] {
40             if {[file exists [file join $d tclConfig.sh]]} {
41                 puts "[file join $d tclConfig.sh]"
42                 exit
43             }
44         }
45        """
46    
47        import subprocess
48        output = subprocess.Popen(["tclsh"], stdin=subprocess.PIPE, stdout=subprocess.PIPE).communicate(input=tclscript)[0]
49        if os.path.exists(output.strip):
50            # only report the file if it actually exists...
51            tclconfigfile = output.strip()
52    
53    if tclconfigfile is None:
54        print "Unable to locate tclConfig.sh"
55        sys.exit(1)
56    
57  # parse the file to determine the names of the variables it contains  # parse the file to determine the names of the variables it contains
58    

Legend:
Removed from v.1947  
changed lines
  Added in v.1948

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22