setupext bug in matplotlib

In [5]: tk.getvar('tk_library') Out[5]:

    > u'/usr/share/tcl/tk8.4'
    >> This looks like what Eric is getting (offlist).
    >>
    >> Can you confirm your tcl.h and tk.h are in /usr/include?

    > confirm

Where are your libtcl and libtk files?

Please try the attached, which isn't pretty but not much more we
can do on a broken system

def find_tcltk():
    """Finds Tcl/Tk includes/libraries/version by interrogating Tkinter."""
    try:
        import Tkinter
    except:
        print "Tkinter not properly installed\n"
        sys.exit(1)
    if Tkinter.TkVersion < 8.3:
        print "Tcl/Tk v8.3 or later required\n"
        sys.exit(1)
    o = FoundTclTk()
    try:
        tk=Tkinter.Tk()
    except Tkinter.TclError:
        print "Using default library and include directories for Tcl and Tk because a"
        print "Tk window failed to open. You may need to define DISPLAY for Tk to work"
        print "so that setup can determine where your libraries are located."
        o.tcl_lib = "/usr/local/lib"
        o.tcl_inc = "/usr/local/include"
        o.tk_lib = "/usr/local/lib"
        o.tk_inc = "/usr/local/include"
        o.tkv = ""
    else:
        tk.withdraw()
        o.tcl_lib = os.path.join((tk.getvar('tcl_library')), '../')
        o.tk_lib = os.path.join(str(tk.getvar('tk_library')), '../')
        o.tkv = str(Tkinter.TkVersion)[:3]
        o.tcl_inc = os.path.join((tk.getvar('tcl_library')),
                    '../../include/tcl'+o.tkv)
        if not os.path.exists(o.tcl_inc):
            o.tcl_inc = os.path.join((tk.getvar('tcl_library')),
                        '../../include')
        o.tk_inc = os.path.join((tk.getvar('tk_library')),
                    '../../include/tk'+o.tkv)
        if not os.path.exists(o.tk_inc):
            o.tk_inc = os.path.join((tk.getvar('tk_library')),
                        '../../include')

        # this is a hack for suse, which is broken
        if not os.path.exists(o.tcl_inc):
            if os.path.exists('/usr/include/tcl.h') and os.path.exists('/usr/include/tk.h'):
                o.tcl_inc = '/usr/include/'
                o.tk_inc = '/usr/include/'
                
        if not os.path.exists(o.tcl_inc):
            print 'cannot find tcl/tk headers. giving up.'
            sys.exit()

John Hunter wrote:

    > In [5]: tk.getvar('tk_library') Out[5]:
    > u'/usr/share/tcl/tk8.4'
    >> This looks like what Eric is getting (offlist).
    >> >> Can you confirm your tcl.h and tk.h are in /usr/include?

    > confirm

Where are your libtcl and libtk files?

torro[~/tmp/firefox] ls /usr/lib/libtcl
libtcl8.4.so* libtclstub8.4.a libtclx8.4.so* torro[~/tmp/firefox] ls /usr/lib/libtk
libtk8.4.so* libtkstub8.4.a

The function is not working. I print the test and another Suse mystery appeared...

python setup.py install
False /usr/share/tcl/tcl8.4/../../include
Traceback (most recent call last):
  File "setup.py", line 229, in ?
    build_tkagg(ext_modules, packages, NUMERIX)
  File "/home/humufr/matplotlib/matplotlib/setupext.py", line 570, in build_tkagg
    add_tk_flags(module) # do this first
  File "/home/humufr/matplotlib/matplotlib/setupext.py", line 495, in add_tk_flags
    module.include_dirs.extend([o.tcl_inc, o.tk_inc])
AttributeError: 'NoneType' object has no attribute 'tcl_inc'

The result of the test to contourn Suse problem:

print os.path.exists(o.tcl_inc),o.tcl_inc

False /usr/share/tcl/tcl8.4/../../include

And I checked the directory:

torro[~/tmp/firefox] ls /usr/share/tcl/tcl8.4/../../include
ls: /usr/share/tcl/tcl8.4/../../include: No such file or directory

N.

···

Please try the attached, which isn't pretty but not much more we
can do on a broken system

def find_tcltk():
    """Finds Tcl/Tk includes/libraries/version by interrogating Tkinter."""
    try:
        import Tkinter
    except:
        print "Tkinter not properly installed\n"
        sys.exit(1)
    if Tkinter.TkVersion < 8.3:
        print "Tcl/Tk v8.3 or later required\n"
        sys.exit(1)
    o = FoundTclTk()
    try:
        tk=Tkinter.Tk()
    except Tkinter.TclError:
        print "Using default library and include directories for Tcl and Tk because a"
        print "Tk window failed to open. You may need to define DISPLAY for Tk to work"
        print "so that setup can determine where your libraries are located."
        o.tcl_lib = "/usr/local/lib"
        o.tcl_inc = "/usr/local/include"
        o.tk_lib = "/usr/local/lib"
        o.tk_inc = "/usr/local/include"
        o.tkv = ""
    else:
        tk.withdraw()
        o.tcl_lib = os.path.join((tk.getvar('tcl_library')), '../')
        o.tk_lib = os.path.join(str(tk.getvar('tk_library')), '../')
        o.tkv = str(Tkinter.TkVersion)[:3]
        o.tcl_inc = os.path.join((tk.getvar('tcl_library')), '../../include/tcl'+o.tkv)
        if not os.path.exists(o.tcl_inc):
            o.tcl_inc = os.path.join((tk.getvar('tcl_library')), '../../include')
        o.tk_inc = os.path.join((tk.getvar('tk_library')), '../../include/tk'+o.tkv) if not os.path.exists(o.tk_inc):
            o.tk_inc = os.path.join((tk.getvar('tk_library')), '../../include')

        # this is a hack for suse, which is broken
        if not os.path.exists(o.tcl_inc): if os.path.exists('/usr/include/tcl.h') and os.path.exists('/usr/include/tk.h'):
                o.tcl_inc = '/usr/include/'
                o.tk_inc = '/usr/include/'
                        if not os.path.exists(o.tcl_inc):
            print 'cannot find tcl/tk headers. giving up.'
            sys.exit()

-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users