Skip to content
This repository has been archived by the owner on Jul 4, 2023. It is now read-only.

pygtk does not install correctly #16891

Closed
marcindulak opened this issue Jan 4, 2013 · 22 comments
Closed

pygtk does not install correctly #16891

marcindulak opened this issue Jan 4, 2013 · 22 comments
Labels

Comments

@marcindulak
Copy link
Contributor

This is problem reported originally at https://github.com/Homebrew/homebrew-science/issues/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")

@samueljohn
Copy link
Contributor

So there is the chance for an easy fix?

@marcindulak
Copy link
Contributor Author

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
Copy link
Contributor

adamv commented Jan 5, 2013

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

@samueljohn
Copy link
Contributor

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

@marcindulak
Copy link
Contributor Author

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
Copy link
Contributor

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

@marcindulak
Copy link
Contributor Author

Yes it does

@samueljohn
Copy link
Contributor

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
Copy link
Contributor Author

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
Copy link
Contributor

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
Copy link
Contributor Author

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
Copy link
Contributor

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

@samueljohn
Copy link
Contributor

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
Copy link
Contributor

@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
Copy link
Contributor

adamv commented Jan 14, 2013

@samueljohn there is a :tex requirement in core now

@adamv
Copy link
Contributor

adamv commented Jan 14, 2013

Closing in core; thanks.

@adamv adamv closed this as completed Jan 14, 2013
@samueljohn
Copy link
Contributor

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

@marcindulak
Copy link
Contributor Author

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
Copy link
Contributor

Thanks for your feedback. Much appreciated. Will fix soonish!

@samueljohn
Copy link
Contributor

@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
Copy link

@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
Copy link
Contributor

tdsmith commented Jul 20, 2015

Did you install matplotlib with --with-pygtk?

@Homebrew Homebrew locked and limited conversation to collaborators Feb 16, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

5 participants