Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

python build doesn't link with brew tk / tcl #16574

Closed
scicalculator opened this Issue · 10 comments

4 participants

@scicalculator

I built tk with the --enable-threads option to attempt to use a tkinter application that runs in threads. Building tk (with --enable-threads), tcl, and python all work, but the _tkinter.so library does not utilize the homebrew tk library.

$ otool -L Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_tkinter.so
Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_tkinter.so:
        /System/Library/Frameworks/Tcl.framework/Versions/8.5/Tcl (compatibility version 8.5.0, current version 8.5.9)
        /System/Library/Frameworks/Tk.framework/Versions/8.5/Tk (compatibility version 8.5.0, current version 8.5.9)
        /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 169.3.0)

$ otool -L Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/lib-dynload/_tkinter.so
Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/lib-dynload/_tkinter.so:
        /System/Library/Frameworks/Tcl.framework/Versions/8.5/Tcl (compatibility version 8.5.0, current version 8.5.9)
        /System/Library/Frameworks/Tk.framework/Versions/8.5/Tk (compatibility version 8.5.0, current version 8.5.9)
        /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 169.3.0)

I think there should be a way (option?) to install python with the homebrew tk/tcl libraries. Also, if tk and tcl exist, wouldn't it seem reasonable to install with them? Is there something I am missing to easily bypass this and reinstall python linking to the right libraries?

Or, have I made a mistake in some way? Any thoughts, ideas, or help would be appreciated.

@samueljohn

True. My Tk is also the system one.
I think we have to (re)work the formula a bit to prefer homebrew's Tk if present.

I can look into this.

@samueljohn

Python's configure does not provide an option to specify a certain Tk framework.
I have tried to add depends_on 'tk' if build.include? 'with-brewed-tk but still Python seems to prefer Tk from MacOS X.

@scicalculator let me know if you know a way to persuade python.

@scicalculator

I looked into it. It seems that the setup.py file in the main directory is called and establishes the libraries. In there are two function (detect_tkinter and detect_tkinter_darwin), which essentially gather information for building the tkinter _tkinter.so library. When it detects OSX, it runs detect_tkinter_darwin, which assumes the location of the Tk framework bundled in OSX. I attempted several ways of getting this library to build differently (they should not be applied at the same time):

  1. https://gist.github.com/4315577
  2. https://gist.github.com/4315577/aff34e8225ac5c42e16bfaadb7c9259e905e27f5

Unfortunately, when I installed python with either of these patches, it resulted in no tkinter library bundled with python. That means import Tkinter throws an exception ImportError: no _tkinter.so (something like that). I did not see when any error message occured. However, there is indeed a _tkiner.so file in the build directory (the file exists), but for some reason, it is not in the final Cellar.

I don't have time to go any further into it right now, but at least it's a start. Hope that can get us on the right path.

@samueljohn
@scicalculator

I don't know what I am doing wrong, but I found that macports uses a very similar method to 2 above, which I think is the best way (https://gist.github.com/4315577/aff34e8225ac5c42e16bfaadb7c9259e905e27f5).

$ otool -L build/lib.macosx-10.8-x86_64-2.7/_tkinter.so
build/lib.macosx-10.8-x86_64-2.7/_tkinter.so:
        /usr/local/lib/libtk8.5.dylib (compatibility version 8.5.0, current version 8.5.9)
        /usr/local/lib/libtcl8.5.dylib (compatibility version 8.5.0, current version 8.5.9)
        /opt/X11/lib/libX11.6.dylib (compatibility version 10.0.0, current version 10.0.0)
        /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 169.3.0)

You can see that the library is properly linked as far as I can tell. The problem is, it doesn't come over from the build directory into the compiled framework.

@scicalculator

Interesting, I just did 2 tests. I halted the brew installation after configure. Then I entered the shell (brew install --debug python). If I then use make it creates _tkinter.so. However, if I halt the brew installation after it uses system 'make' I find no _tkinter.so. What is different between brew using make and my shell using make that there is this difference? That is what is important here. I'll report when I figure it out.

@samueljohn samueljohn referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
@samueljohn

A while back I had to add the header directory explicitly for the Tk shipped with OS X. Now, I have to disable that for --with-brewed-tk. Check out my pull request and tell me if it builds for you. Thanks for the patch, I pasted that one into the formula.

@samueljohn

#16626 is on hold currently (temporarily closed), because we wait for Homebrew/homebrew-dupes#132 first.

@samueljohn samueljohn referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
@samueljohn samueljohn referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
@samueljohn samueljohn referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
@samueljohn samueljohn referenced this issue from a commit in samueljohn/homebrew
@samueljohn samueljohn python: Allow --with-brewed-tk.
- Fixes #16574.
- Improve Tkinter test by actually calling Tk()
- Check for /Library/Frameworks/Tk.framework no longer needed.
- Fix PYTHONFRAMEWORKDIR so that `python-config --ldflags` is useful.
7941a97
@mikemcquaid mikemcquaid closed this issue from a commit
@samueljohn samueljohn python: Allow --with-brewed-tk.
- Fixes #16574.
- Improve Tkinter test by actually calling Tk()
- Check for /Library/Frameworks/Tk.framework no longer needed.
- Fix PYTHONFRAMEWORKDIR so that `python-config --ldflags` is useful.

Closes #16626.

Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
1d8f01d
@samueljohn

@scicalculator please let me know if it works now for you

@mikemcquaid mikemcquaid referenced this issue from a commit
@mikemcquaid mikemcquaid Revert "python: Allow --with-brewed-tk."
This reverts commit 1d8f01d.

Reopens #16626, reopens #16574.
cc2b8b3
@mikemcquaid mikemcquaid reopened this
@mikemcquaid
Owner

Reverted that commit, sorry.

@samueljohn samueljohn referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
@samueljohn samueljohn referenced this issue from a commit in samueljohn/homebrew
@samueljohn samueljohn python: Allow --with-brewed-tk.
- Fixes #16574.
- Improve Tkinter test by actually calling Tk()
- Check for /Library/Frameworks/Tk.framework no longer needed.
- Also remove Tk.framework check from python3.rb
- Fix PYTHONFRAMEWORKDIR so that `python-config --ldflags` is useful.
90f5168
@dholm dholm referenced this issue from a commit in dholm/homebrew
@samueljohn samueljohn python: Allow --with-brewed-tk.
- Fixes #16574.
- Improve Tkinter test by actually calling Tk()
- Check for /Library/Frameworks/Tk.framework no longer needed.
- Fix PYTHONFRAMEWORKDIR so that `python-config --ldflags` is useful.

Closes #16626.

Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
3fc5b59
@dholm dholm referenced this issue from a commit in dholm/homebrew
@mikemcquaid mikemcquaid Revert "python: Allow --with-brewed-tk."
This reverts commit 1d8f01d.

Reopens #16626, reopens #16574.
288689a
@adamv adamv closed this issue from a commit
@samueljohn samueljohn python: Allow --with-brewed-tk.
- Fixes #16574.
- Improve Tkinter test by actually calling Tk()
- Check for /Library/Frameworks/Tk.framework no longer needed.
- Also remove Tk.framework check from python3.rb
- Fix PYTHONFRAMEWORKDIR so that `python-config --ldflags` is useful.

Closes #17008.

Signed-off-by: Adam Vandenberg <flangy@gmail.com>
3defd78
@adamv adamv closed this in 3defd78
@norioxkimura norioxkimura referenced this issue from a commit in norioxkimura/homebrew
@samueljohn samueljohn python: Allow --with-brewed-tk.
- Fixes #16574.
- Improve Tkinter test by actually calling Tk()
- Check for /Library/Frameworks/Tk.framework no longer needed.
- Fix PYTHONFRAMEWORKDIR so that `python-config --ldflags` is useful.

Closes #16626.

Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
f2c4d04
@norioxkimura norioxkimura referenced this issue from a commit in norioxkimura/homebrew
@mikemcquaid mikemcquaid Revert "python: Allow --with-brewed-tk."
This reverts commit 1d8f01d.

Reopens #16626, reopens #16574.
6947e80
@norioxkimura norioxkimura referenced this issue from a commit in norioxkimura/homebrew
@samueljohn samueljohn python: Allow --with-brewed-tk.
- Fixes #16574.
- Improve Tkinter test by actually calling Tk()
- Check for /Library/Frameworks/Tk.framework no longer needed.
- Also remove Tk.framework check from python3.rb
- Fix PYTHONFRAMEWORKDIR so that `python-config --ldflags` is useful.

Closes #17008.

Signed-off-by: Adam Vandenberg <flangy@gmail.com>
6137dcd
@guyzmo guyzmo referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
@guyzmo guyzmo referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
@guyzmo guyzmo referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
@guyzmo guyzmo referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
@cooljeanius cooljeanius referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
@rajeeja rajeeja referenced this issue from a commit
@samueljohn samueljohn python: Allow --with-brewed-tk.
- Fixes #16574.
- Improve Tkinter test by actually calling Tk()
- Check for /Library/Frameworks/Tk.framework no longer needed.
- Fix PYTHONFRAMEWORKDIR so that `python-config --ldflags` is useful.

Closes #16626.

Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
34f90c1
@rajeeja rajeeja referenced this issue from a commit
@mikemcquaid mikemcquaid Revert "python: Allow --with-brewed-tk."
This reverts commit 1d8f01d.

Reopens #16626, reopens #16574.
bedb8df
@rajeeja rajeeja referenced this issue from a commit
@samueljohn samueljohn python: Allow --with-brewed-tk.
- Fixes #16574.
- Improve Tkinter test by actually calling Tk()
- Check for /Library/Frameworks/Tk.framework no longer needed.
- Also remove Tk.framework check from python3.rb
- Fix PYTHONFRAMEWORKDIR so that `python-config --ldflags` is useful.

Closes #17008.

Signed-off-by: Adam Vandenberg <flangy@gmail.com>
65bd175
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.