55
55
'linux2-mips' : ['/usr/local' , '/usr' ],
56
56
'linux2-sparc' : ['/usr/local' , '/usr' ],
57
57
'linux2' : ['/usr/local' , '/usr' ],
58
+ 'linux3' : ['/usr/local' , '/usr' ],
58
59
'linux' : ['/usr/local' , '/usr' ,],
59
60
'cygwin' : ['/usr/local' , '/usr' ,],
60
61
'_darwin' : ['/sw/lib/freetype2' , '/sw/lib/freetype219' , '/usr/local' ,
@@ -834,9 +835,11 @@ def query_tcltk():
834
835
def parse_tcl_config (tcl_lib_dir , tk_lib_dir ):
835
836
import Tkinter
836
837
tcl_poss = [tcl_lib_dir ,
838
+ os .path .normpath (os .path .join (tcl_lib_dir , '..' )),
837
839
"/usr/lib/tcl" + str (Tkinter .TclVersion ),
838
840
"/usr/lib" ]
839
841
tk_poss = [tk_lib_dir ,
842
+ os .path .normpath (os .path .join (tk_lib_dir , '..' )),
840
843
"/usr/lib/tk" + str (Tkinter .TkVersion ),
841
844
"/usr/lib" ]
842
845
for ptcl , ptk in zip (tcl_poss , tk_poss ):
@@ -847,50 +850,31 @@ def parse_tcl_config(tcl_lib_dir, tk_lib_dir):
847
850
if not (os .path .exists (tcl_config ) and os .path .exists (tk_config )):
848
851
return None
849
852
850
- # These files are shell scripts that set a bunch of
851
- # environment variables. To actually get at the
852
- # values, we use ConfigParser, which supports almost
853
- # the same format, but requires at least one section.
854
- # So, we push a "[default]" section to a copy of the
855
- # file in a StringIO object.
856
- try :
857
- tcl_vars_str = StringIO ("[default]\n " + open (tcl_config , "r" ).read ())
858
- tk_vars_str = StringIO ("[default]\n " + open (tk_config , "r" ).read ())
859
- except IOError :
860
- # if we can't read the file, that's ok, we'll try
861
- # to guess instead
862
- return None
863
-
864
- tcl_vars_str .seek (0 )
865
- tcl_vars = configparser .RawConfigParser ()
866
- tk_vars_str .seek (0 )
867
- tk_vars = configparser .RawConfigParser ()
868
- try :
869
- tcl_vars .readfp (tcl_vars_str )
870
- tk_vars .readfp (tk_vars_str )
871
- except configparser .ParsingError :
872
- # if we can't read the file, that's ok, we'll try
873
- # to guess instead
874
- return None
875
-
876
- try :
877
- tcl_lib = tcl_vars .get ("default" , "TCL_LIB_SPEC" )[1 :- 1 ].split ()[0 ][2 :]
878
- tcl_inc = tcl_vars .get ("default" , "TCL_INCLUDE_SPEC" )[3 :- 1 ]
879
-
880
- tk_lib = tk_vars .get ("default" , "TK_LIB_SPEC" )[1 :- 1 ].split ()[0 ][2 :]
881
- if tk_vars .has_option ("default" , "TK_INCLUDE_SPEC" ):
882
- # On Ubuntu 8.04
883
- tk_inc = tk_vars .get ("default" , "TK_INCLUDE_SPEC" )[3 :- 1 ]
884
- else :
885
- # On RHEL4
886
- tk_inc = tcl_inc
887
- except (configparser .NoSectionError , configparser .NoOptionError ):
888
- return None
853
+ def get_var (file , varname ):
854
+ p = subprocess .Popen (
855
+ '. %s ; eval echo ${%s}' % (file , varname ),
856
+ shell = True ,
857
+ executable = "/bin/sh" ,
858
+ stdout = subprocess .PIPE )
859
+ result = p .communicate ()[0 ]
860
+ return result
861
+
862
+ tcl_lib_dir = get_var (tcl_config , 'TCL_LIB_SPEC' ).split ()[0 ][2 :]
863
+ tcl_inc_dir = get_var (tcl_config , 'TCL_INCLUDE_SPEC' )[2 :]
864
+ tcl_lib = get_var (tcl_config , 'TCL_LIB_FLAG' )[2 :].strip ()
865
+
866
+ tk_lib_dir = get_var (tk_config , 'TK_LIB_SPEC' ).split ()[0 ][2 :]
867
+ tk_inc_dir = get_var (tk_config , 'TK_INCLUDE_SPEC' ).strip ()
868
+ if tk_inc_dir == '' :
869
+ tk_inc_dir = tcl_inc_dir
870
+ else :
871
+ tk_inc_dir = tk_inc_dir [2 :]
872
+ tk_lib = get_var (tk_config , 'TK_LIB_FLAG' )[2 :].strip ()
889
873
890
- if not os .path .exists (os .path .join (tk_inc , 'tk.h' )):
874
+ if not os .path .exists (os .path .join (tk_inc_dir , 'tk.h' )):
891
875
return None
892
876
893
- return tcl_lib , tcl_inc , tk_lib , tk_inc
877
+ return tcl_lib_dir , tcl_inc_dir , tcl_lib , tk_lib_dir , tk_inc_dir , tk_lib
894
878
895
879
def guess_tcl_config (tcl_lib_dir , tk_lib_dir , tk_ver ):
896
880
if not (os .path .exists (tcl_lib_dir ) and os .path .exists (tk_lib_dir )):
@@ -925,14 +909,14 @@ def guess_tcl_config(tcl_lib_dir, tk_lib_dir, tk_ver):
925
909
if not os .path .exists (os .path .join (tk_inc , 'tk.h' )):
926
910
return None
927
911
928
- return tcl_lib , tcl_inc , tk_lib , tk_inc
912
+ return tcl_lib , tcl_inc , 'tcl' + tk_ver , tk_lib , tk_inc , 'tk' + tk_ver
929
913
930
914
def hardcoded_tcl_config ():
931
915
tcl_inc = "/usr/local/include"
932
916
tk_inc = "/usr/local/include"
933
917
tcl_lib = "/usr/local/lib"
934
918
tk_lib = "/usr/local/lib"
935
- return tcl_lib , tcl_inc , tk_lib , tk_inc
919
+ return tcl_lib , tcl_inc , 'tcl' , tk_lib , tk_inc , 'tk'
936
920
937
921
def add_tk_flags (module ):
938
922
'Add the module flags to build extensions which use tk'
@@ -1033,10 +1017,10 @@ def add_tk_flags(module):
1033
1017
result = hardcoded_tcl_config ()
1034
1018
1035
1019
# Add final versions of directories and libraries to module lists
1036
- tcl_lib , tcl_inc , tk_lib , tk_inc = result
1037
- module .include_dirs .extend ([tcl_inc , tk_inc ])
1038
- module .library_dirs .extend ([tcl_lib , tk_lib ])
1039
- module .libraries .extend (['tk' + tk_ver , 'tcl' + tk_ver ])
1020
+ tcl_lib_dir , tcl_inc_dir , tcl_lib , tk_lib_dir , tk_inc_dir , tk_lib = result
1021
+ module .include_dirs .extend ([tcl_inc_dir , tk_inc_dir ])
1022
+ module .library_dirs .extend ([tcl_lib_dir , tk_lib_dir ])
1023
+ module .libraries .extend ([tcl_lib , tk_lib ])
1040
1024
1041
1025
return message
1042
1026
0 commit comments