Skip to content

Instantly share code, notes, and snippets.

@jegger
Last active November 9, 2020 22:58
Show Gist options
  • Star 14 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save jegger/9549865 to your computer and use it in GitHub Desktop.
Save jegger/9549865 to your computer and use it in GitHub Desktop.
Install kivy into a virtualenv on Mac 10.9 Mavericks
# Inspired by:
# - https://gist.github.com/goldsmith/7262122
# - https://gist.github.com/brousch/6589386
#### Some hints ####
# Currently kivy apps only work on monitor 1 (multiple monitor setup)
# You have to place the terminal which runs kivy on the monitor 1 or make the app fullscreen.
# Make sure you have the "command line tools" for mavericks installed!
# (xcode-select --install)
# Install brew
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
# Install requiered packages
brew install mercurial sdl sdl_image sdl_mixer sdl_ttf portmidi
# Install smpeg package via another brew tap
brew tap homebrew/headonly
brew install smpeg --HEAD
# Create virtualenv
sudo pip install virtualenv
virtualenv venv
# Install cython
export CFLAGS="-arch i386 -arch x86_64"
export FFLAGS="-m32 -m64"
export LDFLAGS="-Wall -undefined dynamic_lookup -bundle -arch i386 -arch x86_64"
export CC=gcc
export CXX="g++ -arch i386 -arch x86_64"
venv/bin/pip install cython==0.21.2
rm -rf cython
# Install pygame
hg clone https://bitbucket.org/pygame/pygame
cd pygame
../venv/bin/python setup.py build
../venv/bin/python setup.py install
cd ..
rm -rf pygame
# Install kivy
git clone https://github.com/kivy/kivy
cd kivy
../venv/bin/python setup.py install
cd ..
rm -rf kivy
@Ecno92
Copy link

Ecno92 commented Nov 19, 2014

Thanks for this script. With use of your suggestions we could install Kivy successfully on a OSX system.

@jacobvalenta
Copy link

L23: I used brew mercurial
L35: I had to use cython==0.21.2
L49: I had to use make force

@jegger
Copy link
Author

jegger commented May 10, 2015

@jacobvalenta thanks, I updated the gist. But make force was not necessary for me.

@jarryd
Copy link

jarryd commented Aug 5, 2015

Thanks! This helped a lot

@KunjanChauhan
Copy link

This could be a really dumb question, but why use rm -rf (remove symlinks) after installing cython, pygame and kivy? Also at L32 is there a need to specify a specific version of cython - why not let pip install the latest version? Other than these questions, thank you for this very handy set of instructions. Thanks for any answers.

@jegger
Copy link
Author

jegger commented Aug 23, 2016

@kkc15 -rf is for removing the hole directory (not symlinks). I just remove them as they are not needed anymore (as they are in the virtualenv now). Regarding the Cython version: I follow the general rule to specify a version of a package, if possible, as a further version may break the build process (you never know, but you know it worked with the one specified). Cython is a special case anyway as it behaves sometimes unpredictable...

@Benjamin-Kilpatrick
Copy link

Works Great! although it made me use Cython version 0.27.3 and used brew install smpeg instead of brew install smpeg --HEAD

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