2012-02-23 23:25:20 +00:00
|
|
|
#
|
|
|
|
# Kivy - Crossplatform NUI toolkit
|
|
|
|
# http://kivy.org/
|
|
|
|
#
|
2015-02-21 21:15:08 +00:00
|
|
|
from __future__ import print_function
|
2012-02-23 23:25:20 +00:00
|
|
|
|
2012-01-29 16:23:42 +00:00
|
|
|
import sys
|
2013-07-04 14:25:06 +00:00
|
|
|
|
2012-02-23 23:25:20 +00:00
|
|
|
from copy import deepcopy
|
2013-07-04 14:25:06 +00:00
|
|
|
import os
|
2014-08-23 11:45:04 +00:00
|
|
|
from os.path import join, dirname, sep, exists, basename
|
2011-02-01 10:21:54 +00:00
|
|
|
from os import walk, environ
|
2011-02-19 00:08:40 +00:00
|
|
|
from distutils.core import setup
|
|
|
|
from distutils.extension import Extension
|
2015-02-17 04:24:57 +00:00
|
|
|
from distutils.version import LooseVersion
|
2014-08-23 11:45:04 +00:00
|
|
|
from collections import OrderedDict
|
2015-02-21 21:15:08 +00:00
|
|
|
from time import sleep
|
2010-11-03 21:05:03 +00:00
|
|
|
|
2015-02-17 04:24:57 +00:00
|
|
|
|
2015-02-26 23:41:40 +00:00
|
|
|
if sys.version > '3':
|
|
|
|
PY3 = True
|
|
|
|
else:
|
|
|
|
PY3 = False
|
|
|
|
|
|
|
|
if PY3: # fix error with py3's LooseVersion comparisons
|
|
|
|
def ver_equal(self, other):
|
2015-03-04 21:38:17 +00:00
|
|
|
return self.version == other
|
2015-02-26 23:41:40 +00:00
|
|
|
|
|
|
|
LooseVersion.__eq__ = ver_equal
|
|
|
|
|
|
|
|
|
2015-02-21 22:29:44 +00:00
|
|
|
MIN_CYTHON_STRING = '0.20'
|
2015-02-17 04:24:57 +00:00
|
|
|
MIN_CYTHON_VERSION = LooseVersion(MIN_CYTHON_STRING)
|
2015-02-21 21:22:28 +00:00
|
|
|
MAX_CYTHON_STRING = '0.21.2'
|
2015-02-17 04:24:57 +00:00
|
|
|
MAX_CYTHON_VERSION = LooseVersion(MAX_CYTHON_STRING)
|
2015-02-21 21:15:08 +00:00
|
|
|
CYTHON_UNSUPPORTED = (
|
|
|
|
LooseVersion('0.22'),
|
2015-02-26 23:15:08 +00:00
|
|
|
LooseVersion('0.22.beta0'),
|
|
|
|
LooseVersion('0.22.alpha0'),
|
2015-02-21 21:15:08 +00:00
|
|
|
)
|
2015-02-17 04:24:57 +00:00
|
|
|
|
2012-12-28 15:40:37 +00:00
|
|
|
|
2014-08-23 11:45:04 +00:00
|
|
|
def getoutput(cmd):
|
|
|
|
import subprocess
|
2015-01-30 02:25:40 +00:00
|
|
|
p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE,
|
|
|
|
stderr=subprocess.PIPE)
|
2015-01-23 15:33:36 +00:00
|
|
|
p.wait()
|
2015-01-30 02:25:40 +00:00
|
|
|
if p.returncode: # if not returncode == 0
|
|
|
|
print('WARNING: A problem occured while running {0} (code {1})\n'
|
|
|
|
.format(cmd, p.returncode))
|
2015-01-23 15:56:41 +00:00
|
|
|
stderr_content = p.stderr.read()
|
|
|
|
if stderr_content:
|
|
|
|
print('{0}\n'.format(stderr_content))
|
2015-01-23 15:33:36 +00:00
|
|
|
return ""
|
|
|
|
return p.stdout.read()
|
2014-08-23 11:45:04 +00:00
|
|
|
|
|
|
|
|
|
|
|
def pkgconfig(*packages, **kw):
|
|
|
|
flag_map = {'-I': 'include_dirs', '-L': 'library_dirs', '-l': 'libraries'}
|
|
|
|
cmd = 'pkg-config --libs --cflags {}'.format(' '.join(packages))
|
2015-01-23 15:33:36 +00:00
|
|
|
results = getoutput(cmd).split()
|
|
|
|
for token in results:
|
2014-08-23 11:45:04 +00:00
|
|
|
ext = token[:2].decode('utf-8')
|
|
|
|
flag = flag_map.get(ext)
|
|
|
|
if not flag:
|
|
|
|
continue
|
|
|
|
kw.setdefault(flag, []).append(token[2:].decode('utf-8'))
|
|
|
|
return kw
|
|
|
|
|
|
|
|
|
2013-05-27 15:04:18 +00:00
|
|
|
# -----------------------------------------------------------------------------
|
|
|
|
# Determine on which platform we are
|
|
|
|
|
|
|
|
platform = sys.platform
|
|
|
|
|
2014-08-23 11:45:04 +00:00
|
|
|
# Detect 32/64bit for OSX (http://stackoverflow.com/a/1405971/798575)
|
|
|
|
if sys.platform == 'darwin':
|
|
|
|
if sys.maxsize > 2 ** 32:
|
|
|
|
osx_arch = 'x86_64'
|
|
|
|
else:
|
|
|
|
osx_arch = 'i386'
|
|
|
|
|
2013-05-27 15:04:18 +00:00
|
|
|
# Detect Python for android project (http://github.com/kivy/python-for-android)
|
|
|
|
ndkplatform = environ.get('NDKPLATFORM')
|
|
|
|
if ndkplatform is not None and environ.get('LIBLINK'):
|
|
|
|
platform = 'android'
|
|
|
|
kivy_ios_root = environ.get('KIVYIOSROOT', None)
|
|
|
|
if kivy_ios_root is not None:
|
|
|
|
platform = 'ios'
|
|
|
|
if exists('/opt/vc/include/bcm_host.h'):
|
|
|
|
platform = 'rpi'
|
|
|
|
|
2012-02-23 23:25:20 +00:00
|
|
|
# -----------------------------------------------------------------------------
|
|
|
|
# Detect options
|
|
|
|
#
|
2014-08-23 11:45:04 +00:00
|
|
|
c_options = OrderedDict()
|
|
|
|
c_options['use_rpi'] = platform == 'rpi'
|
|
|
|
c_options['use_opengl_es2'] = None
|
|
|
|
c_options['use_opengl_debug'] = False
|
|
|
|
c_options['use_glew'] = False
|
|
|
|
c_options['use_sdl'] = False
|
2015-01-18 00:32:16 +00:00
|
|
|
c_options['use_sdl2'] = None
|
2014-08-23 11:45:04 +00:00
|
|
|
c_options['use_ios'] = False
|
|
|
|
c_options['use_mesagl'] = False
|
|
|
|
c_options['use_x11'] = False
|
2015-01-23 08:45:06 +00:00
|
|
|
c_options['use_gstreamer'] = None
|
2014-08-23 11:45:04 +00:00
|
|
|
c_options['use_avfoundation'] = platform == 'darwin'
|
2015-01-07 18:53:39 +00:00
|
|
|
c_options['use_osx_frameworks'] = platform == 'darwin'
|
2012-02-23 23:25:20 +00:00
|
|
|
|
2012-02-24 00:51:31 +00:00
|
|
|
# now check if environ is changing the default values
|
2012-12-28 15:11:20 +00:00
|
|
|
for key in list(c_options.keys()):
|
2012-02-24 00:51:31 +00:00
|
|
|
ukey = key.upper()
|
|
|
|
if ukey in environ:
|
|
|
|
value = bool(int(environ[ukey]))
|
2012-12-28 17:55:22 +00:00
|
|
|
print('Environ change {0} -> {1}'.format(key, value))
|
2012-02-24 00:51:31 +00:00
|
|
|
c_options[key] = value
|
|
|
|
|
2012-02-23 23:25:20 +00:00
|
|
|
# -----------------------------------------------------------------------------
|
|
|
|
# Cython check
|
2012-12-16 15:05:25 +00:00
|
|
|
# on python-for-android and kivy-ios, cython usage is external
|
2015-02-21 21:15:08 +00:00
|
|
|
|
|
|
|
cython_unsupported_append = '''
|
|
|
|
|
|
|
|
Please note that the following versions of Cython are not supported
|
|
|
|
at all: {}
|
|
|
|
'''.format(', '.join(map(str, CYTHON_UNSUPPORTED)))
|
|
|
|
|
|
|
|
cython_min = '''\
|
|
|
|
This version of Cython is not compatible with Kivy. Please upgrade to
|
|
|
|
at least version {0}, preferably the newest supported version {1}.
|
|
|
|
|
|
|
|
If your platform provides a Cython package, make sure you have upgraded
|
|
|
|
to the newest version. If the newest version available is still too low,
|
|
|
|
please remove it and install the newest supported Cython via pip:
|
|
|
|
|
|
|
|
pip install -I Cython=={1}{2}\
|
|
|
|
'''.format(MIN_CYTHON_STRING, MAX_CYTHON_STRING,
|
|
|
|
cython_unsupported_append if CYTHON_UNSUPPORTED else '')
|
|
|
|
|
|
|
|
cython_max = '''\
|
|
|
|
This version of Cython is untested with Kivy. While this version may
|
|
|
|
work perfectly fine, it is possible that you may experience issues. If
|
|
|
|
you do have issues, please downgrade to a supported version. It is
|
|
|
|
best to use the newest supported version, {1}, but the minimum
|
|
|
|
supported version is {0}.
|
|
|
|
|
|
|
|
If your platform provides a Cython package, check if you can downgrade
|
|
|
|
to a supported version. Otherwise, uninstall the platform package and
|
|
|
|
install Cython via pip:
|
|
|
|
|
|
|
|
pip install -I Cython=={1}{2}\
|
|
|
|
'''.format(MIN_CYTHON_STRING, MAX_CYTHON_STRING,
|
|
|
|
cython_unsupported_append if CYTHON_UNSUPPORTED else '')
|
|
|
|
|
|
|
|
cython_unsupported = '''\
|
|
|
|
This version of Cython suffers from known bugs and is unsupported.
|
|
|
|
Please install the newest supported version, {1}, if possible, but
|
|
|
|
the minimum supported version is {0}.
|
|
|
|
|
|
|
|
If your platform provides a Cython package, check if you can install
|
|
|
|
a supported version. Otherwise, uninstall the platform package and
|
|
|
|
install Cython via pip:
|
|
|
|
|
|
|
|
pip install -I Cython=={1}{2}\
|
|
|
|
'''.format(MIN_CYTHON_STRING, MAX_CYTHON_STRING,
|
|
|
|
cython_unsupported_append)
|
|
|
|
|
2012-12-16 15:05:25 +00:00
|
|
|
have_cython = False
|
|
|
|
if platform in ('ios', 'android'):
|
2012-12-28 15:11:20 +00:00
|
|
|
print('\nCython check avoided.')
|
2012-12-16 12:47:32 +00:00
|
|
|
else:
|
|
|
|
try:
|
|
|
|
# check for cython
|
|
|
|
from Cython.Distutils import build_ext
|
|
|
|
have_cython = True
|
2015-01-26 16:47:32 +00:00
|
|
|
import Cython
|
|
|
|
cy_version_str = Cython.__version__
|
2015-02-17 04:24:57 +00:00
|
|
|
cy_ver = LooseVersion(cy_version_str)
|
2015-01-26 16:47:32 +00:00
|
|
|
print('\nDetected Cython version {}'.format(cy_version_str))
|
2015-02-17 04:24:57 +00:00
|
|
|
if cy_ver < MIN_CYTHON_VERSION:
|
2015-02-21 21:15:08 +00:00
|
|
|
print(cython_min)
|
|
|
|
raise ImportError('Incompatible Cython Version')
|
|
|
|
if cy_ver in CYTHON_UNSUPPORTED:
|
|
|
|
print(cython_unsupported)
|
2015-01-26 16:47:32 +00:00
|
|
|
raise ImportError('Incompatible Cython Version')
|
2015-02-17 04:24:57 +00:00
|
|
|
if cy_ver > MAX_CYTHON_VERSION:
|
2015-02-21 21:15:08 +00:00
|
|
|
print(cython_max)
|
|
|
|
sleep(1)
|
2012-12-16 12:47:32 +00:00
|
|
|
except ImportError:
|
2012-12-28 15:11:20 +00:00
|
|
|
print('\nCython is missing, its required for compiling kivy !\n\n')
|
2012-12-16 15:05:25 +00:00
|
|
|
raise
|
|
|
|
|
|
|
|
if not have_cython:
|
|
|
|
from distutils.command.build_ext import build_ext
|
2011-04-23 16:08:31 +00:00
|
|
|
|
2012-02-23 23:25:20 +00:00
|
|
|
# -----------------------------------------------------------------------------
|
|
|
|
# Setup classes
|
2012-06-16 15:46:48 +00:00
|
|
|
|
2015-01-18 00:30:14 +00:00
|
|
|
# the build path where kivy is being compiled
|
2015-01-28 19:45:24 +00:00
|
|
|
src_path = build_path = dirname(__file__)
|
2015-01-18 00:30:14 +00:00
|
|
|
|
2014-08-23 11:45:04 +00:00
|
|
|
|
2012-02-23 23:25:20 +00:00
|
|
|
class KivyBuildExt(build_ext):
|
|
|
|
|
2015-01-18 00:30:14 +00:00
|
|
|
def finalize_options(self):
|
|
|
|
retval = build_ext.finalize_options(self)
|
|
|
|
global build_path
|
|
|
|
if (self.build_lib is not None and exists(self.build_lib) and
|
|
|
|
not self.inplace):
|
|
|
|
build_path = self.build_lib
|
|
|
|
return retval
|
|
|
|
|
2012-02-23 23:25:20 +00:00
|
|
|
def build_extensions(self):
|
2015-01-18 00:32:16 +00:00
|
|
|
# build files
|
2015-01-28 19:45:24 +00:00
|
|
|
config_h_fn = ('graphics', 'config.h')
|
|
|
|
config_pxi_fn = ('graphics', 'config.pxi')
|
|
|
|
config_py_fn = ('setupconfig.py', )
|
2015-01-18 00:32:16 +00:00
|
|
|
|
|
|
|
# generate headers
|
|
|
|
config_h = '// Autogenerated file for Kivy C configuration\n'
|
|
|
|
config_h += '#define __PY3 {0}\n'.format(int(PY3))
|
|
|
|
config_pxi = '# Autogenerated file for Kivy Cython configuration\n'
|
|
|
|
config_pxi += 'DEF PY3 = {0}\n'.format(int(PY3))
|
|
|
|
config_py = '# Autogenerated file for Kivy configuration\n'
|
|
|
|
config_py += 'PY3 = {0}\n'.format(int(PY3))
|
2015-02-22 05:12:17 +00:00
|
|
|
config_py += 'CYTHON_MIN = {0}\nCYTHON_MAX = {1}\n'.format(
|
|
|
|
repr(MIN_CYTHON_STRING), repr(MAX_CYTHON_STRING))
|
|
|
|
config_py += 'CYTHON_BAD = {0}\n'.format(repr(', '.join(map(
|
|
|
|
str, CYTHON_UNSUPPORTED))))
|
2015-01-18 00:32:16 +00:00
|
|
|
|
|
|
|
# generate content
|
2012-12-28 15:11:20 +00:00
|
|
|
print('Build configuration is:')
|
|
|
|
for opt, value in c_options.items():
|
2015-01-18 00:32:16 +00:00
|
|
|
value = int(bool(value))
|
2012-12-28 17:55:22 +00:00
|
|
|
print(' * {0} = {1}'.format(opt, value))
|
2015-01-18 00:32:16 +00:00
|
|
|
opt = opt.upper()
|
|
|
|
config_h += '#define __{0} {1}\n'.format(opt, value)
|
|
|
|
config_pxi += 'DEF {0} = {1}\n'.format(opt, value)
|
|
|
|
config_py += '{0} = {1}\n'.format(opt, value)
|
2014-06-16 16:57:01 +00:00
|
|
|
debug = bool(self.debug)
|
|
|
|
print(' * debug = {0}'.format(debug))
|
2015-01-18 00:30:14 +00:00
|
|
|
|
2015-01-18 00:32:16 +00:00
|
|
|
config_pxi += 'DEF DEBUG = {0}\n'.format(debug)
|
|
|
|
config_py += 'DEBUG = {0}\n'.format(debug)
|
2015-01-18 00:30:14 +00:00
|
|
|
for fn, content in (
|
|
|
|
(config_h_fn, config_h), (config_pxi_fn, config_pxi),
|
|
|
|
(config_py_fn, config_py)):
|
2015-01-28 19:45:24 +00:00
|
|
|
build_fn = expand(build_path, *fn)
|
|
|
|
if self.update_if_changed(build_fn, content):
|
|
|
|
print('Updated {}'.format(build_fn))
|
|
|
|
src_fn = expand(src_path, *fn)
|
|
|
|
if src_fn != build_fn and self.update_if_changed(src_fn, content):
|
|
|
|
print('Updated {}'.format(src_fn))
|
2015-01-07 18:53:39 +00:00
|
|
|
|
2014-08-23 11:45:04 +00:00
|
|
|
c = self.compiler.compiler_type
|
|
|
|
print('Detected compiler is {}'.format(c))
|
|
|
|
if c != 'msvc':
|
|
|
|
for e in self.extensions:
|
|
|
|
e.extra_link_args += ['-lm']
|
2012-02-23 23:25:20 +00:00
|
|
|
|
|
|
|
build_ext.build_extensions(self)
|
|
|
|
|
2014-08-23 11:45:04 +00:00
|
|
|
def update_if_changed(self, fn, content):
|
|
|
|
need_update = True
|
|
|
|
if exists(fn):
|
|
|
|
with open(fn) as fd:
|
|
|
|
need_update = fd.read() != content
|
|
|
|
if need_update:
|
|
|
|
with open(fn, 'w') as fd:
|
|
|
|
fd.write(content)
|
2015-01-18 00:30:14 +00:00
|
|
|
return need_update
|
2014-08-23 11:45:04 +00:00
|
|
|
|
2012-02-23 23:25:20 +00:00
|
|
|
|
|
|
|
# -----------------------------------------------------------------------------
|
2010-11-03 21:05:03 +00:00
|
|
|
# extract version (simulate doc generation, kivy will be not imported)
|
2011-02-01 10:21:54 +00:00
|
|
|
environ['KIVY_DOC_INCLUDE'] = '1'
|
2010-11-03 21:05:03 +00:00
|
|
|
import kivy
|
|
|
|
|
|
|
|
# extra build commands go in the cmdclass dict {'command-name': CommandClass}
|
2011-01-20 17:17:29 +00:00
|
|
|
# see tools.packaging.{platform}.build.py for custom build commands for
|
2015-02-12 05:20:46 +00:00
|
|
|
# portable packages. Also e.g. we use build_ext command from cython if its
|
2011-01-20 17:17:29 +00:00
|
|
|
# installed for c extensions.
|
2012-02-23 23:25:20 +00:00
|
|
|
from kivy.tools.packaging.factory import FactoryBuild
|
|
|
|
cmdclass = {
|
|
|
|
'build_factory': FactoryBuild,
|
2012-06-16 15:46:48 +00:00
|
|
|
'build_ext': KivyBuildExt}
|
2010-11-03 21:05:03 +00:00
|
|
|
|
2011-04-15 12:37:52 +00:00
|
|
|
try:
|
|
|
|
# add build rules for portable packages to cmdclass
|
|
|
|
if platform == 'win32':
|
|
|
|
from kivy.tools.packaging.win32.build import WindowsPortableBuild
|
|
|
|
cmdclass['build_portable'] = WindowsPortableBuild
|
|
|
|
elif platform == 'darwin':
|
|
|
|
from kivy.tools.packaging.osx.build import OSXPortableBuild
|
|
|
|
cmdclass['build_portable'] = OSXPortableBuild
|
|
|
|
except ImportError:
|
2012-12-28 15:11:20 +00:00
|
|
|
print('User distribution detected, avoid portable command.')
|
2010-11-03 21:05:03 +00:00
|
|
|
|
2011-02-01 19:46:39 +00:00
|
|
|
# Detect which opengl version headers to use
|
2013-03-19 18:14:27 +00:00
|
|
|
if platform in ('android', 'darwin', 'ios', 'rpi'):
|
2014-08-23 11:45:04 +00:00
|
|
|
c_options['use_opengl_es2'] = True
|
2012-01-10 13:39:21 +00:00
|
|
|
elif platform == 'win32':
|
2012-12-28 15:11:20 +00:00
|
|
|
print('Windows platform detected, force GLEW usage.')
|
2011-01-25 16:41:09 +00:00
|
|
|
c_options['use_glew'] = True
|
2014-08-23 11:45:04 +00:00
|
|
|
c_options['use_opengl_es2'] = False
|
2011-02-01 19:46:39 +00:00
|
|
|
else:
|
2014-08-23 11:45:04 +00:00
|
|
|
if c_options['use_opengl_es2'] is None:
|
|
|
|
GLES = environ.get('GRAPHICS') == 'GLES'
|
|
|
|
OPENGL = environ.get('GRAPHICS') == 'OPENGL'
|
|
|
|
if GLES:
|
|
|
|
c_options['use_opengl_es2'] = True
|
|
|
|
elif OPENGL:
|
|
|
|
c_options['use_opengl_es2'] = False
|
|
|
|
else:
|
|
|
|
# auto detection of GLES headers
|
|
|
|
default_header_dirs = ['/usr/include', '/usr/local/include']
|
|
|
|
c_options['use_opengl_es2'] = False
|
|
|
|
for hdir in default_header_dirs:
|
|
|
|
filename = join(hdir, 'GLES2', 'gl2.h')
|
|
|
|
if exists(filename):
|
|
|
|
c_options['use_opengl_es2'] = True
|
|
|
|
print('NOTE: Found GLES 2.0 headers at {0}'.format(
|
|
|
|
filename))
|
|
|
|
break
|
|
|
|
if not c_options['use_opengl_es2']:
|
|
|
|
print('NOTE: Not found GLES 2.0 headers at: {}'.format(
|
|
|
|
default_header_dirs))
|
|
|
|
print(' Please contact us if your distribution '
|
|
|
|
'uses an alternative path for the headers.')
|
|
|
|
|
|
|
|
print('Using this graphics system: {}'.format(
|
|
|
|
['OpenGL', 'OpenGL ES 2'][int(c_options['use_opengl_es2'] or False)]))
|
2011-01-25 16:41:09 +00:00
|
|
|
|
2012-02-24 00:51:31 +00:00
|
|
|
# check if we are in a kivy-ios build
|
|
|
|
if platform == 'ios':
|
2012-12-28 15:11:20 +00:00
|
|
|
print('Kivy-IOS project environment detect, use it.')
|
2012-12-28 17:55:22 +00:00
|
|
|
print('Kivy-IOS project located at {0}'.format(kivy_ios_root))
|
2012-12-28 15:11:20 +00:00
|
|
|
print('Activate SDL compilation.')
|
2012-02-24 00:51:31 +00:00
|
|
|
c_options['use_ios'] = True
|
|
|
|
c_options['use_sdl'] = True
|
2011-01-25 16:41:09 +00:00
|
|
|
|
2015-01-18 00:32:16 +00:00
|
|
|
# detect gstreamer, only on desktop
|
|
|
|
# works if we forced the options or in autodetection
|
2015-01-30 02:25:40 +00:00
|
|
|
if platform not in ('ios', 'android') and (c_options['use_gstreamer']
|
|
|
|
in (None, True)):
|
2015-01-07 18:53:39 +00:00
|
|
|
if c_options['use_osx_frameworks'] and platform == 'darwin':
|
|
|
|
# check the existence of frameworks
|
|
|
|
f_path = '/Library/Frameworks/GStreamer.framework'
|
|
|
|
if not exists(f_path):
|
|
|
|
c_options['use_gstreamer'] = False
|
|
|
|
print('Missing GStreamer framework {}'.format(f_path))
|
|
|
|
else:
|
|
|
|
c_options['use_gstreamer'] = True
|
|
|
|
gst_flags = {
|
|
|
|
'extra_link_args': [
|
|
|
|
'-Xlinker', '-headerpad',
|
|
|
|
'-Xlinker', '190',
|
|
|
|
'-framework', 'GStreamer'],
|
|
|
|
'include_dirs': [join(f_path, 'Headers')]}
|
|
|
|
|
2015-01-18 00:32:16 +00:00
|
|
|
else:
|
|
|
|
# use pkg-config approach instead
|
|
|
|
gst_flags = pkgconfig('gstreamer-1.0')
|
|
|
|
if 'libraries' in gst_flags:
|
|
|
|
c_options['use_gstreamer'] = True
|
|
|
|
|
|
|
|
|
|
|
|
# detect SDL2, only on desktop
|
|
|
|
# works if we forced the options or in autodetection
|
|
|
|
sdl2_flags = {}
|
2015-01-23 08:45:06 +00:00
|
|
|
if platform not in ('ios', 'android') and c_options['use_sdl2'] in (None, True):
|
2015-01-18 00:32:16 +00:00
|
|
|
|
|
|
|
if c_options['use_osx_frameworks'] and platform == 'darwin':
|
|
|
|
# check the existence of frameworks
|
2015-01-07 18:53:39 +00:00
|
|
|
sdl2_valid = True
|
|
|
|
sdl2_flags = {
|
|
|
|
'extra_link_args': [
|
|
|
|
'-Xlinker', '-headerpad',
|
|
|
|
'-Xlinker', '190'],
|
|
|
|
'include_dirs': []
|
|
|
|
}
|
|
|
|
for name in ('SDL2', 'SDL2_ttf', 'SDL2_image', 'SDL2_mixer'):
|
|
|
|
f_path = '/Library/Frameworks/{}.framework'.format(name)
|
|
|
|
if not exists(f_path):
|
|
|
|
print('Missing framework {}'.format(f_path))
|
|
|
|
sdl2_valid = False
|
|
|
|
continue
|
|
|
|
sdl2_flags['extra_link_args'] += ['-framework', name]
|
|
|
|
sdl2_flags['include_dirs'] += [join(f_path, 'Headers')]
|
|
|
|
print('Found sdl2 frameworks: {}'.format(f_path))
|
|
|
|
|
|
|
|
if not sdl2_valid:
|
|
|
|
c_options['use_sdl2'] = False
|
|
|
|
print('Deactivate SDL2 compilation due to missing frameworks')
|
|
|
|
else:
|
|
|
|
c_options['use_sdl2'] = True
|
|
|
|
print('Activate SDL2 compilation')
|
|
|
|
|
|
|
|
else:
|
|
|
|
# use pkg-config approach instead
|
|
|
|
sdl2_flags = pkgconfig('sdl2', 'SDL2_ttf', 'SDL2_image', 'SDL2_mixer')
|
|
|
|
if 'libraries' in sdl2_flags:
|
|
|
|
c_options['use_sdl2'] = True
|
|
|
|
|
|
|
|
if c_options['use_sdl2']:
|
|
|
|
print('SDL2 compilation enabled, deactivate 1.x')
|
|
|
|
c_options['use_sdl'] = False
|
2014-11-15 21:38:45 +00:00
|
|
|
|
2014-08-23 11:45:04 +00:00
|
|
|
|
2012-02-23 23:25:20 +00:00
|
|
|
# -----------------------------------------------------------------------------
|
|
|
|
# declare flags
|
2012-06-16 15:46:48 +00:00
|
|
|
|
2013-09-07 07:37:20 +00:00
|
|
|
|
2012-02-23 23:25:20 +00:00
|
|
|
def get_modulename_from_file(filename):
|
2012-02-24 01:25:25 +00:00
|
|
|
filename = filename.replace(sep, '/')
|
2012-02-23 23:25:20 +00:00
|
|
|
pyx = '.'.join(filename.split('.')[:-1])
|
2012-02-24 01:25:25 +00:00
|
|
|
pyxl = pyx.split('/')
|
2012-02-23 23:25:20 +00:00
|
|
|
while pyxl[0] != 'kivy':
|
|
|
|
pyxl.pop(0)
|
|
|
|
if pyxl[1] == 'kivy':
|
|
|
|
pyxl.pop(0)
|
|
|
|
return '.'.join(pyxl)
|
2011-01-25 16:41:09 +00:00
|
|
|
|
2012-06-16 15:46:48 +00:00
|
|
|
|
2015-01-28 19:45:24 +00:00
|
|
|
def expand(root, *args):
|
|
|
|
return join(root, 'kivy', *args)
|
2014-08-23 11:45:04 +00:00
|
|
|
|
|
|
|
|
2012-02-23 23:25:20 +00:00
|
|
|
class CythonExtension(Extension):
|
2010-11-03 21:05:03 +00:00
|
|
|
|
2012-02-23 23:25:20 +00:00
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
Extension.__init__(self, *args, **kwargs)
|
2013-02-25 15:42:24 +00:00
|
|
|
self.cython_directives = {
|
2013-03-03 04:01:13 +00:00
|
|
|
'c_string_encoding': 'utf-8',
|
2012-02-23 23:25:20 +00:00
|
|
|
'profile': 'USE_PROFILE' in environ,
|
2012-02-25 10:41:12 +00:00
|
|
|
'embedsignature': 'USE_EMBEDSIGNATURE' in environ}
|
2012-02-23 23:25:20 +00:00
|
|
|
# XXX with pip, setuptools is imported before distutils, and change
|
|
|
|
# our pyx to c, then, cythonize doesn't happen. So force again our
|
|
|
|
# sources
|
|
|
|
self.sources = args[1]
|
2010-12-16 22:00:14 +00:00
|
|
|
|
2012-06-16 15:46:48 +00:00
|
|
|
|
2012-02-23 23:25:20 +00:00
|
|
|
def merge(d1, *args):
|
|
|
|
d1 = deepcopy(d1)
|
|
|
|
for d2 in args:
|
2012-12-28 15:11:20 +00:00
|
|
|
for key, value in d2.items():
|
2012-08-13 17:32:08 +00:00
|
|
|
value = deepcopy(value)
|
2012-02-23 23:25:20 +00:00
|
|
|
if key in d1:
|
|
|
|
d1[key].extend(value)
|
|
|
|
else:
|
|
|
|
d1[key] = value
|
|
|
|
return d1
|
2011-04-27 12:12:58 +00:00
|
|
|
|
2013-09-07 07:37:20 +00:00
|
|
|
|
2012-02-24 00:51:31 +00:00
|
|
|
def determine_base_flags():
|
|
|
|
flags = {
|
2014-08-23 11:45:04 +00:00
|
|
|
'libraries': [],
|
2012-02-24 00:51:31 +00:00
|
|
|
'include_dirs': [],
|
|
|
|
'extra_link_args': [],
|
|
|
|
'extra_compile_args': []}
|
|
|
|
if c_options['use_ios']:
|
2013-02-11 20:25:20 +00:00
|
|
|
sysroot = environ.get('IOSSDKROOT', environ.get('SDKROOT'))
|
|
|
|
if not sysroot:
|
|
|
|
raise Exception('IOSSDKROOT is not set')
|
2012-02-24 00:51:31 +00:00
|
|
|
flags['include_dirs'] += [sysroot]
|
|
|
|
flags['extra_compile_args'] += ['-isysroot', sysroot]
|
|
|
|
flags['extra_link_args'] += ['-isysroot', sysroot]
|
|
|
|
elif platform == 'darwin':
|
2013-07-04 14:25:06 +00:00
|
|
|
v = os.uname()
|
2014-08-23 11:45:04 +00:00
|
|
|
if v[2] >= '13.0.0':
|
|
|
|
# use xcode-select to search on the right Xcode path
|
|
|
|
# XXX use the best SDK available instead of a specific one
|
|
|
|
import platform as _platform
|
|
|
|
xcode_dev = getoutput('xcode-select -p').splitlines()[0]
|
|
|
|
sdk_mac_ver = '.'.join(_platform.mac_ver()[0].split('.')[:2])
|
|
|
|
print('Xcode detected at {}, and using MacOSX{} sdk'.format(
|
|
|
|
xcode_dev, sdk_mac_ver))
|
|
|
|
sysroot = join(xcode_dev.decode('utf-8'),
|
|
|
|
'Platforms/MacOSX.platform/Developer/SDKs',
|
|
|
|
'MacOSX{}.sdk'.format(sdk_mac_ver),
|
|
|
|
'System/Library/Frameworks')
|
2013-07-04 14:25:06 +00:00
|
|
|
else:
|
2014-08-23 11:45:04 +00:00
|
|
|
sysroot = ('/System/Library/Frameworks/'
|
|
|
|
'ApplicationServices.framework/Frameworks')
|
2012-02-24 00:51:31 +00:00
|
|
|
flags['extra_compile_args'] += ['-F%s' % sysroot]
|
|
|
|
flags['extra_link_args'] += ['-F%s' % sysroot]
|
|
|
|
return flags
|
2010-11-03 21:05:03 +00:00
|
|
|
|
2013-09-07 07:37:20 +00:00
|
|
|
|
2012-02-23 23:25:20 +00:00
|
|
|
def determine_gl_flags():
|
|
|
|
flags = {'libraries': []}
|
2011-02-01 19:46:39 +00:00
|
|
|
if platform == 'win32':
|
2012-02-23 23:25:20 +00:00
|
|
|
flags['libraries'] = ['opengl32']
|
2012-02-24 00:51:31 +00:00
|
|
|
elif platform == 'ios':
|
|
|
|
flags['libraries'] = ['GLESv2']
|
|
|
|
flags['extra_link_args'] = ['-framework', 'OpenGLES']
|
2011-02-01 19:46:39 +00:00
|
|
|
elif platform == 'darwin':
|
2014-08-23 11:45:04 +00:00
|
|
|
flags['extra_link_args'] = ['-framework', 'OpenGL', '-arch', osx_arch]
|
|
|
|
flags['extra_compile_args'] = ['-arch', osx_arch]
|
2011-02-01 19:46:39 +00:00
|
|
|
elif platform.startswith('freebsd'):
|
2012-02-23 23:25:20 +00:00
|
|
|
flags['include_dirs'] = ['/usr/local/include']
|
|
|
|
flags['extra_link_args'] = ['-L', '/usr/local/lib']
|
2012-05-24 01:49:54 +00:00
|
|
|
flags['libraries'] = ['GL']
|
2012-04-05 12:17:55 +00:00
|
|
|
elif platform.startswith('openbsd'):
|
|
|
|
flags['include_dirs'] = ['/usr/X11R6/include']
|
|
|
|
flags['extra_link_args'] = ['-L', '/usr/X11R6/lib']
|
|
|
|
flags['libraries'] = ['GL']
|
2012-01-10 13:39:21 +00:00
|
|
|
elif platform == 'android':
|
2012-02-24 10:24:21 +00:00
|
|
|
flags['include_dirs'] = [join(ndkplatform, 'usr', 'include')]
|
|
|
|
flags['extra_link_args'] = ['-L', join(ndkplatform, 'usr', 'lib')]
|
2012-02-23 23:25:20 +00:00
|
|
|
flags['libraries'] = ['GLESv2']
|
2013-03-19 18:14:27 +00:00
|
|
|
elif platform == 'rpi':
|
|
|
|
flags['include_dirs'] = ['/opt/vc/include',
|
2013-05-27 15:04:18 +00:00
|
|
|
'/opt/vc/include/interface/vcos/pthreads',
|
|
|
|
'/opt/vc/include/interface/vmcs_host/linux']
|
2014-10-21 06:48:21 +00:00
|
|
|
flags['library_dirs'] = ['/opt/vc/lib']
|
2014-10-15 09:04:22 +00:00
|
|
|
flags['libraries'] = ['bcm_host', 'EGL', 'GLESv2']
|
2010-11-03 21:05:03 +00:00
|
|
|
else:
|
2012-02-23 23:25:20 +00:00
|
|
|
flags['libraries'] = ['GL']
|
2011-01-25 16:41:09 +00:00
|
|
|
if c_options['use_glew']:
|
2011-02-01 19:46:39 +00:00
|
|
|
if platform == 'win32':
|
2012-02-23 23:25:20 +00:00
|
|
|
flags['libraries'] += ['glew32']
|
2011-01-25 18:55:48 +00:00
|
|
|
else:
|
2012-02-23 23:25:20 +00:00
|
|
|
flags['libraries'] += ['GLEW']
|
|
|
|
return flags
|
2011-01-25 16:41:09 +00:00
|
|
|
|
2013-09-07 07:37:20 +00:00
|
|
|
|
2012-02-24 00:51:31 +00:00
|
|
|
def determine_sdl():
|
|
|
|
flags = {}
|
|
|
|
if not c_options['use_sdl']:
|
|
|
|
return flags
|
|
|
|
|
|
|
|
flags['libraries'] = ['SDL', 'SDL_ttf', 'freetype', 'z', 'bz2']
|
2012-02-24 01:09:45 +00:00
|
|
|
flags['include_dirs'] = []
|
2012-02-24 00:51:31 +00:00
|
|
|
flags['extra_link_args'] = []
|
|
|
|
flags['extra_compile_args'] = []
|
|
|
|
|
|
|
|
# Paths as per homebrew (modified formula to use hg checkout)
|
|
|
|
if c_options['use_ios']:
|
|
|
|
# Note: on IOS, SDL is already loaded by the launcher/main.m
|
|
|
|
# So if we add it here, it will just complain about duplicate
|
|
|
|
# symbol, cause libSDL.a would be included in main.m binary +
|
|
|
|
# text_sdlttf.so
|
|
|
|
# At the result, we are linking without SDL explicitly, and add
|
|
|
|
# -undefined dynamic_lookup
|
|
|
|
# (/tito)
|
|
|
|
flags['libraries'] = ['SDL_ttf', 'freetype', 'bz2']
|
2012-02-24 01:09:45 +00:00
|
|
|
flags['include_dirs'] += [
|
2012-02-24 00:51:31 +00:00
|
|
|
join(kivy_ios_root, 'build', 'include'),
|
|
|
|
join(kivy_ios_root, 'build', 'include', 'SDL'),
|
|
|
|
join(kivy_ios_root, 'build', 'include', 'freetype')]
|
|
|
|
flags['extra_link_args'] += [
|
|
|
|
'-L', join(kivy_ios_root, 'build', 'lib'),
|
|
|
|
'-undefined', 'dynamic_lookup']
|
|
|
|
else:
|
2012-02-24 01:09:45 +00:00
|
|
|
flags['include_dirs'] = ['/usr/local/include/SDL']
|
2012-02-24 00:51:31 +00:00
|
|
|
flags['extra_link_args'] += ['-L/usr/local/lib/']
|
|
|
|
|
|
|
|
if platform == 'ios':
|
|
|
|
flags['extra_link_args'] += [
|
|
|
|
'-framework', 'Foundation',
|
|
|
|
'-framework', 'UIKit',
|
|
|
|
'-framework', 'AudioToolbox',
|
|
|
|
'-framework', 'CoreGraphics',
|
|
|
|
'-framework', 'QuartzCore',
|
2012-03-14 00:16:54 +00:00
|
|
|
'-framework', 'MobileCoreServices',
|
2012-02-24 00:51:31 +00:00
|
|
|
'-framework', 'ImageIO']
|
|
|
|
elif platform == 'darwin':
|
|
|
|
flags['extra_link_args'] += [
|
|
|
|
'-framework', 'ApplicationServices']
|
|
|
|
return flags
|
|
|
|
|
2013-09-07 07:37:20 +00:00
|
|
|
|
2013-08-20 23:35:34 +00:00
|
|
|
def determine_sdl2():
|
|
|
|
flags = {}
|
|
|
|
if not c_options['use_sdl2']:
|
|
|
|
return flags
|
|
|
|
|
2014-11-14 12:19:34 +00:00
|
|
|
sdl2_path = environ.get('KIVY_SDL2_PATH', None)
|
2014-11-08 12:40:41 +00:00
|
|
|
|
2014-11-15 21:38:45 +00:00
|
|
|
if sdl2_flags and not sdl2_path:
|
|
|
|
return sdl2_flags
|
|
|
|
|
|
|
|
# no pkgconfig info, or we want to use a specific sdl2 path, so perform
|
|
|
|
# manual configuration
|
2013-08-20 23:35:34 +00:00
|
|
|
flags['libraries'] = ['SDL2', 'SDL2_ttf', 'SDL2_image', 'SDL2_mixer']
|
2014-11-08 12:40:41 +00:00
|
|
|
flags['include_dirs'] = ([sdl2_path] if sdl2_path else
|
|
|
|
['/usr/local/include/SDL2', '/usr/include/SDL2'])
|
2014-08-23 11:45:04 +00:00
|
|
|
|
2013-08-20 23:35:34 +00:00
|
|
|
flags['extra_link_args'] = []
|
|
|
|
flags['extra_compile_args'] = []
|
2014-11-08 12:40:41 +00:00
|
|
|
flags['extra_link_args'] += (['-L' + sdl2_path] if sdl2_path else
|
2014-11-15 21:38:45 +00:00
|
|
|
['-L/usr/local/lib/'])
|
2013-08-20 23:35:34 +00:00
|
|
|
|
|
|
|
# ensure headers for all the SDL2 and sub libraries are available
|
|
|
|
libs_to_check = ['SDL', 'SDL_mixer', 'SDL_ttf', 'SDL_image']
|
|
|
|
can_compile = True
|
|
|
|
for lib in libs_to_check:
|
|
|
|
found = False
|
|
|
|
for d in flags['include_dirs']:
|
|
|
|
fn = join(d, '{}.h'.format(lib))
|
|
|
|
if exists(fn):
|
|
|
|
found = True
|
2014-09-21 17:28:07 +00:00
|
|
|
print('SDL2: found {} header at {}'.format(lib, fn))
|
2013-08-20 23:35:34 +00:00
|
|
|
break
|
|
|
|
|
|
|
|
if not found:
|
2014-09-21 17:28:07 +00:00
|
|
|
print('SDL2: missing sub library {}'.format(lib))
|
2013-08-20 23:35:34 +00:00
|
|
|
can_compile = False
|
|
|
|
|
|
|
|
if not can_compile:
|
|
|
|
c_options['use_sdl2'] = False
|
|
|
|
return {}
|
|
|
|
|
|
|
|
return flags
|
|
|
|
|
2013-09-07 07:37:20 +00:00
|
|
|
|
2012-02-24 00:51:31 +00:00
|
|
|
base_flags = determine_base_flags()
|
2012-02-23 23:25:20 +00:00
|
|
|
gl_flags = determine_gl_flags()
|
|
|
|
|
|
|
|
# -----------------------------------------------------------------------------
|
|
|
|
# sources to compile
|
2014-08-23 11:45:04 +00:00
|
|
|
# all the dependencies have been found manually with:
|
|
|
|
# grep -inr -E '(cimport|include)' kivy/graphics/context_instructions.{pxd,pyx}
|
|
|
|
graphics_dependencies = {
|
|
|
|
'gl_redirect.h': ['common_subset.h'],
|
|
|
|
'c_opengl.pxd': ['config.pxi', 'gl_redirect.h'],
|
|
|
|
'buffer.pyx': ['common.pxi'],
|
|
|
|
'context.pxd': [
|
|
|
|
'instructions.pxd', 'texture.pxd', 'vbo.pxd',
|
|
|
|
'c_opengl.pxd', 'c_opengl_debug.pxd'],
|
|
|
|
'c_opengl_debug.pyx': ['common.pxi', 'c_opengl.pxd'],
|
|
|
|
'compiler.pxd': ['instructions.pxd'],
|
|
|
|
'compiler.pyx': ['context_instructions.pxd'],
|
|
|
|
'context_instructions.pxd': [
|
|
|
|
'transformation.pxd', 'instructions.pxd', 'texture.pxd'],
|
|
|
|
'fbo.pxd': ['c_opengl.pxd', 'instructions.pxd', 'texture.pxd'],
|
|
|
|
'fbo.pyx': [
|
|
|
|
'config.pxi', 'opcodes.pxi', 'transformation.pxd', 'context.pxd',
|
|
|
|
'c_opengl_debug.pxd'],
|
|
|
|
'gl_instructions.pyx': [
|
|
|
|
'config.pxi', 'opcodes.pxi', 'c_opengl.pxd', 'c_opengl_debug.pxd',
|
|
|
|
'instructions.pxd'],
|
|
|
|
'instructions.pxd': [
|
|
|
|
'vbo.pxd', 'context_instructions.pxd', 'compiler.pxd', 'shader.pxd',
|
|
|
|
'texture.pxd', '../_event.pxd'],
|
|
|
|
'instructions.pyx': [
|
|
|
|
'config.pxi', 'opcodes.pxi', 'c_opengl.pxd', 'c_opengl_debug.pxd',
|
|
|
|
'context.pxd', 'common.pxi', 'vertex.pxd', 'transformation.pxd'],
|
|
|
|
'opengl.pyx': ['config.pxi', 'common.pxi', 'c_opengl.pxd', 'gl_redirect.h'],
|
|
|
|
'opengl_utils.pyx': ['opengl_utils_def.pxi', 'c_opengl.pxd'],
|
|
|
|
'shader.pxd': ['c_opengl.pxd', 'transformation.pxd', 'vertex.pxd'],
|
|
|
|
'shader.pyx': [
|
|
|
|
'config.pxi', 'common.pxi', 'c_opengl.pxd', 'c_opengl_debug.pxd',
|
|
|
|
'vertex.pxd', 'transformation.pxd', 'context.pxd'],
|
|
|
|
'stencil_instructions.pxd': ['instructions.pxd'],
|
|
|
|
'stencil_instructions.pyx': [
|
|
|
|
'config.pxi', 'opcodes.pxi', 'c_opengl.pxd', 'c_opengl_debug.pxd'],
|
2014-09-19 19:44:55 +00:00
|
|
|
'svg.pyx': ['config.pxi', 'common.pxi', 'texture.pxd', 'instructions.pxd',
|
2014-09-20 00:19:29 +00:00
|
|
|
'vertex_instructions.pxd', 'tesselator.pxd'],
|
2014-08-23 11:45:04 +00:00
|
|
|
'texture.pxd': ['c_opengl.pxd'],
|
|
|
|
'texture.pyx': [
|
|
|
|
'config.pxi', 'common.pxi', 'opengl_utils_def.pxi', 'context.pxd',
|
|
|
|
'c_opengl.pxd', 'c_opengl_debug.pxd', 'opengl_utils.pxd',
|
|
|
|
'img_tools.pxi'],
|
|
|
|
'vbo.pxd': ['buffer.pxd', 'c_opengl.pxd', 'vertex.pxd'],
|
|
|
|
'vbo.pyx': [
|
|
|
|
'config.pxi', 'common.pxi', 'c_opengl_debug.pxd', 'context.pxd',
|
|
|
|
'instructions.pxd', 'shader.pxd'],
|
|
|
|
'vertex.pxd': ['c_opengl.pxd'],
|
|
|
|
'vertex.pyx': ['config.pxi', 'common.pxi'],
|
|
|
|
'vertex_instructions.pyx': [
|
|
|
|
'config.pxi', 'common.pxi', 'vbo.pxd', 'vertex.pxd', 'instructions.pxd',
|
2014-09-20 00:19:29 +00:00
|
|
|
'vertex_instructions.pxd',
|
2014-08-23 11:45:04 +00:00
|
|
|
'c_opengl.pxd', 'c_opengl_debug.pxd', 'texture.pxd',
|
|
|
|
'vertex_instructions_line.pxi'],
|
|
|
|
'vertex_instructions_line.pxi': ['stencil_instructions.pxd']}
|
|
|
|
|
2012-02-23 23:25:20 +00:00
|
|
|
sources = {
|
2014-09-29 23:50:46 +00:00
|
|
|
'_event.pyx': merge(base_flags, {'depends': ['properties.pxd']}),
|
2015-03-04 16:36:06 +00:00
|
|
|
'weakproxy.pyx': {},
|
2014-09-29 23:50:46 +00:00
|
|
|
'properties.pyx': merge(base_flags, {'depends': ['_event.pxd']}),
|
2012-02-23 23:25:20 +00:00
|
|
|
'graphics/buffer.pyx': base_flags,
|
2014-08-23 11:45:04 +00:00
|
|
|
'graphics/context.pyx': merge(base_flags, gl_flags),
|
|
|
|
'graphics/c_opengl_debug.pyx': merge(base_flags, gl_flags),
|
|
|
|
'graphics/compiler.pyx': merge(base_flags, gl_flags),
|
|
|
|
'graphics/context_instructions.pyx': merge(base_flags, gl_flags),
|
|
|
|
'graphics/fbo.pyx': merge(base_flags, gl_flags),
|
|
|
|
'graphics/gl_instructions.pyx': merge(base_flags, gl_flags),
|
|
|
|
'graphics/instructions.pyx': merge(base_flags, gl_flags),
|
|
|
|
'graphics/opengl.pyx': merge(base_flags, gl_flags),
|
|
|
|
'graphics/opengl_utils.pyx': merge(base_flags, gl_flags),
|
|
|
|
'graphics/shader.pyx': merge(base_flags, gl_flags),
|
|
|
|
'graphics/stencil_instructions.pyx': merge(base_flags, gl_flags),
|
|
|
|
'graphics/texture.pyx': merge(base_flags, gl_flags),
|
|
|
|
'graphics/transformation.pyx': merge(base_flags, gl_flags),
|
|
|
|
'graphics/vbo.pyx': merge(base_flags, gl_flags),
|
|
|
|
'graphics/vertex.pyx': merge(base_flags, gl_flags),
|
|
|
|
'graphics/vertex_instructions.pyx': merge(base_flags, gl_flags),
|
2014-08-29 23:21:59 +00:00
|
|
|
'core/text/text_layout.pyx': base_flags,
|
|
|
|
'graphics/tesselator.pyx': merge(base_flags, {
|
|
|
|
'include_dirs': ['kivy/lib/libtess2/Include'],
|
2014-08-30 12:11:25 +00:00
|
|
|
'c_depends': [
|
|
|
|
'lib/libtess2/Source/bucketalloc.c',
|
|
|
|
'lib/libtess2/Source/dict.c',
|
|
|
|
'lib/libtess2/Source/geom.c',
|
|
|
|
'lib/libtess2/Source/mesh.c',
|
|
|
|
'lib/libtess2/Source/priorityq.c',
|
|
|
|
'lib/libtess2/Source/sweep.c',
|
|
|
|
'lib/libtess2/Source/tess.c'
|
|
|
|
]
|
2014-09-19 19:44:55 +00:00
|
|
|
}),
|
|
|
|
'graphics/svg.pyx': merge(base_flags, gl_flags)
|
2014-08-29 23:21:59 +00:00
|
|
|
}
|
2011-02-13 15:06:19 +00:00
|
|
|
|
2012-02-24 00:51:31 +00:00
|
|
|
if c_options['use_sdl']:
|
|
|
|
sdl_flags = determine_sdl()
|
2015-02-09 11:53:45 +00:00
|
|
|
for source_file in ('core/window/sdl.pyx',
|
|
|
|
'core/text/text_sdlttf.pyx',
|
|
|
|
'core/audio/audio_sdl.pyx'):
|
|
|
|
sources[source_file] = merge(
|
|
|
|
base_flags, gl_flags, sdl_flags)
|
2012-02-24 00:51:31 +00:00
|
|
|
|
2013-08-20 23:35:34 +00:00
|
|
|
if c_options['use_sdl2']:
|
|
|
|
sdl2_flags = determine_sdl2()
|
|
|
|
if sdl2_flags:
|
2015-02-09 11:53:45 +00:00
|
|
|
sdl2_depends = {'depends': ['lib/sdl2.pxi']}
|
|
|
|
for source_file in ('core/window/_window_sdl2.pyx',
|
|
|
|
'core/image/_img_sdl2.pyx',
|
|
|
|
'core/text/_text_sdl2.pyx',
|
|
|
|
'core/clipboard/_clipboard_sdl2.pyx'):
|
|
|
|
sources[source_file] = merge(
|
|
|
|
base_flags, gl_flags, sdl2_flags, sdl2_depends)
|
2013-08-20 23:35:34 +00:00
|
|
|
|
2012-02-24 00:51:31 +00:00
|
|
|
if platform in ('darwin', 'ios'):
|
|
|
|
# activate ImageIO provider for our core image
|
|
|
|
if platform == 'ios':
|
|
|
|
osx_flags = {'extra_link_args': [
|
|
|
|
'-framework', 'Foundation',
|
|
|
|
'-framework', 'UIKit',
|
|
|
|
'-framework', 'AudioToolbox',
|
|
|
|
'-framework', 'CoreGraphics',
|
|
|
|
'-framework', 'QuartzCore',
|
2014-08-23 11:45:04 +00:00
|
|
|
'-framework', 'ImageIO',
|
|
|
|
'-framework', 'Accelerate']}
|
2012-02-24 00:51:31 +00:00
|
|
|
else:
|
|
|
|
osx_flags = {'extra_link_args': [
|
|
|
|
'-framework', 'ApplicationServices']}
|
|
|
|
sources['core/image/img_imageio.pyx'] = merge(
|
|
|
|
base_flags, osx_flags)
|
|
|
|
|
2014-08-23 11:45:04 +00:00
|
|
|
if c_options['use_avfoundation']:
|
|
|
|
import platform as _platform
|
|
|
|
mac_ver = [int(x) for x in _platform.mac_ver()[0].split('.')[:2]]
|
|
|
|
if mac_ver >= [10, 7]:
|
|
|
|
osx_flags = {
|
|
|
|
'extra_link_args': ['-framework', 'AVFoundation'],
|
|
|
|
'extra_compile_args': ['-ObjC++'],
|
|
|
|
'depends': ['core/camera/camera_avfoundation_implem.m']}
|
|
|
|
sources['core/camera/camera_avfoundation.pyx'] = merge(
|
|
|
|
base_flags, osx_flags)
|
|
|
|
else:
|
|
|
|
print('AVFoundation cannot be used, OSX >= 10.7 is required')
|
|
|
|
|
2013-03-19 18:14:27 +00:00
|
|
|
if c_options['use_rpi']:
|
|
|
|
sources['lib/vidcore_lite/egl.pyx'] = merge(
|
|
|
|
base_flags, gl_flags)
|
|
|
|
sources['lib/vidcore_lite/bcm.pyx'] = merge(
|
|
|
|
base_flags, gl_flags)
|
|
|
|
|
2013-03-31 10:26:23 +00:00
|
|
|
if c_options['use_x11']:
|
2012-08-13 17:32:08 +00:00
|
|
|
sources['core/window/window_x11.pyx'] = merge(
|
2014-08-23 11:45:04 +00:00
|
|
|
base_flags, gl_flags, {
|
|
|
|
# FIXME add an option to depend on them but not compile them
|
|
|
|
# cause keytab is included in core, and core is included in
|
|
|
|
# window_x11
|
|
|
|
#
|
|
|
|
#'depends': [
|
|
|
|
# 'core/window/window_x11_keytab.c',
|
|
|
|
# 'core/window/window_x11_core.c'],
|
|
|
|
'libraries': ['Xrender', 'X11']})
|
|
|
|
|
|
|
|
if c_options['use_gstreamer']:
|
|
|
|
sources['lib/gstplayer/_gstplayer.pyx'] = merge(
|
|
|
|
base_flags, gst_flags, {
|
|
|
|
'depends': ['lib/gstplayer/_gstplayer.h']})
|
2012-08-13 17:32:08 +00:00
|
|
|
|
2010-11-05 16:55:22 +00:00
|
|
|
|
2012-02-23 23:25:20 +00:00
|
|
|
# -----------------------------------------------------------------------------
|
|
|
|
# extension modules
|
2012-06-16 15:46:48 +00:00
|
|
|
|
2014-08-23 11:45:04 +00:00
|
|
|
def get_dependencies(name, deps=None):
|
|
|
|
if deps is None:
|
|
|
|
deps = []
|
|
|
|
for dep in graphics_dependencies.get(name, []):
|
|
|
|
if dep not in deps:
|
|
|
|
deps.append(dep)
|
|
|
|
get_dependencies(dep, deps)
|
|
|
|
return deps
|
|
|
|
|
|
|
|
|
|
|
|
def resolve_dependencies(fn, depends):
|
|
|
|
fn = basename(fn)
|
|
|
|
deps = []
|
|
|
|
get_dependencies(fn, deps)
|
|
|
|
get_dependencies(fn.replace('.pyx', '.pxd'), deps)
|
2015-01-28 19:45:24 +00:00
|
|
|
return [expand(src_path, 'graphics', x) for x in deps]
|
2014-08-23 11:45:04 +00:00
|
|
|
|
|
|
|
|
2012-02-23 23:25:20 +00:00
|
|
|
def get_extensions_from_sources(sources):
|
|
|
|
ext_modules = []
|
2012-02-24 01:09:45 +00:00
|
|
|
if environ.get('KIVY_FAKE_BUILDEXT'):
|
2012-12-28 15:11:20 +00:00
|
|
|
print('Fake build_ext asked, will generate only .h/.c')
|
2012-02-24 01:09:45 +00:00
|
|
|
return ext_modules
|
2012-12-28 15:11:20 +00:00
|
|
|
for pyx, flags in sources.items():
|
2014-08-23 11:45:04 +00:00
|
|
|
is_graphics = pyx.startswith('graphics')
|
2015-01-28 19:45:24 +00:00
|
|
|
pyx = expand(src_path, pyx)
|
|
|
|
depends = [expand(src_path, x) for x in flags.pop('depends', [])]
|
|
|
|
c_depends = [expand(src_path, x) for x in flags.pop('c_depends', [])]
|
2012-02-23 23:25:20 +00:00
|
|
|
if not have_cython:
|
|
|
|
pyx = '%s.c' % pyx[:-4]
|
2014-08-23 11:45:04 +00:00
|
|
|
if is_graphics:
|
|
|
|
depends = resolve_dependencies(pyx, depends)
|
|
|
|
f_depends = [x for x in depends if x.rsplit('.', 1)[-1] in (
|
|
|
|
'c', 'cpp', 'm')]
|
2011-02-01 23:17:24 +00:00
|
|
|
module_name = get_modulename_from_file(pyx)
|
2014-08-23 11:45:04 +00:00
|
|
|
flags_clean = {'depends': depends}
|
2012-12-28 15:11:20 +00:00
|
|
|
for key, value in flags.items():
|
2012-02-24 01:14:14 +00:00
|
|
|
if len(value):
|
|
|
|
flags_clean[key] = value
|
2012-02-23 23:25:20 +00:00
|
|
|
ext_modules.append(CythonExtension(module_name,
|
2014-09-19 19:44:55 +00:00
|
|
|
[pyx] + f_depends + c_depends, **flags_clean))
|
2012-02-23 23:25:20 +00:00
|
|
|
return ext_modules
|
2010-11-05 16:55:22 +00:00
|
|
|
|
2012-02-23 23:25:20 +00:00
|
|
|
ext_modules = get_extensions_from_sources(sources)
|
2010-11-03 21:05:03 +00:00
|
|
|
|
2012-02-23 23:25:20 +00:00
|
|
|
# -----------------------------------------------------------------------------
|
|
|
|
# automatically detect data files
|
2010-11-03 21:05:03 +00:00
|
|
|
data_file_prefix = 'share/kivy-'
|
|
|
|
examples = {}
|
2011-06-10 00:42:23 +00:00
|
|
|
examples_allowed_ext = ('readme', 'py', 'wav', 'png', 'jpg', 'svg', 'json',
|
2011-01-31 23:25:15 +00:00
|
|
|
'avi', 'gif', 'txt', 'ttf', 'obj', 'mtl', 'kv')
|
2010-12-16 22:00:14 +00:00
|
|
|
for root, subFolders, files in walk('examples'):
|
2012-02-23 23:25:20 +00:00
|
|
|
for fn in files:
|
|
|
|
ext = fn.split('.')[-1].lower()
|
2010-11-03 21:05:03 +00:00
|
|
|
if ext not in examples_allowed_ext:
|
|
|
|
continue
|
2012-02-23 23:25:20 +00:00
|
|
|
filename = join(root, fn)
|
2010-12-16 22:00:14 +00:00
|
|
|
directory = '%s%s' % (data_file_prefix, dirname(filename))
|
2010-11-03 21:05:03 +00:00
|
|
|
if not directory in examples:
|
|
|
|
examples[directory] = []
|
|
|
|
examples[directory].append(filename)
|
|
|
|
|
2012-02-23 23:25:20 +00:00
|
|
|
# -----------------------------------------------------------------------------
|
2010-11-03 21:05:03 +00:00
|
|
|
# setup !
|
|
|
|
setup(
|
|
|
|
name='Kivy',
|
|
|
|
version=kivy.__version__,
|
|
|
|
author='Kivy Crew',
|
|
|
|
author_email='kivy-dev@googlegroups.com',
|
|
|
|
url='http://kivy.org/',
|
2013-08-01 14:29:23 +00:00
|
|
|
license='MIT',
|
2012-08-13 17:32:08 +00:00
|
|
|
description=(
|
|
|
|
'A software library for rapid development of '
|
|
|
|
'hardware-accelerated multitouch applications.'),
|
2010-11-03 21:05:03 +00:00
|
|
|
ext_modules=ext_modules,
|
|
|
|
cmdclass=cmdclass,
|
|
|
|
packages=[
|
|
|
|
'kivy',
|
2012-10-17 16:34:28 +00:00
|
|
|
'kivy.adapters',
|
2010-11-03 21:05:03 +00:00
|
|
|
'kivy.core',
|
|
|
|
'kivy.core.audio',
|
|
|
|
'kivy.core.camera',
|
|
|
|
'kivy.core.clipboard',
|
|
|
|
'kivy.core.image',
|
2010-11-05 04:27:58 +00:00
|
|
|
'kivy.core.gl',
|
2010-11-03 21:05:03 +00:00
|
|
|
'kivy.core.spelling',
|
|
|
|
'kivy.core.text',
|
|
|
|
'kivy.core.video',
|
2010-11-05 04:27:58 +00:00
|
|
|
'kivy.core.window',
|
2013-05-12 12:06:20 +00:00
|
|
|
'kivy.effects',
|
2011-05-26 20:39:06 +00:00
|
|
|
'kivy.ext',
|
2010-11-03 21:05:03 +00:00
|
|
|
'kivy.graphics',
|
2014-10-23 17:35:08 +00:00
|
|
|
'kivy.garden',
|
2010-11-03 21:05:03 +00:00
|
|
|
'kivy.input',
|
|
|
|
'kivy.input.postproc',
|
|
|
|
'kivy.input.providers',
|
|
|
|
'kivy.lib',
|
|
|
|
'kivy.lib.osc',
|
2014-08-23 11:45:04 +00:00
|
|
|
'kivy.lib.gstplayer',
|
2013-05-30 20:56:07 +00:00
|
|
|
'kivy.lib.vidcore_lite',
|
2010-11-03 21:05:03 +00:00
|
|
|
'kivy.modules',
|
2011-08-16 16:28:44 +00:00
|
|
|
'kivy.network',
|
2014-08-23 11:45:04 +00:00
|
|
|
'kivy.storage',
|
2010-11-03 21:05:03 +00:00
|
|
|
'kivy.tools',
|
|
|
|
'kivy.tools.packaging',
|
2012-03-16 14:38:50 +00:00
|
|
|
'kivy.tools.packaging.pyinstaller_hooks',
|
2012-08-07 22:00:11 +00:00
|
|
|
'kivy.tools.highlight',
|
2012-10-25 03:38:03 +00:00
|
|
|
'kivy.extras',
|
2012-08-07 22:00:11 +00:00
|
|
|
'kivy.tools.extensions',
|
2012-02-23 23:25:20 +00:00
|
|
|
'kivy.uix', ],
|
2010-11-03 21:05:03 +00:00
|
|
|
package_dir={'kivy': 'kivy'},
|
|
|
|
package_data={'kivy': [
|
2014-12-18 16:18:29 +00:00
|
|
|
'*.pxd',
|
2015-01-14 22:51:00 +00:00
|
|
|
'*.pxi',
|
2014-12-18 16:18:29 +00:00
|
|
|
'core/text/*.pxd',
|
2015-01-14 22:51:00 +00:00
|
|
|
'core/text/*.pxi',
|
2014-12-18 16:18:29 +00:00
|
|
|
'graphics/*.pxd',
|
2015-01-14 22:51:00 +00:00
|
|
|
'graphics/*.pxi',
|
2014-12-18 16:18:29 +00:00
|
|
|
'lib/vidcore_lite/*.pxd',
|
2015-01-14 22:51:00 +00:00
|
|
|
'lib/vidcore_lite/*.pxi',
|
2011-01-09 23:37:16 +00:00
|
|
|
'data/*.kv',
|
2011-06-10 00:42:23 +00:00
|
|
|
'data/*.json',
|
2011-01-09 23:37:16 +00:00
|
|
|
'data/fonts/*.ttf',
|
|
|
|
'data/images/*.png',
|
2011-04-21 17:43:31 +00:00
|
|
|
'data/images/*.jpg',
|
2011-08-21 21:47:13 +00:00
|
|
|
'data/images/*.gif',
|
2012-01-22 20:00:58 +00:00
|
|
|
'data/images/*.atlas',
|
2011-10-21 16:05:51 +00:00
|
|
|
'data/keyboards/*.json',
|
2011-01-31 23:07:49 +00:00
|
|
|
'data/logo/*.png',
|
2011-01-09 23:37:16 +00:00
|
|
|
'data/glsl/*.png',
|
|
|
|
'data/glsl/*.vs',
|
|
|
|
'data/glsl/*.fs',
|
2012-08-07 22:00:11 +00:00
|
|
|
'tools/highlight/*.vim',
|
|
|
|
'tools/highlight/*.el',
|
2010-11-03 21:05:03 +00:00
|
|
|
'tools/packaging/README.txt',
|
|
|
|
'tools/packaging/win32/kivy.bat',
|
2011-01-31 23:49:50 +00:00
|
|
|
'tools/packaging/win32/kivyenv.sh',
|
2010-11-03 21:05:03 +00:00
|
|
|
'tools/packaging/win32/README.txt',
|
2012-08-07 22:00:11 +00:00
|
|
|
'tools/packaging/osx/Info.plist',
|
|
|
|
'tools/packaging/osx/InfoPlist.strings',
|
2011-01-20 17:17:29 +00:00
|
|
|
'tools/packaging/osx/kivy.sh']},
|
2012-12-28 15:11:20 +00:00
|
|
|
data_files=list(examples.items()),
|
2010-11-03 21:05:03 +00:00
|
|
|
classifiers=[
|
2011-04-15 19:38:29 +00:00
|
|
|
'Development Status :: 5 - Production/Stable',
|
2010-11-03 21:05:03 +00:00
|
|
|
'Environment :: MacOS X',
|
|
|
|
'Environment :: Win32 (MS Windows)',
|
|
|
|
'Environment :: X11 Applications',
|
|
|
|
'Intended Audience :: Developers',
|
|
|
|
'Intended Audience :: End Users/Desktop',
|
|
|
|
'Intended Audience :: Information Technology',
|
|
|
|
'Intended Audience :: Science/Research',
|
2013-08-01 14:29:23 +00:00
|
|
|
'License :: OSI Approved :: MIT License',
|
2010-11-03 21:05:03 +00:00
|
|
|
'Natural Language :: English',
|
|
|
|
'Operating System :: MacOS :: MacOS X',
|
|
|
|
'Operating System :: Microsoft :: Windows',
|
|
|
|
'Operating System :: POSIX :: BSD :: FreeBSD',
|
|
|
|
'Operating System :: POSIX :: Linux',
|
|
|
|
'Programming Language :: Python :: 2.7',
|
2014-08-23 11:45:04 +00:00
|
|
|
'Programming Language :: Python :: 3.3',
|
|
|
|
'Programming Language :: Python :: 3.4',
|
2010-11-03 21:05:03 +00:00
|
|
|
'Topic :: Artistic Software',
|
|
|
|
'Topic :: Games/Entertainment',
|
|
|
|
'Topic :: Multimedia :: Graphics :: 3D Rendering',
|
|
|
|
'Topic :: Multimedia :: Graphics :: Capture :: Digital Camera',
|
|
|
|
'Topic :: Multimedia :: Graphics :: Presentation',
|
|
|
|
'Topic :: Multimedia :: Graphics :: Viewers',
|
|
|
|
'Topic :: Multimedia :: Sound/Audio :: Players :: MP3',
|
|
|
|
'Topic :: Multimedia :: Video :: Display',
|
|
|
|
'Topic :: Scientific/Engineering :: Human Machine Interfaces',
|
|
|
|
'Topic :: Scientific/Engineering :: Visualization',
|
|
|
|
'Topic :: Software Development :: Libraries :: Application Frameworks',
|
2014-08-23 11:45:04 +00:00
|
|
|
'Topic :: Software Development :: User Interfaces'],
|
|
|
|
dependency_links=[
|
|
|
|
'https://github.com/kivy-garden/garden/archive/master.zip'],
|
|
|
|
install_requires=['Kivy-Garden==0.1.1'])
|