Skip to content

Instantly share code, notes, and snippets.

@mehcode
Created August 7, 2013 09:49
Show Gist options
  • Star 21 You must be signed in to star a gist
  • Fork 7 You must be signed in to fork a gist
  • Save mehcode/6172694 to your computer and use it in GitHub Desktop.
Save mehcode/6172694 to your computer and use it in GitHub Desktop.
Install pygtk inside of a virtualenv
# Ensure we're in a virtualenv.
if [ "$VIRTUAL_ENV" == "" ]
then
echo "ERROR: not in a virtual environment."
exit -1
fi
# Setup variables.
CACHE="/tmp/install-pygtk-$$"
# Make temp directory.
mkdir -p $CACHE
# Test for py2cairo.
echo -e "\E[1m * Checking for cairo...\E[0m"
python -c "
try: import cairo; raise SystemExit(0)
except ImportError: raise SystemExit(-1)"
if [ $? == 255 ]
then
echo -e "\E[1m * Installing cairo...\E[0m"
# Fetch, build, and install py2cairo.
( cd $CACHE
curl 'http://cairographics.org/releases/py2cairo-1.10.0.tar.bz2' > "py2cairo.tar.bz2"
tar -xvf py2cairo.tar.bz2
( cd py2cairo*
autoreconf -ivf
./configure --prefix=$VIRTUAL_ENV --disable-dependency-tracking
make
make install
)
)
fi
# Test for gobject.
echo -e "\E[1m * Checking for gobject...\E[0m"
python -c "
try: import gobject; raise SystemExit(0)
except ImportError: raise SystemExit(-1)"
if [ $? == 255 ]
then
echo -e "\E[1m * Installing gobject...\E[0m"
# Fetch, build, and install gobject.
( cd $CACHE
curl 'http://ftp.gnome.org/pub/GNOME/sources/pygobject/2.28/pygobject-2.28.6.tar.bz2' > 'pygobject.tar.bz2'
tar -xvf pygobject.tar.bz2
( cd pygobject*
./configure --prefix=$VIRTUAL_ENV --disable-introspection
make
make install
)
)
fi
# Test for gtk.
echo -e "\E[1m * Checking for gtk...\E[0m"
python -c "
try: import gtk; raise SystemExit(0)
except ImportError: raise SystemExit(-1)" 2&> /dev/null
if [ $? == 255 ]
then
echo -e "\E[1m * Installing gtk...\E[0m"
# Fetch, build, and install gtk.
( cd $CACHE
curl 'https://pypi.python.org/packages/source/P/PyGTK/pygtk-2.24.0.tar.bz2' > 'pygtk.tar.bz2'
tar -xvf pygtk.tar.bz2
( cd pygtk*
./configure --prefix=$VIRTUAL_ENV PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$VIRTUAL_ENV/lib/pkgconfig
make
make install
)
)
fi
@mehcode
Copy link
Author

mehcode commented Aug 7, 2013

Why is that so complicated...

@sque
Copy link

sque commented Mar 8, 2015

It works, Thanks! Really I don't understand either why a pip install cannot do this work on non-windows platforms.

@cshintov
Copy link

i was trying to install it in virtual environment..
my installation stopped at this ..
checking for GLIB - version >= 2.8.0... no
*** Could not run GLIB test program, checking why...
*** The test program failed to compile or link. See the file config.log for the
*** exact error that occured. This usually means GLIB is incorrectly installed.
configure: error: gobject is required to build pygtk?

what should i do?

@nromashchenko
Copy link

You saved my life.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment