comparison setup.py @ 562:991c817d1e6b

Fail when libepoxy can’t be found, pass --disable-opengl to skip the OpenGL backend compilation.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Thu, 05 Jun 2014 18:48:24 +0200
parents 98380e4a0ee5
children ab0a5580bc40
comparison
equal deleted inserted replaced
561:bafe6361c0af 562:991c817d1e6b
23 extension_names = [] 23 extension_names = []
24 extensions = [] 24 extensions = []
25 25
26 debug = False # True to generate HTML annotations and display infered types. 26 debug = False # True to generate HTML annotations and display infered types.
27 anmviewer = False # It’s currently broken anyway. 27 anmviewer = False # It’s currently broken anyway.
28 use_opengl = True # Compile the OpenGL backend if True
29 nthreads = 4 # How many processes to use for Cython compilation. 28 nthreads = 4 # How many processes to use for Cython compilation.
30 29
31 30
32 # Hack to prevent `setup.py clean` from compiling Cython files. 31 # Hack to prevent `setup.py clean` from compiling Cython files.
33 if sys.argv[1] == 'clean': 32 if sys.argv[1] == 'clean':
38 if filename.endswith('.c'): 37 if filename.endswith('.c'):
39 os.unlink(os.path.join(directory, filename)) 38 os.unlink(os.path.join(directory, filename))
40 sys.exit(0) 39 sys.exit(0)
41 40
42 41
42 try:
43 sys.argv.remove('--disable-opengl')
44 except ValueError:
45 use_opengl = True
46 else:
47 use_opengl = False
48
49
50 # Check for epoxy.pc, and don’t compile the OpenGL backend if it isn’t present.
51 if use_opengl:
52 try:
53 check_output([COMMAND] + GL_LIBRARIES)
54 except CalledProcessError:
55 print('libepoxy not found. Please install it or pass --disable-opengl')
56 sys.exit(1)
57 except OSError:
58 # Assume GL is here if we can’t use pkg-config, but display a warning.
59 print('You don’t seem to have pkg-config installed. Please get a copy '
60 'from http://pkg-config.freedesktop.org/ and install it.\n'
61 'Continuing without it, assuming every dependency is available.')
62
63
43 default_libs = { 64 default_libs = {
44 'sdl2': '-lSDL2', 65 'sdl2': '-lSDL2',
45 'SDL2_image': '-lSDL2_image', 66 'SDL2_image': '-lSDL2_image',
46 'SDL2_mixer': '-lSDL2_mixer', 67 'SDL2_mixer': '-lSDL2_mixer',
47 'SDL2_ttf': '-lSDL2_ttf', 68 'SDL2_ttf': '-lSDL2_ttf',
48 'epoxy': '-lepoxy' 69 'epoxy': '-lepoxy'
49 } 70 }
50
51
52 # Check for epoxy.pc, and don’t compile the OpenGL backend if it isn’t present.
53 try:
54 check_output([COMMAND] + GL_LIBRARIES)
55 except CalledProcessError:
56 use_opengl = False
57 except OSError:
58 # Assume GL is here if we can’t use pkg-config, but display a warning.
59 print('You don’t seem to have pkg-config installed. Please get a copy '
60 'from http://pkg-config.freedesktop.org/ and install it.\n'
61 'Continuing without it, assuming every dependency is available.')
62 71
63 72
64 def get_arguments(arg, libraries): 73 def get_arguments(arg, libraries):
65 try: 74 try:
66 return check_output([COMMAND, arg] + libraries).split() 75 return check_output([COMMAND, arg] + libraries).split()