Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to I get Kivy 1.9.1 or 1.9.2 to use SDL2 instead of pygame on OSX 10.12.2?

Tags:

python

kivy

Trying to get Kivy to use SDL2 and not pygame, on OSX 10.12.2 under python 2.7.13 installed by brew. I've run the following to install dependencies. They appear to be installed fine, as 'brew doctor' returns clean.

brew install sdl2 sdl2_image sdl2_ttf sdl2_mixer gstreamer
pip install -I Cython==0.23

Then I've tried both 1.9.2-dev0 and 1.9.1 version of Kivy, compiling from source, with an attempt to use SDL. I've also tried pip install kivy as well, rather than the latest code from the repo, and none of these attempts get Kivy to recognize SDL2.

git clone http://github.com/kivy/kivy
cd kivy
USE_SDL2=1 make force
USE_OSX_FRAMEWORKS=0 sudo pip install -e kivy

bash-3.2$ KIVY_WINDOW=sdl2 KIVY_IMAGE=sdl2 KIVY_CLIPBOARD=sdl2 KIVY_TEXT=sdl2 python main.py
[INFO   ] [Logger      ] Record log in /Users/dancaron/.kivy/logs/kivy_17-01-23_107.txt
[INFO   ] [Kivy        ] v1.9.2-dev0
[INFO   ] [Python      ] v2.7.13 (default, Jan 23 2017, 19:04:34)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)]
[INFO   ] [Factory     ] 193 symbols loaded
[INFO   ] [Image       ] Providers:  (img_imageio, img_tex, img_dds, img_pygame, img_ffpyplayer, img_pil, img_gif ignored)
[CRITICAL] [App         ] Unable to get any Image provider, abort.

How do I get Kivy to use SDL2?

like image 568
devdrc Avatar asked Jan 24 '17 04:01

devdrc


1 Answers

I was able to get SDL2 working with Kivy 1.9.2 on OSX 10.12.2 using the following procedure. This assumes a brew installed python 2.7, and brew installed SDL2.

1) Download Kivy source (into /usr/local/lib/python2.7/site-packages directory)

git clone https://github.com/kivy/kivy
cd kivy

2) Set environmental variables to tell Kivy where to find brewed SDL2 libs, not to use OSX frameworks path, and to actually use SDL2, and build Kivy.

KIVY_SDL2_PATH=/usr/local/lib USE_OSX_FRAMEWORKS=0 USE_SDL2=1 make force

Now, running your main script, you should see Window provider is SDL2.

bash-3.2$ python main.py
[WARNING] [Config      ] Older configuration version detected (14 instead of 17)
[WARNING] [Config      ] Upgrading configuration in progress.
[INFO   ] [Kivy        ] v1.9.2-dev0
[INFO   ] [Python      ] v2.7.13 (default, Jan 23 2017, 19:04:34)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)]
[INFO   ] [Factory     ] 193 symbols loaded
[INFO   ] [Image       ] Providers: img_tex, img_imageio, img_dds, img_sdl2, img_pil, img_gif (img_ffpyplayer ignored)
[INFO   ] [OSC         ] using <multiprocessing> for socket
[INFO   ] [Window      ] Provider: sdl2

Using SDL2 over pygame provides retina support, and fixes issues like black screen on window resize.

like image 153
devdrc Avatar answered Nov 18 '22 04:11

devdrc