viernes, 13 de diciembre de 2013

Installing pygame on OS X with a Homebrew Python 2.7 install

Solved this surprisingly quickly today thanks in part to this post by Basti am. His post was mostly correct but some parts have changed, so I’m going to document how I got it working. Note that this method will miss out PNG, SCRAP, and PORTMIDI support. Good luck getting those working!
  1. Install Python via Homebrew:
    brew install python
  2. Install pip (because one package manager isn’t enough, right Python?):
    easy_install pip
  3. Install numpy with pip:
    pip install numpy
  4. Install the pre-requesites for pygame with Homebrew:
    brew install sdl sdl_ttf sdl_image sdl_mixer
  5. Download the pygame source. (in my case was: pygame_version) It’s one of the top links. Extract it somewhere and go to that directory in a terminal.
  6. Run python
  7. Fix the Setup file to point to your Homebrew SDL libraries, not OS X ones (which are missing stuff). Change the lines starting SDL, FONT, IMAGE, and MIXER to read:
    SDL = -I/usr/local/include/SDL -L/usr/local/lib -lSDL
    FONT = -lSDL_ttf
    IMAGE = -lSDL_image
    MIXER = -lSDL_mixer

    Below those definitions are lines commented out that enable/disable features. Remove the # to uncomment the ones you want.
  8. Run python install.
  9. Success!