[matplotlib-devel] setupext.py chooses tk on mac OS X incorrectly
Hello, I was having trouble getting matplotlib to link to the correct Tcl and Tk, and as a result uncovered what I would call a bug, or at least unpredictable behavior. Basically, I have a custom Tcl/Tk installation, and I setup python to correctly find them, so I have the expectation that Matplotlib would use the same Tk. It can be pretty easily figured out just by importing Tkinter. Anyway, I looked through the matplotlib setupext.py and discovered that there is a function that does this, and correctly: query_tcltk anyway, the logic in the setupext file is such that if the sys.platform is 'darwin' then it will look for a Framework first (maybe only), and since there is always an ancient system version of Tcl and Tk, it will always pick those before anywhere else. The system frameworks are not complete, and I know you all recommend installing a binary with everything in it. Unfortunately, I did not have this option for unimportant reasons. Either way, I do believe that it is a bug that it does not choose the Tk that is being used by Python or at least trying to before using other available libraries and frameworks. This is easy enough for me to fix just for myself and at work, but I believe that you all should consider using Python's Tk for these reasons: 1). If python was installed from source, this is the one that the user configured python to use, and therefore is the one they trust. 2). If the Tk/Tcl libraries were installed from source instead of using the binaries you suggested installing, then it will just use the wrong system Framework anyway. I bet people using macports and other unix-like package managers on mac end up submitting a lot of bug reports over this. 3). It is just more predictable and sustainable if modules set Python as their standard base. Besides, it isn't much work as you already wrote a function to find the correct tcl and tk. 4). I don't mind helping write the patch. I am only worried about not knowing the intricacies of all the random supported platforms that you all look out for. For example: I know jack about Windows linking. Either way, I'll update it if you have someone look at it. I'll work on it sometimes this week when I'm not too busy at work and send it in. Anyway, I am hoping that I convinced you all, and look forward to helping fix this. Have a great rest-of-the-week! Jayson -- Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM) software. With Adobe AIR, Ajax developers can use existing skills and code to build responsive, highly engaging applications that combine the power of local resources and data with the reach of the web. Download the Adobe AIR SDK and Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com ___ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
Re: [matplotlib-devel] setupext.py chooses tk on mac OS X incorrectly
I should also add that the reason it won't find my tclConfig.sh and tkConfig.sh files is because they were configured/installed with the --prefix option, but with the information from Python this is easily resolvable. Jayson On Wed, Feb 4, 2009 at 3:08 PM, Jayson Barr wrote: > Hello, > > I was having trouble getting matplotlib to link to the correct Tcl and > Tk, and as a result uncovered what I would call a bug, or at least > unpredictable behavior. > > Basically, I have a custom Tcl/Tk installation, and I setup python to > correctly find them, so I have the expectation that Matplotlib would > use the same Tk. It can be pretty easily figured out just by > importing Tkinter. Anyway, I looked through the matplotlib > setupext.py and discovered that there is a function that does this, > and correctly: query_tcltk > > anyway, the logic in the setupext file is such that if the > sys.platform is 'darwin' then it will look for a Framework first > (maybe only), and since there is always an ancient system version of > Tcl and Tk, it will always pick those before anywhere else. > > The system frameworks are not complete, and I know you all recommend > installing a binary with everything in it. Unfortunately, I did not > have this option for unimportant reasons. > > Either way, I do believe that it is a bug that it does not choose the > Tk that is being used by Python or at least trying to before using > other available libraries and frameworks. This is easy enough for me > to fix just for myself and at work, but I believe that you all should > consider using Python's Tk for these reasons: > 1). If python was installed from source, this is the one that the > user configured python to use, and therefore is the one they trust. > 2). If the Tk/Tcl libraries were installed from source instead of > using the binaries you suggested installing, then it will just use the > wrong system Framework anyway. I bet people using macports and other > unix-like package managers on mac end up submitting a lot of bug > reports over this. > 3). It is just more predictable and sustainable if modules set Python > as their standard base. Besides, it isn't much work as you already > wrote a function to find the correct tcl and tk. > 4). I don't mind helping write the patch. I am only worried about > not knowing the intricacies of all the random supported platforms that > you all look out for. For example: I know jack about Windows linking. > Either way, I'll update it if you have someone look at it. I'll work > on it sometimes this week when I'm not too busy at work and send it > in. > > Anyway, > I am hoping that I convinced you all, and look forward to helping fix this. > > Have a great rest-of-the-week! > Jayson > -- Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM) software. With Adobe AIR, Ajax developers can use existing skills and code to build responsive, highly engaging applications that combine the power of local resources and data with the reach of the web. Download the Adobe AIR SDK and Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com ___ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
Re: [matplotlib-devel] setupext.py chooses tk on mac OS X incorrectly
Hi all, I agree with JDH. Unfortunately, work has been exceptionally hectic so I haven't begun the patch (if you don't count the hack job I did to install it for myself). Hi Adam, As noted above, I haven't started a patch yet but I would be up for working with you on one. It sounds like we can get this tested pretty well. Thanks, and talk to you soon, Jayson On Sat, Feb 7, 2009 at 7:44 AM, John Hunter wrote: > On Wed, Feb 4, 2009 at 5:08 PM, Jayson Barr wrote: > >> 4). I don't mind helping write the patch. I am only worried about >> not knowing the intricacies of all the random supported platforms that >> you all look out for. For example: I know jack about Windows linking. >> Either way, I'll update it if you have someone look at it. I'll work >> on it sometimes this week when I'm not too busy at work and send it >> in. > > > The problem is that the code is already messy, and Adam describes his > solution as messy, and it is difficult if not impossible to get people > to test on all the required platforms. I can test on OS X w/o > macports and a linux box, Charlie would probably be able to test on > win32, and Adam can test on macports. Perhaps you and Adam can > collaborate on a patch and we'll see if we can get it properly tested. > There are lots of tcl/tk combinations out there on different > platforms, so it is a trick issue. > > JDH > -- Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM) software. With Adobe AIR, Ajax developers can use existing skills and code to build responsive, highly engaging applications that combine the power of local resources and data with the reach of the web. Download the Adobe AIR SDK and Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com ___ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
Re: [matplotlib-devel] setupext.py chooses tk on mac OS X incorrectly
Adam: sorry, I didn't mean to just send that straight to you. gmail decided its default would be to send to you and not the mailing list. Everyone else: The message that was supposed to go to the list: I was looking at setupext.py and I am thinking that we could just change the add_tk_flags function. My idea is to remove the elif sys.platform == "darwin" section and always go to the else. In the except line after trying query_tcltk() we can add a check for darwin and have it search the normal framework locations, or even put an if sys.platform == "darwin" that goes for the frameworks in hardcoded_tclconfig(). In the else line after that we could do a check to see if the returned tcl/tk libs and version match any normal system framework paths (in $HOME/Library/Frameworks, /System/Library and /System/Library/Frameworks) or even just look at the library name or some other method to determine if it is a framework and add the "-framework Tcl -framework Tk" flags to module.extra_link_args and module.extra_compile_args if they are. Also, I was looking and I don't actually see any point around here where it is explicitly checked if the results of query_tcltk() correspond to a directory that is in basedir["darwin"]. As an aside, we could add to hardcoded_tclconfig() to surf the directories returned from add_base_flags / basedir["darwin"] instead of the directories it has. It would probably be best on all systems to look in the basedir[os.system] directories for Tk as a last result rather than /usr/local Basically, I am just sharing some of the ideas I have been playing with. Jayson On Thu, Feb 12, 2009 at 12:45 PM, Jayson Barr wrote: > I was looking at setupext.py and I am thinking that we could just > change the add_tk_flags function. > > My idea is to remove the elif sys.platform == "darwin" section and > always go to the else. > > In the except line after trying query_tcltk() we can add a check for > darwin and have it search the normal framework locations, or even put > an if sys.platform == "darwin" that goes for the frameworks in > hardcoded_tclconfig(). > > In the else line after that we could do a check to see if the returned > tcl/tk libs and version match any normal system framework paths (in > $HOME/Library/Frameworks, /System/Library and > /System/Library/Frameworks) or even just look at the library or some > other method to determine if it is a framework and add the "-framework > Tcl -framework Tk" flags to module.extra_link_args and > module.extra_compile_args if they are. > > Also, I was looking and I don't actually see any point around here > where it is explicitly checked if the results of query_tcltk() > corrsepond to a directory that is in basedir["darwin"]. > > As an aside, we could add to hardcoded_tclconfig() to surf the > directories returned from add_base_flags / basedir["darwin"] instead > of the directories it has. It would probably be best on all systems > to look in the basedir[os.system] directories as a last result rather > than /usr/local > > Basically, I am just sharing some of the ideas I have been playing with. > > Jayson > > On Tue, Feb 10, 2009 at 9:54 AM, Adam Mercer wrote: >> On Mon, Feb 9, 2009 at 17:08, Jayson Barr wrote: >> >>> I agree with JDH. >> >> Likewise. >> >>> Unfortunately, work has been exceptionally hectic so I haven't begun >>> the patch (if you don't count the hack job I did to install it for >>> myself). >> >> Same here, I'm really busy with work and don't have much time to look >> into this at the moment. >> >>> Hi Adam, >>> As noted above, I haven't started a patch yet but I would be up for >>> working with you on one. It sounds like we can get this tested pretty >>> well. >> >> Its on my todo list, so when I get chance I'm going to investigate a >> better solution. I'll keep you posted. >> >> Cheers >> >> Adam >> > -- ___ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel