Install pygame using pip on Ubuntu 11.04 Natty

It’s probably easier just to install the (up-to-date) package from Ubuntu. To get it to work with pip, you need to install (for me) these packages:

sudo aptitude install libmikmod2 libportmidi0 libportmidi-dev libsdl1.2-dev libsdl-image1.2 libsdl-image1.2-dev libsdl-mixer1.2 libsdl-mixer1.2-dev libsdl-ttf2.0-0 libsdl-ttf2.0-dev libsmpeg0 libsmpeg-dev libv4l-dev python-dev

Make pygame-pip.diff look like this patch:

diff -ur pygame-1.9.1release/config_unix.py pygame-1.9.1release-patched/config_unix.py
--- pygame-1.9.1release/config_unix.py  2011-07-03 21:34:58.291201138 +0200
+++ pygame-1.9.1release-patched/config_unix.py  2011-07-03 21:49:20.035474295 +0200
@@ -17,7 +17,7 @@
 #these get prefixes with '/usr' and '/usr/local' or the $LOCALBASE
 origincdirs = ['/include', '/include/SDL', '/include/SDL',
                '/include/smpeg' ]
-origlibdirs = ['/lib','/lib64','/X11R6/lib']
+origlibdirs = ['/lib','/lib64','/X11R6/lib','/lib/i386-linux-gnu']

 def confirm(message):
     "ask a yes/no question, return result"
Only in pygame-1.9.1release-patched: config_unix.py~
diff -ur pygame-1.9.1release/src/camera.h pygame-1.9.1release-patched/src/camera.h
--- pygame-1.9.1release/src/camera.h    2011-07-03 21:34:58.291201138 +0200
+++ pygame-1.9.1release-patched/src/camera.h    2011-07-03 21:02:01.453398517 +0200
@@ -39,7 +39,7 @@

     #include           /* for videodev2.h */

-    #include 
+    #include 
     #include 
 #endif

Then download, patch and install:

wget http://www.pygame.org/ftp/pygame-1.9.1release.tar.gz
tar -zxf pygame-1.9.1release.tar.gz
patch -p0 < pygame-pip.diff
pip install pygame-1.9.1release.tar.gz/ # note slash is important

Several places suggest that NumPy is required too, but I didn’t need it (yet).

2 responses
Posterous diff formatting is broken, seems to cut off #include\s+\w+ after the #include
diff -ur pygame-1.9.1release/config_unix.py pygame-1.9.1release-patched/config_unix.py
--- pygame-1.9.1release/config_unix.py 2011-07-03 21:34:58.291201138 +0200
+++ pygame-1.9.1release-patched/config_unix.py 2011-07-03 21:49:20.035474295 +0200
@@ -17,7 +17,7 @@
#these get prefixes with '/usr' and '/usr/local' or the $LOCALBASE
origincdirs = ['/include', '/include/SDL', '/include/SDL',
'/include/smpeg' ]
-origlibdirs = ['/lib','/lib64','/X11R6/lib']
+origlibdirs = ['/lib','/lib64','/X11R6/lib','/lib/i386-linux-gnu']

def confirm(message):
"ask a yes/no question, return result"
Only in pygame-1.9.1release-patched: config_unix.py~
diff -ur pygame-1.9.1release/src/camera.h pygame-1.9.1release-patched/src/camera.h
--- pygame-1.9.1release/src/camera.h 2011-07-03 21:34:58.291201138 +0200
+++ pygame-1.9.1release-patched/src/camera.h 2011-07-03 21:02:01.453398517 +0200
@@ -39,7 +39,7 @@

#include <asm /> /* for videodev2.h */

- #include <linux />
+ #include <libv4l1-videodev>
#include <linux />
#endif