Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

pygtk does not install correctly #16891

Closed
marcindulak opened this Issue · 22 comments

5 participants

@marcindulak

This is problem reported originally at Homebrew/homebrew-science#53
pygtk related packages do not create correct links under /usr/local/include.
Creating links as listed above results in a matplotlib working with gdk backend
(no more "ImportError: No module named _backend_gdk")

@marcindulak marcindulak referenced this issue in Homebrew/homebrew-science
Closed

pygtk does not install correctly #53

@samueljohn

So there is the chance for an easy fix?

@marcindulak

One has to set PKG_CONFIG_PATH correctly and additionally /usr/local/lib/pkgconfig/libffi.pc needs to be present (for some reasons it is not linked correctly from Cellar). So after libffi gets fixed, the correct variable would be:
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/opt/X11/lib/pkgconfig
The second dir is due to #14123

@adamv
Owner

If pygtk uses libffi, it should have depends_on 'libffi'.

@samueljohn

I guess @adamv is right; would be great if you could test this @marcindulak :-)

@marcindulak

The problem (or feature) of the libffi.pc file missing is due the libffi formula itself.
#9911
So the question is: do i need to set the PKG_CONFIG_PATH before building pip install matplotlib or
this should be happening automatically?

@samueljohn

A good question. Does pip install matplotlib read the PKG_CONFIG_PATH at all? (I haven't tested)

@marcindulak

Yes it does

@samueljohn

Then, perhaps, I can make a formula for matplotlib in my homebrew-python repository. Homebrew sets the PKG_CONFIG_PATH correctly during a build (if the depends_on lists the needed libs)

@marcindulak

I understand now: homebrew sets the variables only within its own environment, so PKG_CONFIG_PATH
is not known the the shell, and this means some brew installed packages are not fully functional outside of brew.
Users need to keep track of this and set the variables by hand: #6828
Additional information: doing brew link libffi links the libffi.pc under /usr/local/lib/pkgconfig as expected,
but i understand there is a good reason the link is not performed for libffi.

@samueljohn

Yes, Homebrew cannot set variables outside of its own process. Otherwise it would need to mess around with you .profile or whatever shell you are using.

You can call brew sh to temporary get the environment brew is using. I think this sets up the PKG_CONFIG_PATH, too. But I think not for keg_only formulae. Because these can break many other builds because they overwrite stuff from OS X.

Often one can set the path to a specific .pc file. But not sure if matplotlib allows this.

@marcindulak

I'm building pip install matplotlib outside of brew with:
export PKG_CONFIG_PATH=brew --prefix libffi/lib/pkgconfig:$PKG_CONFIG_PATH
export PKG_CONFIG_PATH=/opt/X11/lib/pkgconfig:$PKG_CONFIG_PATH
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH
The X11 one is related to xquartz and there is some discussion here #14489

@samueljohn

This is enough hassle. I am going to make a matplotlib formula in my homebrew-python tap.

@samueljohn

Ok, here it comes:
https://github.com/samueljohn/homebrew-python

brew tap samueljohn/python
brew install matplotlib --with-gtk

Let me know if there are any problems.

@samueljohn

@marcindulak can you please give me feedback on the gtk backend in my matplotlib formula?

@adamv the pygtk formula has libffi indirectly in its deps, so I think it's okay.
This is more a matter of how to teach external python packages to use the one and not the other libffi, I think.

Therefore, in my opinion, we can close this. I am open for rants about my matlabformula in my repo :-)

@adamv
Owner

@samueljohn there is a :tex requirement in core now

@adamv
Owner

Closing in core; thanks.

@adamv adamv closed this
@samueljohn

@adamv I will note that down onto my todo list :-)

@marcindulak

It looks to me that there are two problems in the matplotlib formula.
My perspective is the default OSX python:
1. line 69: PYTHONPATH is overwritten so matplotlib does not build with gtk (python -c "import gtk" fails if i add that to the install stage)
2. line 54: i think it should end with 'with-gtk'

@samueljohn
@samueljohn

@marcindulak you mean this line --> https://github.com/samueljohn/homebrew-python/blob/master/matplotlib.rb#L75 ?
True, I have less tested this with system python. Brewed python is fine. But I'll fix that.

To (2): Wow, good catch!

@joellama

@samueljohn I was wondering if you could help me get pygtk up and running on my mac. I've brew installed python, pygtk, gtk and also your version of matplotlib. But if I type

import pygtk
pygtk.require('2.0')
import gtk
from gtk import gdk
import matplotlib
matplotlib.use('GTKAgg') # or 'GTK'
from matplotlib.backends.backend_gtk import FigureCanvasGTK as FigureCanvas

I get an error

from matplotlib.backends._backend_gdk import pixbuf_get_pixels_array
ImportError: No module named _backend_gdk

If you have any suggestions I would be really grateful!

@tdsmith
Owner

Did you install matplotlib with --with-pygtk?

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.