Created
July 20, 2011 11:34
-
-
Save ches/1094799 to your computer and use it in GitHub Desktop.
Install PyGTK via Homebrew and virtualenv
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This LOOKS pretty straightforward, but it took awhile to sort out issues with | |
# py2cairo and pygobject, so I hope I've saved you some time :-) | |
# | |
# This assumes you already subscribe to a nice clean virtualenvwrapper workflow | |
# -- see https://gist.github.com/771394 if you need advice on getting there. | |
# There are some optional dependencies omitted, so if you're going to be doing | |
# heavy development with these libs, you may want to look into them. | |
# | |
# We go to some configure option pains to avoid polluting the system-level | |
# Python, and `brew link`ing Cairo which is keg-only by default. | |
brew install cairo && brew install gtk+ | |
# Have a coffee. Better yet, a meal. | |
mkvirtualenv --no-site-packages pygtk | |
workon pygtk | |
# NOTE: pycairo uses a nonstandard build system, the autotools approach is | |
# officially unsupported. I couldn't get the latest version (1.10.0 at time of | |
# writing) to work with either approach, so I punted and used autotools here | |
# with the next-most-recent version. | |
curl -O http://cairographics.org/releases/py2cairo-1.8.10.tar.gz | |
tar xzf py2cairo-1.8.10.tar.gz && cd py2cairo-1.8.10 | |
./configure --prefix=$VIRTUAL_ENV PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/local/Cellar/cairo/1.10.2/lib/pkgconfig | |
make | |
make install | |
# pygobject | |
# introspection no worky: https://github.com/mxcl/homebrew/pull/4353 | |
curl -O http://ftp.gnome.org/pub/GNOME/sources/pygobject/2.28/pygobject-2.28.6.tar.bz2 | |
tar xf pygobject-2.28.6.tar.bz2 && cd pygobject-2.28.6 | |
./configure --prefix=$VIRTUAL_ENV --disable-introspection | |
make | |
make install | |
# pygtk | |
curl -O http://ftp.gnome.org/pub/GNOME/sources/pygtk/2.24/pygtk-2.24.0.tar.bz2 | |
tar xf pygtk-2.24.0.tar.bz2 && cd pygtk-2.24.0 | |
./configure --prefix=$VIRTUAL_ENV PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$VIRTUAL_ENV/lib/pkgconfig | |
make # moar coffee nao | |
make install | |
# There's a short test script you can run from the REPL here, if you want to | |
# verify that things are working: | |
# | |
# http://faq.pygtk.org/index.py?file=faq21.001.htp&req=show | |
# |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# ~/bin/openxenmanager | |
source ~/.virtualenvs/pygtk/bin/activate | |
cd $HOME/src/python/openxenmanager | |
python window.py | |
deactivate |
I have the same issue :(. How can we take care of this?
File "window.py" asks for python 2.5 and gtk 2.0
open window.py and change the request line of python 2.5 to the version you have...
i have python 2.7 and it worked after that (i hade to change the permission of file and folder to do so ^_^)
brew no longer seems to have a formula for pygtx
[joule] ~ [1.9.3-p194] brew update
Updated Homebrew from 93fe0378 to ce39c3f3.
==> Updated Formulae
adobe-air-sdk doxygen zeromq
[joule] ~ [1.9.3-p194] brew info pygtx
Error: No available formula for pygtx
[joule] ~ [1.9.3-p194]
@jedschneider - surely you want pygtk not pygtx
This may help some people:
Copy these files to /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula
pygobject.rb
---Begin---
class Pygobject < Formula
desc "GLib/GObject/GIO Python bindings for Python 2"
homepage "https://wiki.gnome.org/Projects/PyGObject"
url "https://download.gnome.org/sources/pygobject/2.28/pygobject-2.28.7.tar.xz"
sha256 "bb9d25a3442ca7511385a7c01b057492095c263784ef31231ffe589d83a96a5a"
revision 2
bottle do
cellar :any
sha256 "2dbdab3cd94b10eae121c1e8460085b84c1908b487150e486005dd125f99890d" => :catalina
sha256 "caf4b79e8454b58bb67e73a6f06853d7a410c1fa9b31478c6ac389424ca690bb" => :mojave
sha256 "04550d558f335fd6431ee3c124ba19011ec4284e7584eff343ad6b78483472a5" => :high_sierra
sha256 "fbe187ff2aa28f4e9f57e1e3f8f69df8e69da6406833b3dd9a976f5bae267ee7" => :sierra
end
depends_on "pkg-config" => :build
depends_on "glib"
depends_on "python@2"
patch do
url "https://raw.githubusercontent.com/Homebrew/formula-patches/85fa66a9/pygobject/2.28.7.diff"
sha256 "ada3da43c84410cc165d8547ad3c7809435e09c9e8539882860d97cd1ce922b2"
end
def install
system "./configure", "--disable-dependency-tracking",
"--prefix=#{prefix}",
"--disable-introspection"
system "make", "install"
(lib/"python2.7/site-packages/pygtk.pth").append_lines <<~EOS
#{HOMEBREW_PREFIX}/lib/python2.7/site-packages/gtk-2.0
EOS
end
test do
system Formula["python@2"].opt_bin/"python2.7", "-c", "import dsextras"
end
end
---End---
pygtk.rb
---Begin---
class Pygtk < Formula
desc "GTK+ bindings for Python"
homepage "http://www.pygtk.org/"
url "https://download.gnome.org/sources/pygtk/2.24/pygtk-2.24.0.tar.bz2"
sha256 "cd1c1ea265bd63ff669e92a2d3c2a88eb26bcd9e5363e0f82c896e649f206912"
revision 3
bottle do
cellar :any
rebuild 2
sha256 "12bab3d76587659b38e56867c9b359941803275716896e2936cd3e8029cf5f3f" => :catalina
sha256 "87f89d246e3a779381ec2efdee7ee2b69fda464f38a59dd8e14304435d759419" => :mojave
sha256 "969cef803e110b2767c6d3ade304b92d7f23a02ff7eb4030772b69b52df7c3b2" => :high_sierra
end
depends_on "pkg-config" => :build
depends_on "atk"
depends_on "glib"
depends_on "gtk+"
depends_on "libglade"
depends_on "py2cairo"
depends_on "pygobject"
# Allow building with recent Pango, where some symbols were removed
patch do
url "https://raw.githubusercontent.com/Homebrew/formula-patches/85fa66a9/pygtk/2.24.0.diff"
sha256 "ec480cff20082c41d9015bb7f7fc523c27a2c12a60772b2c55222e4ba0263dde"
end
def install
ENV.append "CFLAGS", "-ObjC"
system "./configure", "--disable-dependency-tracking",
"--prefix=#{prefix}"
system "make", "install"
# Fixing the pkgconfig file to find codegen, because it was moved from
# pygtk to pygobject. But our pkgfiles point into the cellar and in the
# pygtk-cellar there is no pygobject.
inreplace lib/"pkgconfig/pygtk-2.0.pc", "codegendir=${datadir}/pygobject/2.0/codegen", "codegendir=#{HOMEBREW_PREFIX}/share/pygobject/2.0/codegen"
inreplace bin/"pygtk-codegen-2.0", "exec_prefix=${prefix}", "exec_prefix=#{Formula["pygobject"].opt_prefix}"
end
test do
(testpath/"codegen.def").write("(define-enum asdf)")
system "#{bin}/pygtk-codegen-2.0", "codegen.def"
end
end
---End---
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
After doing
brew install pygtk
andexport PYTHONPATH=/usr/local/lib/python2.7/site-packages
I get
:(