2012-02-23 23:25:20 +00:00
|
|
|
#
|
2016-03-11 22:17:10 +00:00
|
|
|
# Kivy - Cross-platform UI framework
|
2016-03-11 21:56:18 +00:00
|
|
|
# https://kivy.org/
|
2012-02-23 23:25:20 +00:00
|
|
|
#
|
2015-01-26 16:47:32 +00:00
|
|
|
|
2012-01-29 16:23:42 +00:00
|
|
|
import sys
|
2017-02-10 23:11:24 +00:00
|
|
|
build_examples = False
|
|
|
|
if "--build_examples" in sys.argv:
|
|
|
|
build_examples = True
|
|
|
|
sys.argv.remove("--build_examples")
|
2013-07-04 14:25:06 +00:00
|
|
|
|
2020-01-09 19:42:36 +00:00
|
|
|
from kivy.utils import pi_version
|
2012-02-23 23:25:20 +00:00
|
|
|
from copy import deepcopy
|
2013-07-04 14:25:06 +00:00
|
|
|
import os
|
2018-06-16 15:40:39 +00:00
|
|
|
from os.path import join, dirname, sep, exists, basename, isdir
|
2019-01-20 01:30:52 +00:00
|
|
|
from os import walk, environ, makedirs
|
Change check for Cython to attempt fallback to setuptools on supporte… (#5998)
* Change check for Cython to attempt fallback to setuptools on supported platforms.
This attempts to solve Issue #5984 without causing more problems for Issue #5558.
* Correct argument to extras_require.
* Refactor the declaration and usage of Cython
- Use setuptools.setup by default if available for import.
- The objective for that complicated import/cython is commented.
- Also have more specific variable names, and have their usage be
clarified.
- Remove Cython from install_requires as it already is declared under
setup_requires, and that it conflicts with install_requires due to
issues in setuptools.
- https://github.com/pypa/setuptools/issues/209
- https://github.com/pypa/setuptools/issues/391
- This commit goes back to breaking installation in environments without
Cython, but should be rectified in the next commit.
* Actually fix the specific usage of Cython
- In order for setup.py to make use of the Cython installed during by
the setup_requires to be usable, it must be imported after it is
installed by that step, thus it cannot be done at the top level and
this can be achieved by importing it when it's actually called. A
build_ext factory function is created for this.
- Still allow whatever Cython already present on the current environment
be attempted to be used. This may end up being unnecessary as if it
is always declared in setup_requires (which isn't currently the case
due to the complicated/documented block), it _should_ pull in the
exact/supported version of Cython for usage. This should be
investigated so that this complicated logic may be avoided.
* Make distutils happy by not using factory function
- As it turns out, calling setup.py build_ext will result in a code path
within setuptools that will invoke distutils in a way that forces an
issubclass check, which ultimately results in an exception due to that
function not being a class.
- To fix this, we go back to constructing a base class except also using
the "new" style class (to make Python 2 happy) so that the __new__
method will actually be called so that the logic to select the Cython
version of build_ext will be invoked.
- Also use the super class protocol to invoke parent methods.
* Declare version bounds directly on setup_requires
- This allows us to fully remove the brittle version checks
- Also this allows us to directly declare setup_requires if Cython is
definitely required, as this would allow the correct version to be
installed directly by setuptools during the execution of the setup
step.
- No need to check for failed Cython imports due to the presence of the
setup_requires declaration.
* Add comment explaining the initialisation routine for KivyBuildExt.
Details of how setuptools deals with both cmdclass and when setup_requires
dependencies come in to scope are both relevant.
* Bring comment in to line with earlier changes.
The cython checks are significantly simpler now, and the rationale is also slightly different.
2019-03-04 10:49:42 +00:00
|
|
|
from distutils.command.build_ext import build_ext
|
2015-02-17 04:24:57 +00:00
|
|
|
from distutils.version import LooseVersion
|
2016-04-24 17:35:14 +00:00
|
|
|
from distutils.sysconfig import get_python_inc
|
2014-08-23 11:45:04 +00:00
|
|
|
from collections import OrderedDict
|
2020-09-14 20:17:19 +00:00
|
|
|
from time import sleep
|
2019-04-27 09:48:51 +00:00
|
|
|
from sysconfig import get_paths
|
2019-06-23 20:43:38 +00:00
|
|
|
from pathlib import Path
|
2019-06-01 23:29:09 +00:00
|
|
|
import logging
|
2019-06-23 20:43:38 +00:00
|
|
|
from setuptools import setup, Extension, find_packages
|
2015-04-09 00:39:59 +00:00
|
|
|
|
2010-11-03 21:05:03 +00:00
|
|
|
|
2019-06-01 23:29:09 +00:00
|
|
|
if sys.version_info[0] == 2:
|
|
|
|
logging.critical(
|
|
|
|
'Unsupported Python version detected!: Kivy 2.0.0 and higher does not '
|
|
|
|
'support Python 2. Please upgrade to Python 3, or downgrade Kivy to '
|
2019-06-23 20:43:38 +00:00
|
|
|
'1.11.1 - the last Kivy release that still supports Python 2.')
|
2012-12-28 15:40:37 +00:00
|
|
|
|
2019-05-15 00:51:39 +00:00
|
|
|
|
2019-06-01 23:29:09 +00:00
|
|
|
def ver_equal(self, other):
|
|
|
|
return self.version == other
|
|
|
|
|
2015-02-26 23:41:40 +00:00
|
|
|
|
2019-06-01 23:29:09 +00:00
|
|
|
# fix error with py3's LooseVersion comparisons
|
|
|
|
LooseVersion.__eq__ = ver_equal
|
2015-02-26 23:41:40 +00:00
|
|
|
|
|
|
|
|
2017-09-09 08:59:51 +00:00
|
|
|
def get_description():
|
2019-02-03 11:08:36 +00:00
|
|
|
with open(join(dirname(__file__), 'README.md'), 'rb') as fileh:
|
2019-12-30 02:04:07 +00:00
|
|
|
return fileh.read().decode("utf8").replace('\r\n', '\n')
|
2017-09-09 08:59:51 +00:00
|
|
|
|
|
|
|
|
2015-11-22 20:12:13 +00:00
|
|
|
def getoutput(cmd, env=None):
|
2014-08-23 11:45:04 +00:00
|
|
|
import subprocess
|
2015-01-30 02:25:40 +00:00
|
|
|
p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE,
|
2015-11-22 20:12:13 +00:00
|
|
|
stderr=subprocess.PIPE, env=env)
|
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
|
2016-09-07 09:23:44 +00:00
|
|
|
print('WARNING: A problem occurred while running {0} (code {1})\n'
|
2015-01-30 02:25:40 +00:00
|
|
|
.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'}
|
2015-11-22 20:12:13 +00:00
|
|
|
lenviron = None
|
2016-04-24 17:35:14 +00:00
|
|
|
pconfig = join(sys.prefix, 'libs', 'pkgconfig')
|
2015-11-22 20:12:13 +00:00
|
|
|
|
|
|
|
if isdir(pconfig):
|
|
|
|
lenviron = environ.copy()
|
|
|
|
lenviron['PKG_CONFIG_PATH'] = '{};{}'.format(
|
|
|
|
environ.get('PKG_CONFIG_PATH', ''), pconfig)
|
2014-08-23 11:45:04 +00:00
|
|
|
cmd = 'pkg-config --libs --cflags {}'.format(' '.join(packages))
|
2015-11-22 20:12:13 +00:00
|
|
|
results = getoutput(cmd, lenviron).split()
|
2015-01-23 15:33:36 +00:00
|
|
|
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
|
|
|
|
|
|
|
|
|
2019-12-09 01:03:44 +00:00
|
|
|
def get_isolated_env_paths():
|
|
|
|
try:
|
|
|
|
# sdl2_dev is installed before setup.py is run, when installing from
|
|
|
|
# source due to pyproject.toml. However, it is installed to a
|
|
|
|
# pip isolated env, which we need to add to compiler
|
|
|
|
import kivy_deps.sdl2_dev as sdl2_dev
|
|
|
|
except ImportError:
|
|
|
|
return [], []
|
|
|
|
|
|
|
|
root = os.path.abspath(join(sdl2_dev.__path__[0], '../../../..'))
|
|
|
|
includes = [join(root, 'Include')] if isdir(join(root, 'Include')) else []
|
|
|
|
libs = [join(root, 'libs')] if isdir(join(root, 'libs')) else []
|
|
|
|
return includes, libs
|
|
|
|
|
|
|
|
|
2013-05-27 15:04:18 +00:00
|
|
|
# -----------------------------------------------------------------------------
|
|
|
|
# Determine on which platform we are
|
|
|
|
|
2020-09-16 01:50:34 +00:00
|
|
|
build_examples = build_examples or \
|
|
|
|
os.environ.get('KIVY_BUILD_EXAMPLES', '0') == '1'
|
|
|
|
|
2013-05-27 15:04:18 +00:00
|
|
|
platform = sys.platform
|
|
|
|
|
|
|
|
# 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'
|
2018-10-29 18:29:42 +00:00
|
|
|
# proprietary broadcom video core drivers
|
2013-05-27 15:04:18 +00:00
|
|
|
if exists('/opt/vc/include/bcm_host.h'):
|
2019-10-20 19:33:38 +00:00
|
|
|
# The proprietary broadcom video core drivers are not available on the
|
|
|
|
# Raspberry Pi 4
|
2020-01-09 19:42:36 +00:00
|
|
|
if (pi_version or 4) < 4:
|
2019-10-20 19:33:38 +00:00
|
|
|
platform = 'rpi'
|
2018-10-29 18:29:42 +00:00
|
|
|
# use mesa video core drivers
|
2019-10-21 21:50:06 +00:00
|
|
|
if environ.get('VIDEOCOREMESA', None) == '1':
|
2018-10-29 18:29:42 +00:00
|
|
|
platform = 'vc'
|
2019-02-08 22:23:00 +00:00
|
|
|
mali_paths = (
|
2019-02-09 15:19:22 +00:00
|
|
|
'/usr/lib/arm-linux-gnueabihf/libMali.so',
|
|
|
|
'/usr/lib/arm-linux-gnueabihf/mali-egl/libmali.so',
|
|
|
|
'/usr/local/mali-egl/libmali.so')
|
2019-02-08 22:23:00 +00:00
|
|
|
if any((exists(path) for path in mali_paths)):
|
2015-06-02 02:31:08 +00:00
|
|
|
platform = 'mali'
|
2013-05-27 15:04:18 +00:00
|
|
|
|
2019-03-05 10:47:47 +00:00
|
|
|
# Needed when cross-compiling
|
|
|
|
if environ.get('KIVY_CROSS_PLATFORM'):
|
|
|
|
platform = environ.get('KIVY_CROSS_PLATFORM')
|
|
|
|
|
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'
|
2015-06-02 02:31:08 +00:00
|
|
|
c_options['use_egl'] = False
|
2016-12-23 05:31:10 +00:00
|
|
|
c_options['use_opengl_es2'] = None
|
2016-01-08 23:57:32 +00:00
|
|
|
c_options['use_opengl_mock'] = environ.get('READTHEDOCS', None) == 'True'
|
2015-01-18 00:32:16 +00:00
|
|
|
c_options['use_sdl2'] = None
|
2018-03-16 00:53:04 +00:00
|
|
|
c_options['use_pangoft2'] = None
|
2014-08-23 11:45:04 +00:00
|
|
|
c_options['use_ios'] = False
|
2019-01-20 01:30:52 +00:00
|
|
|
c_options['use_android'] = False
|
2014-08-23 11:45:04 +00:00
|
|
|
c_options['use_mesagl'] = False
|
|
|
|
c_options['use_x11'] = False
|
2017-12-21 00:06:37 +00:00
|
|
|
c_options['use_wayland'] = False
|
2015-01-23 08:45:06 +00:00
|
|
|
c_options['use_gstreamer'] = None
|
2019-02-12 01:03:12 +00:00
|
|
|
c_options['use_avfoundation'] = platform in ['darwin', 'ios']
|
2015-01-07 18:53:39 +00:00
|
|
|
c_options['use_osx_frameworks'] = platform == 'darwin'
|
2015-06-12 19:24:17 +00:00
|
|
|
c_options['debug_gl'] = False
|
2012-02-23 23:25:20 +00:00
|
|
|
|
2020-03-13 15:15:45 +00:00
|
|
|
# Set the alpha size, this will be 0 on the Raspberry Pi and 8 on all other
|
|
|
|
# platforms, so SDL2 works without X11
|
|
|
|
c_options['kivy_sdl_gl_alpha_size'] = 8 if pi_version is None else 0
|
|
|
|
|
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:
|
2020-03-13 15:15:45 +00:00
|
|
|
# kivy_sdl_gl_alpha_size should be an integer, the rest are booleans
|
|
|
|
value = int(environ[ukey])
|
|
|
|
if key != 'kivy_sdl_gl_alpha_size':
|
|
|
|
value = bool(value)
|
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
|
|
|
|
|
2019-06-10 03:45:04 +00:00
|
|
|
use_embed_signature = environ.get('USE_EMBEDSIGNATURE', '0') == '1'
|
|
|
|
use_embed_signature = use_embed_signature or bool(
|
|
|
|
platform not in ('ios', 'android'))
|
Windows: add support for ANGLE as an alternative for GL rendering
This can be achieve by asking a ES profile implementation to SDL2, and compile then copy ANGLE libEGL.dll and libGLESv2.dll to c:\Python27\share\sdl2\bin.
Support in kivy for ANGLE must be activated at compilation: USE_ANGLE=1 make
The changes intruduce a "dynamic" opengl backend, that uses SDL2 GetProcAddress to gather all the GL pointers that we need for opengl, and expose them in "cgl" context.
All the graphics implementation now use cgl (either a module or the new context for dynamic gl) as a base for accessing GL functions. The GL definitions are extracted and shared in c_opengl_def.
ANGLE give us:
- ability to execute Kivy application with default driver (at least for Virtualbox and intel, no need to install specific vendor graphics)
- works starting Direct3d 9 support (use dxdiag to find out)
- works on older computer (intel drop opengl support older graphics card (< 2011, according to a customer) on Windows 10 while there where no issue on Windows 7)
Known issues:
- stencil doesn't work on Windows 7 on Virtual BOX, but even their samples doesn't work, while firefox and chrome that uses angle (according to http://www.browserleaks.com/webgl)
- line doesn't show on Windows 10
TODO:
- continue to separate fully the GL context in order to dynamically switch to another implementation at runtime
- be able to use MOCK without recompilation
- be able to use DEBUG opengl (check glGetError after every command) without recompilation
- be able to either use DESKTOP opengl or ANGLE opengl without recompilation
- stencil fixes or alternative
- line fixes or alternative
Suggestions:
- if stencil is really an issue, there is a possibility to use scissor. It might be faster, but doesn't support stack, and have addional limitation, such as: scissor must be aligned to the windows while stencil can be rotated + position of the scissor must be in windows coordinate. They may have a possibility to make "hybrid" instructions that either use scissor or stencil depending the current matrix. On standard ui (without any scatter/rotation), only scissor would be used.
2016-05-30 21:51:36 +00:00
|
|
|
|
2012-02-23 23:25:20 +00:00
|
|
|
# -----------------------------------------------------------------------------
|
Change check for Cython to attempt fallback to setuptools on supporte… (#5998)
* Change check for Cython to attempt fallback to setuptools on supported platforms.
This attempts to solve Issue #5984 without causing more problems for Issue #5558.
* Correct argument to extras_require.
* Refactor the declaration and usage of Cython
- Use setuptools.setup by default if available for import.
- The objective for that complicated import/cython is commented.
- Also have more specific variable names, and have their usage be
clarified.
- Remove Cython from install_requires as it already is declared under
setup_requires, and that it conflicts with install_requires due to
issues in setuptools.
- https://github.com/pypa/setuptools/issues/209
- https://github.com/pypa/setuptools/issues/391
- This commit goes back to breaking installation in environments without
Cython, but should be rectified in the next commit.
* Actually fix the specific usage of Cython
- In order for setup.py to make use of the Cython installed during by
the setup_requires to be usable, it must be imported after it is
installed by that step, thus it cannot be done at the top level and
this can be achieved by importing it when it's actually called. A
build_ext factory function is created for this.
- Still allow whatever Cython already present on the current environment
be attempted to be used. This may end up being unnecessary as if it
is always declared in setup_requires (which isn't currently the case
due to the complicated/documented block), it _should_ pull in the
exact/supported version of Cython for usage. This should be
investigated so that this complicated logic may be avoided.
* Make distutils happy by not using factory function
- As it turns out, calling setup.py build_ext will result in a code path
within setuptools that will invoke distutils in a way that forces an
issubclass check, which ultimately results in an exception due to that
function not being a class.
- To fix this, we go back to constructing a base class except also using
the "new" style class (to make Python 2 happy) so that the __new__
method will actually be called so that the logic to select the Cython
version of build_ext will be invoked.
- Also use the super class protocol to invoke parent methods.
* Declare version bounds directly on setup_requires
- This allows us to fully remove the brittle version checks
- Also this allows us to directly declare setup_requires if Cython is
definitely required, as this would allow the correct version to be
installed directly by setuptools during the execution of the setup
step.
- No need to check for failed Cython imports due to the presence of the
setup_requires declaration.
* Add comment explaining the initialisation routine for KivyBuildExt.
Details of how setuptools deals with both cmdclass and when setup_requires
dependencies come in to scope are both relevant.
* Bring comment in to line with earlier changes.
The cython checks are significantly simpler now, and the rationale is also slightly different.
2019-03-04 10:49:42 +00:00
|
|
|
# We want to be able to install kivy as a wheel without a dependency
|
|
|
|
# on cython, but we also want to use cython where possible as a setup
|
2019-12-09 01:03:44 +00:00
|
|
|
# time dependency through `pyproject.toml` if building from source.
|
Change check for Cython to attempt fallback to setuptools on supporte… (#5998)
* Change check for Cython to attempt fallback to setuptools on supported platforms.
This attempts to solve Issue #5984 without causing more problems for Issue #5558.
* Correct argument to extras_require.
* Refactor the declaration and usage of Cython
- Use setuptools.setup by default if available for import.
- The objective for that complicated import/cython is commented.
- Also have more specific variable names, and have their usage be
clarified.
- Remove Cython from install_requires as it already is declared under
setup_requires, and that it conflicts with install_requires due to
issues in setuptools.
- https://github.com/pypa/setuptools/issues/209
- https://github.com/pypa/setuptools/issues/391
- This commit goes back to breaking installation in environments without
Cython, but should be rectified in the next commit.
* Actually fix the specific usage of Cython
- In order for setup.py to make use of the Cython installed during by
the setup_requires to be usable, it must be imported after it is
installed by that step, thus it cannot be done at the top level and
this can be achieved by importing it when it's actually called. A
build_ext factory function is created for this.
- Still allow whatever Cython already present on the current environment
be attempted to be used. This may end up being unnecessary as if it
is always declared in setup_requires (which isn't currently the case
due to the complicated/documented block), it _should_ pull in the
exact/supported version of Cython for usage. This should be
investigated so that this complicated logic may be avoided.
* Make distutils happy by not using factory function
- As it turns out, calling setup.py build_ext will result in a code path
within setuptools that will invoke distutils in a way that forces an
issubclass check, which ultimately results in an exception due to that
function not being a class.
- To fix this, we go back to constructing a base class except also using
the "new" style class (to make Python 2 happy) so that the __new__
method will actually be called so that the logic to select the Cython
version of build_ext will be invoked.
- Also use the super class protocol to invoke parent methods.
* Declare version bounds directly on setup_requires
- This allows us to fully remove the brittle version checks
- Also this allows us to directly declare setup_requires if Cython is
definitely required, as this would allow the correct version to be
installed directly by setuptools during the execution of the setup
step.
- No need to check for failed Cython imports due to the presence of the
setup_requires declaration.
* Add comment explaining the initialisation routine for KivyBuildExt.
Details of how setuptools deals with both cmdclass and when setup_requires
dependencies come in to scope are both relevant.
* Bring comment in to line with earlier changes.
The cython checks are significantly simpler now, and the rationale is also slightly different.
2019-03-04 10:49:42 +00:00
|
|
|
|
|
|
|
# There are issues with using cython at all on some platforms;
|
|
|
|
# exclude them from using or declaring cython.
|
|
|
|
|
|
|
|
# This determines whether Cython specific functionality may be used.
|
|
|
|
can_use_cython = True
|
|
|
|
|
2018-06-16 15:40:39 +00:00
|
|
|
if platform in ('ios', 'android'):
|
Change check for Cython to attempt fallback to setuptools on supporte… (#5998)
* Change check for Cython to attempt fallback to setuptools on supported platforms.
This attempts to solve Issue #5984 without causing more problems for Issue #5558.
* Correct argument to extras_require.
* Refactor the declaration and usage of Cython
- Use setuptools.setup by default if available for import.
- The objective for that complicated import/cython is commented.
- Also have more specific variable names, and have their usage be
clarified.
- Remove Cython from install_requires as it already is declared under
setup_requires, and that it conflicts with install_requires due to
issues in setuptools.
- https://github.com/pypa/setuptools/issues/209
- https://github.com/pypa/setuptools/issues/391
- This commit goes back to breaking installation in environments without
Cython, but should be rectified in the next commit.
* Actually fix the specific usage of Cython
- In order for setup.py to make use of the Cython installed during by
the setup_requires to be usable, it must be imported after it is
installed by that step, thus it cannot be done at the top level and
this can be achieved by importing it when it's actually called. A
build_ext factory function is created for this.
- Still allow whatever Cython already present on the current environment
be attempted to be used. This may end up being unnecessary as if it
is always declared in setup_requires (which isn't currently the case
due to the complicated/documented block), it _should_ pull in the
exact/supported version of Cython for usage. This should be
investigated so that this complicated logic may be avoided.
* Make distutils happy by not using factory function
- As it turns out, calling setup.py build_ext will result in a code path
within setuptools that will invoke distutils in a way that forces an
issubclass check, which ultimately results in an exception due to that
function not being a class.
- To fix this, we go back to constructing a base class except also using
the "new" style class (to make Python 2 happy) so that the __new__
method will actually be called so that the logic to select the Cython
version of build_ext will be invoked.
- Also use the super class protocol to invoke parent methods.
* Declare version bounds directly on setup_requires
- This allows us to fully remove the brittle version checks
- Also this allows us to directly declare setup_requires if Cython is
definitely required, as this would allow the correct version to be
installed directly by setuptools during the execution of the setup
step.
- No need to check for failed Cython imports due to the presence of the
setup_requires declaration.
* Add comment explaining the initialisation routine for KivyBuildExt.
Details of how setuptools deals with both cmdclass and when setup_requires
dependencies come in to scope are both relevant.
* Bring comment in to line with earlier changes.
The cython checks are significantly simpler now, and the rationale is also slightly different.
2019-03-04 10:49:42 +00:00
|
|
|
# NEVER use or declare cython on these platforms
|
|
|
|
print('Not using cython on %s' % platform)
|
|
|
|
can_use_cython = False
|
2019-11-29 15:00: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__)
|
2019-09-05 03:33:02 +00:00
|
|
|
print("Current directory is: {}".format(os.getcwd()))
|
|
|
|
print("Source and initial build directory is: {}".format(src_path))
|
2015-01-18 00:30:14 +00:00
|
|
|
|
2020-09-14 20:17:19 +00:00
|
|
|
# __version__ is imported by exec, but help linter not complain
|
|
|
|
__version__ = None
|
|
|
|
with open(join(src_path, 'kivy', '_version.py'), encoding="utf-8") as f:
|
|
|
|
exec(f.read())
|
|
|
|
|
2014-08-23 11:45:04 +00:00
|
|
|
|
Change check for Cython to attempt fallback to setuptools on supporte… (#5998)
* Change check for Cython to attempt fallback to setuptools on supported platforms.
This attempts to solve Issue #5984 without causing more problems for Issue #5558.
* Correct argument to extras_require.
* Refactor the declaration and usage of Cython
- Use setuptools.setup by default if available for import.
- The objective for that complicated import/cython is commented.
- Also have more specific variable names, and have their usage be
clarified.
- Remove Cython from install_requires as it already is declared under
setup_requires, and that it conflicts with install_requires due to
issues in setuptools.
- https://github.com/pypa/setuptools/issues/209
- https://github.com/pypa/setuptools/issues/391
- This commit goes back to breaking installation in environments without
Cython, but should be rectified in the next commit.
* Actually fix the specific usage of Cython
- In order for setup.py to make use of the Cython installed during by
the setup_requires to be usable, it must be imported after it is
installed by that step, thus it cannot be done at the top level and
this can be achieved by importing it when it's actually called. A
build_ext factory function is created for this.
- Still allow whatever Cython already present on the current environment
be attempted to be used. This may end up being unnecessary as if it
is always declared in setup_requires (which isn't currently the case
due to the complicated/documented block), it _should_ pull in the
exact/supported version of Cython for usage. This should be
investigated so that this complicated logic may be avoided.
* Make distutils happy by not using factory function
- As it turns out, calling setup.py build_ext will result in a code path
within setuptools that will invoke distutils in a way that forces an
issubclass check, which ultimately results in an exception due to that
function not being a class.
- To fix this, we go back to constructing a base class except also using
the "new" style class (to make Python 2 happy) so that the __new__
method will actually be called so that the logic to select the Cython
version of build_ext will be invoked.
- Also use the super class protocol to invoke parent methods.
* Declare version bounds directly on setup_requires
- This allows us to fully remove the brittle version checks
- Also this allows us to directly declare setup_requires if Cython is
definitely required, as this would allow the correct version to be
installed directly by setuptools during the execution of the setup
step.
- No need to check for failed Cython imports due to the presence of the
setup_requires declaration.
* Add comment explaining the initialisation routine for KivyBuildExt.
Details of how setuptools deals with both cmdclass and when setup_requires
dependencies come in to scope are both relevant.
* Bring comment in to line with earlier changes.
The cython checks are significantly simpler now, and the rationale is also slightly different.
2019-03-04 10:49:42 +00:00
|
|
|
class KivyBuildExt(build_ext, object):
|
|
|
|
|
|
|
|
def __new__(cls, *a, **kw):
|
|
|
|
# Note how this class is declared as a subclass of distutils
|
|
|
|
# build_ext as the Cython version may not be available in the
|
|
|
|
# environment it is initially started in. However, if Cython
|
|
|
|
# can be used, setuptools will bring Cython into the environment
|
|
|
|
# thus its version of build_ext will become available.
|
|
|
|
# The reason why this is done as a __new__ rather than through a
|
|
|
|
# factory function is because there are distutils functions that check
|
|
|
|
# the values provided by cmdclass with issublcass, and so it would
|
|
|
|
# result in an exception.
|
|
|
|
# The following essentially supply a dynamically generated subclass
|
|
|
|
# that mix in the cython version of build_ext so that the
|
|
|
|
# functionality provided will also be executed.
|
|
|
|
if can_use_cython:
|
|
|
|
from Cython.Distutils import build_ext as cython_build_ext
|
|
|
|
build_ext_cls = type(
|
|
|
|
'KivyBuildExt', (KivyBuildExt, cython_build_ext), {})
|
|
|
|
return super(KivyBuildExt, cls).__new__(build_ext_cls)
|
|
|
|
else:
|
|
|
|
return super(KivyBuildExt, cls).__new__(cls)
|
2018-06-16 15:40:39 +00:00
|
|
|
|
|
|
|
def finalize_options(self):
|
Change check for Cython to attempt fallback to setuptools on supporte… (#5998)
* Change check for Cython to attempt fallback to setuptools on supported platforms.
This attempts to solve Issue #5984 without causing more problems for Issue #5558.
* Correct argument to extras_require.
* Refactor the declaration and usage of Cython
- Use setuptools.setup by default if available for import.
- The objective for that complicated import/cython is commented.
- Also have more specific variable names, and have their usage be
clarified.
- Remove Cython from install_requires as it already is declared under
setup_requires, and that it conflicts with install_requires due to
issues in setuptools.
- https://github.com/pypa/setuptools/issues/209
- https://github.com/pypa/setuptools/issues/391
- This commit goes back to breaking installation in environments without
Cython, but should be rectified in the next commit.
* Actually fix the specific usage of Cython
- In order for setup.py to make use of the Cython installed during by
the setup_requires to be usable, it must be imported after it is
installed by that step, thus it cannot be done at the top level and
this can be achieved by importing it when it's actually called. A
build_ext factory function is created for this.
- Still allow whatever Cython already present on the current environment
be attempted to be used. This may end up being unnecessary as if it
is always declared in setup_requires (which isn't currently the case
due to the complicated/documented block), it _should_ pull in the
exact/supported version of Cython for usage. This should be
investigated so that this complicated logic may be avoided.
* Make distutils happy by not using factory function
- As it turns out, calling setup.py build_ext will result in a code path
within setuptools that will invoke distutils in a way that forces an
issubclass check, which ultimately results in an exception due to that
function not being a class.
- To fix this, we go back to constructing a base class except also using
the "new" style class (to make Python 2 happy) so that the __new__
method will actually be called so that the logic to select the Cython
version of build_ext will be invoked.
- Also use the super class protocol to invoke parent methods.
* Declare version bounds directly on setup_requires
- This allows us to fully remove the brittle version checks
- Also this allows us to directly declare setup_requires if Cython is
definitely required, as this would allow the correct version to be
installed directly by setuptools during the execution of the setup
step.
- No need to check for failed Cython imports due to the presence of the
setup_requires declaration.
* Add comment explaining the initialisation routine for KivyBuildExt.
Details of how setuptools deals with both cmdclass and when setup_requires
dependencies come in to scope are both relevant.
* Bring comment in to line with earlier changes.
The cython checks are significantly simpler now, and the rationale is also slightly different.
2019-03-04 10:49:42 +00:00
|
|
|
retval = super(KivyBuildExt, self).finalize_options()
|
2020-03-13 15:32:22 +00:00
|
|
|
|
|
|
|
# Build the extensions in parallel if the options has not been set
|
|
|
|
if hasattr(self, 'parallel') and self.parallel is None:
|
2020-03-14 20:20:33 +00:00
|
|
|
# Use a maximum of 4 cores. If cpu_count returns None, then parallel
|
|
|
|
# build will be disabled
|
|
|
|
self.parallel = min(4, os.cpu_count() or 0)
|
|
|
|
if self.parallel:
|
2020-03-15 23:26:42 +00:00
|
|
|
print('Building extensions in parallel using {} cores'.format(
|
|
|
|
self.parallel))
|
2020-03-13 15:32:22 +00:00
|
|
|
|
2018-06-16 15:40:39 +00:00
|
|
|
global build_path
|
|
|
|
if (self.build_lib is not None and exists(self.build_lib) and
|
|
|
|
not self.inplace):
|
|
|
|
build_path = self.build_lib
|
2019-09-05 03:33:02 +00:00
|
|
|
print("Updated build directory to: {}".format(build_path))
|
2020-03-13 15:32:22 +00:00
|
|
|
|
2018-06-16 15:40:39 +00:00
|
|
|
return retval
|
|
|
|
|
|
|
|
def build_extensions(self):
|
2015-01-18 00:32:16 +00:00
|
|
|
# build files
|
2016-12-18 21:22:44 +00:00
|
|
|
config_h_fn = ('include', 'config.h')
|
|
|
|
config_pxi_fn = ('include', 'config.pxi')
|
2015-01-28 19:45:24 +00:00
|
|
|
config_py_fn = ('setupconfig.py', )
|
2015-01-18 00:32:16 +00:00
|
|
|
|
|
|
|
# generate headers
|
|
|
|
config_h = '// Autogenerated file for Kivy C configuration\n'
|
2019-06-01 23:29:09 +00:00
|
|
|
config_h += '#define __PY3 1\n'
|
2015-01-18 00:32:16 +00:00
|
|
|
config_pxi = '# Autogenerated file for Kivy Cython configuration\n'
|
2019-06-01 23:29:09 +00:00
|
|
|
config_pxi += 'DEF PY3 = 1\n'
|
2015-01-18 00:32:16 +00:00
|
|
|
config_py = '# Autogenerated file for Kivy configuration\n'
|
2019-06-01 23:29:09 +00:00
|
|
|
config_py += 'PY3 = 1\n'
|
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():
|
2020-03-13 15:15:45 +00:00
|
|
|
# kivy_sdl_gl_alpha_size is already an integer
|
|
|
|
if opt != 'kivy_sdl_gl_alpha_size':
|
|
|
|
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)
|
2018-06-16 15:40:39 +00:00
|
|
|
debug = bool(self.debug)
|
2014-06-16 16:57:01 +00:00
|
|
|
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)
|
Windows: add support for ANGLE as an alternative for GL rendering
This can be achieve by asking a ES profile implementation to SDL2, and compile then copy ANGLE libEGL.dll and libGLESv2.dll to c:\Python27\share\sdl2\bin.
Support in kivy for ANGLE must be activated at compilation: USE_ANGLE=1 make
The changes intruduce a "dynamic" opengl backend, that uses SDL2 GetProcAddress to gather all the GL pointers that we need for opengl, and expose them in "cgl" context.
All the graphics implementation now use cgl (either a module or the new context for dynamic gl) as a base for accessing GL functions. The GL definitions are extracted and shared in c_opengl_def.
ANGLE give us:
- ability to execute Kivy application with default driver (at least for Virtualbox and intel, no need to install specific vendor graphics)
- works starting Direct3d 9 support (use dxdiag to find out)
- works on older computer (intel drop opengl support older graphics card (< 2011, according to a customer) on Windows 10 while there where no issue on Windows 7)
Known issues:
- stencil doesn't work on Windows 7 on Virtual BOX, but even their samples doesn't work, while firefox and chrome that uses angle (according to http://www.browserleaks.com/webgl)
- line doesn't show on Windows 10
TODO:
- continue to separate fully the GL context in order to dynamically switch to another implementation at runtime
- be able to use MOCK without recompilation
- be able to use DEBUG opengl (check glGetError after every command) without recompilation
- be able to either use DESKTOP opengl or ANGLE opengl without recompilation
- stencil fixes or alternative
- line fixes or alternative
Suggestions:
- if stencil is really an issue, there is a possibility to use scissor. It might be faster, but doesn't support stack, and have addional limitation, such as: scissor must be aligned to the windows while stencil can be rotated + position of the scissor must be in windows coordinate. They may have a possibility to make "hybrid" instructions that either use scissor or stencil depending the current matrix. On standard ui (without any scatter/rotation), only scissor would be used.
2016-05-30 21:51:36 +00:00
|
|
|
config_pxi += 'DEF PLATFORM = "{0}"\n'.format(platform)
|
|
|
|
config_py += 'PLATFORM = "{0}"\n'.format(platform)
|
2015-01-18 00:30:14 +00:00
|
|
|
for fn, content in (
|
2018-06-16 15:40:39 +00:00
|
|
|
(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)
|
2018-06-16 15:40:39 +00:00
|
|
|
if self.update_if_changed(build_fn, content):
|
2015-01-28 19:45:24 +00:00
|
|
|
print('Updated {}'.format(build_fn))
|
|
|
|
src_fn = expand(src_path, *fn)
|
2018-06-16 15:40:39 +00:00
|
|
|
if src_fn != build_fn and self.update_if_changed(src_fn, content):
|
2015-01-28 19:45:24 +00:00
|
|
|
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
|
|
|
|
Change check for Cython to attempt fallback to setuptools on supporte… (#5998)
* Change check for Cython to attempt fallback to setuptools on supported platforms.
This attempts to solve Issue #5984 without causing more problems for Issue #5558.
* Correct argument to extras_require.
* Refactor the declaration and usage of Cython
- Use setuptools.setup by default if available for import.
- The objective for that complicated import/cython is commented.
- Also have more specific variable names, and have their usage be
clarified.
- Remove Cython from install_requires as it already is declared under
setup_requires, and that it conflicts with install_requires due to
issues in setuptools.
- https://github.com/pypa/setuptools/issues/209
- https://github.com/pypa/setuptools/issues/391
- This commit goes back to breaking installation in environments without
Cython, but should be rectified in the next commit.
* Actually fix the specific usage of Cython
- In order for setup.py to make use of the Cython installed during by
the setup_requires to be usable, it must be imported after it is
installed by that step, thus it cannot be done at the top level and
this can be achieved by importing it when it's actually called. A
build_ext factory function is created for this.
- Still allow whatever Cython already present on the current environment
be attempted to be used. This may end up being unnecessary as if it
is always declared in setup_requires (which isn't currently the case
due to the complicated/documented block), it _should_ pull in the
exact/supported version of Cython for usage. This should be
investigated so that this complicated logic may be avoided.
* Make distutils happy by not using factory function
- As it turns out, calling setup.py build_ext will result in a code path
within setuptools that will invoke distutils in a way that forces an
issubclass check, which ultimately results in an exception due to that
function not being a class.
- To fix this, we go back to constructing a base class except also using
the "new" style class (to make Python 2 happy) so that the __new__
method will actually be called so that the logic to select the Cython
version of build_ext will be invoked.
- Also use the super class protocol to invoke parent methods.
* Declare version bounds directly on setup_requires
- This allows us to fully remove the brittle version checks
- Also this allows us to directly declare setup_requires if Cython is
definitely required, as this would allow the correct version to be
installed directly by setuptools during the execution of the setup
step.
- No need to check for failed Cython imports due to the presence of the
setup_requires declaration.
* Add comment explaining the initialisation routine for KivyBuildExt.
Details of how setuptools deals with both cmdclass and when setup_requires
dependencies come in to scope are both relevant.
* Bring comment in to line with earlier changes.
The cython checks are significantly simpler now, and the rationale is also slightly different.
2019-03-04 10:49:42 +00:00
|
|
|
super(KivyBuildExt, self).build_extensions()
|
2012-02-23 23:25:20 +00:00
|
|
|
|
2018-06-16 15:40:39 +00:00
|
|
|
def update_if_changed(self, fn, content):
|
2014-08-23 11:45:04 +00:00
|
|
|
need_update = True
|
|
|
|
if exists(fn):
|
|
|
|
with open(fn) as fd:
|
|
|
|
need_update = fd.read() != content
|
|
|
|
if need_update:
|
2019-01-20 01:30:52 +00:00
|
|
|
directory_name = dirname(fn)
|
|
|
|
if not exists(directory_name):
|
|
|
|
makedirs(directory_name)
|
2014-08-23 11:45:04 +00:00
|
|
|
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
|
|
|
|
2015-11-29 18:04:10 +00:00
|
|
|
def _check_and_fix_sdl2_mixer(f_path):
|
2019-03-06 07:46:50 +00:00
|
|
|
# Between SDL_mixer 2.0.1 and 2.0.4, the included frameworks changed
|
|
|
|
# smpeg2 have been replaced with mpg123, but there is no need to fix.
|
|
|
|
smpeg2_path = ("{}/Versions/A/Frameworks/smpeg2.framework"
|
|
|
|
"/Versions/A/smpeg2").format(f_path)
|
|
|
|
if not exists(smpeg2_path):
|
|
|
|
return
|
|
|
|
|
2015-11-29 18:04:10 +00:00
|
|
|
print("Check if SDL2_mixer smpeg2 have an @executable_path")
|
2016-12-17 07:50:52 +00:00
|
|
|
rpath_from = ("@executable_path/../Frameworks/SDL2.framework"
|
2017-01-27 23:11:12 +00:00
|
|
|
"/Versions/A/SDL2")
|
2015-11-29 18:04:10 +00:00
|
|
|
rpath_to = "@rpath/../../../../SDL2.framework/Versions/A/SDL2"
|
2015-12-17 17:28:53 +00:00
|
|
|
output = getoutput(("otool -L '{}'").format(smpeg2_path)).decode('utf-8')
|
2015-11-29 18:04:10 +00:00
|
|
|
if "@executable_path" not in output:
|
|
|
|
return
|
|
|
|
|
|
|
|
print("WARNING: Your SDL2_mixer version is invalid")
|
|
|
|
print("WARNING: The smpeg2 framework embedded in SDL2_mixer contains a")
|
|
|
|
print("WARNING: reference to @executable_path that will fail the")
|
|
|
|
print("WARNING: execution of your application.")
|
|
|
|
print("WARNING: We are going to change:")
|
|
|
|
print("WARNING: from: {}".format(rpath_from))
|
|
|
|
print("WARNING: to: {}".format(rpath_to))
|
|
|
|
getoutput("install_name_tool -change {} {} {}".format(
|
|
|
|
rpath_from, rpath_to, smpeg2_path))
|
|
|
|
|
|
|
|
output = getoutput(("otool -L '{}'").format(smpeg2_path))
|
2015-12-26 10:09:45 +00:00
|
|
|
if b"@executable_path" not in output:
|
2015-11-29 18:04:10 +00:00
|
|
|
print("WARNING: Change successfully applied!")
|
|
|
|
print("WARNING: You'll never see this message again.")
|
|
|
|
else:
|
|
|
|
print("WARNING: Unable to apply the changes, sorry.")
|
|
|
|
|
2016-12-17 07:50:52 +00:00
|
|
|
|
2012-02-23 23:25:20 +00:00
|
|
|
# -----------------------------------------------------------------------------
|
2019-09-05 03:33:02 +00:00
|
|
|
print("Python path is:\n{}\n".format('\n'.join(sys.path)))
|
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
|
|
|
|
|
2019-06-03 02:48:20 +00:00
|
|
|
# Cython check
|
|
|
|
# on python-for-android and kivy-ios, cython usage is external
|
|
|
|
from kivy.tools.packaging.cython_cfg import get_cython_versions, get_cython_msg
|
|
|
|
CYTHON_REQUIRES_STRING, MIN_CYTHON_STRING, MAX_CYTHON_STRING, \
|
|
|
|
CYTHON_UNSUPPORTED = get_cython_versions()
|
|
|
|
cython_min_msg, cython_max_msg, cython_unsupported_msg = get_cython_msg()
|
|
|
|
|
|
|
|
if can_use_cython:
|
|
|
|
import Cython
|
|
|
|
print('\nFound Cython at', Cython.__file__)
|
|
|
|
|
|
|
|
cy_version_str = Cython.__version__
|
|
|
|
cy_ver = LooseVersion(cy_version_str)
|
|
|
|
print('Detected supported Cython version {}'.format(cy_version_str))
|
|
|
|
|
|
|
|
if cy_ver < LooseVersion(MIN_CYTHON_STRING):
|
|
|
|
print(cython_min_msg)
|
|
|
|
elif cy_ver in CYTHON_UNSUPPORTED:
|
|
|
|
print(cython_unsupported_msg)
|
|
|
|
elif cy_ver > LooseVersion(MAX_CYTHON_STRING):
|
|
|
|
print(cython_max_msg)
|
|
|
|
sleep(1)
|
|
|
|
|
2010-11-03 21:05:03 +00:00
|
|
|
# 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
|
|
|
|
2016-12-23 05:31:10 +00:00
|
|
|
# Detect which opengl version headers to use
|
2018-10-29 18:29:42 +00:00
|
|
|
if platform in ('android', 'darwin', 'ios', 'rpi', 'mali', 'vc'):
|
2016-12-23 05:31:10 +00:00
|
|
|
c_options['use_opengl_es2'] = True
|
|
|
|
elif c_options['use_opengl_es2'] is None:
|
|
|
|
c_options['use_opengl_es2'] = \
|
|
|
|
environ.get('KIVY_GRAPHICS', '').lower() == 'gles'
|
|
|
|
|
|
|
|
print('Using this graphics system: {}'.format(
|
2016-12-27 01:19:34 +00:00
|
|
|
['OpenGL', 'OpenGL ES 2'][int(c_options['use_opengl_es2'] or False)]))
|
2016-12-23 05:31:10 +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-02-24 00:51:31 +00:00
|
|
|
c_options['use_ios'] = True
|
2015-02-13 17:36:27 +00:00
|
|
|
c_options['use_sdl2'] = True
|
2011-01-25 16:41:09 +00:00
|
|
|
|
2019-01-20 01:30:52 +00:00
|
|
|
elif platform == 'android':
|
|
|
|
c_options['use_android'] = True
|
|
|
|
|
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)):
|
2017-05-04 22:50:27 +00:00
|
|
|
gstreamer_valid = False
|
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
|
2017-05-04 22:50:27 +00:00
|
|
|
print('GStreamer framework not found, fallback on pkg-config')
|
2015-01-07 18:53:39 +00:00
|
|
|
else:
|
2017-05-04 22:50:27 +00:00
|
|
|
print('GStreamer framework found')
|
|
|
|
gstreamer_valid = True
|
2015-01-07 18:53:39 +00:00
|
|
|
c_options['use_gstreamer'] = True
|
|
|
|
gst_flags = {
|
|
|
|
'extra_link_args': [
|
2015-11-29 18:04:10 +00:00
|
|
|
'-F/Library/Frameworks',
|
|
|
|
'-Xlinker', '-rpath',
|
|
|
|
'-Xlinker', '/Library/Frameworks',
|
2015-01-07 18:53:39 +00:00
|
|
|
'-Xlinker', '-headerpad',
|
|
|
|
'-Xlinker', '190',
|
|
|
|
'-framework', 'GStreamer'],
|
|
|
|
'include_dirs': [join(f_path, 'Headers')]}
|
2019-04-27 09:48:51 +00:00
|
|
|
elif platform == 'win32':
|
|
|
|
gst_flags = pkgconfig('gstreamer-1.0')
|
|
|
|
if 'libraries' in gst_flags:
|
|
|
|
print('GStreamer found via pkg-config')
|
|
|
|
gstreamer_valid = True
|
|
|
|
c_options['use_gstreamer'] = True
|
2019-12-09 01:03:44 +00:00
|
|
|
else:
|
|
|
|
_includes = get_isolated_env_paths()[0] + [get_paths()['include']]
|
|
|
|
for include_dir in _includes:
|
|
|
|
if exists(join(include_dir, 'gst', 'gst.h')):
|
|
|
|
print('GStreamer found via gst.h')
|
|
|
|
gstreamer_valid = True
|
|
|
|
c_options['use_gstreamer'] = True
|
|
|
|
gst_flags = {
|
|
|
|
'libraries':
|
|
|
|
['gstreamer-1.0', 'glib-2.0', 'gobject-2.0']}
|
|
|
|
break
|
2015-01-07 18:53:39 +00:00
|
|
|
|
2017-05-04 22:50:27 +00:00
|
|
|
if not gstreamer_valid:
|
2015-01-18 00:32:16 +00:00
|
|
|
# use pkg-config approach instead
|
|
|
|
gst_flags = pkgconfig('gstreamer-1.0')
|
|
|
|
if 'libraries' in gst_flags:
|
2017-05-04 22:50:27 +00:00
|
|
|
print('GStreamer found via pkg-config')
|
2015-01-18 00:32:16 +00:00
|
|
|
c_options['use_gstreamer'] = True
|
|
|
|
|
|
|
|
|
2015-09-22 21:08:51 +00:00
|
|
|
# detect SDL2, only on desktop and iOS, or android if explicitly enabled
|
2015-01-18 00:32:16 +00:00
|
|
|
# works if we forced the options or in autodetection
|
|
|
|
sdl2_flags = {}
|
2019-12-28 05:22:00 +00:00
|
|
|
if platform == 'win32' and c_options['use_sdl2'] is None:
|
|
|
|
c_options['use_sdl2'] = True
|
|
|
|
|
2015-09-22 21:08:51 +00:00
|
|
|
if c_options['use_sdl2'] or (
|
|
|
|
platform not in ('android',) and c_options['use_sdl2'] is None):
|
2015-01-18 00:32:16 +00:00
|
|
|
|
2017-05-04 22:50:27 +00:00
|
|
|
sdl2_valid = False
|
2015-01-18 00:32:16 +00:00
|
|
|
if c_options['use_osx_frameworks'] and platform == 'darwin':
|
|
|
|
# check the existence of frameworks
|
2021-12-09 17:15:25 +00:00
|
|
|
sdl2_frameworks_search_path = environ.get(
|
|
|
|
"KIVY_SDL2_FRAMEWORKS_SEARCH_PATH", "/Library/Frameworks"
|
|
|
|
)
|
2015-01-07 18:53:39 +00:00
|
|
|
sdl2_valid = True
|
|
|
|
sdl2_flags = {
|
|
|
|
'extra_link_args': [
|
2021-12-09 17:15:25 +00:00
|
|
|
'-F{}'.format(sdl2_frameworks_search_path),
|
2015-11-29 18:04:10 +00:00
|
|
|
'-Xlinker', '-rpath',
|
2021-12-09 17:15:25 +00:00
|
|
|
'-Xlinker', sdl2_frameworks_search_path,
|
2015-01-07 18:53:39 +00:00
|
|
|
'-Xlinker', '-headerpad',
|
|
|
|
'-Xlinker', '190'],
|
2015-11-29 18:04:10 +00:00
|
|
|
'include_dirs': [],
|
2021-12-09 17:15:25 +00:00
|
|
|
'extra_compile_args': ['-F{}'.format(sdl2_frameworks_search_path)]
|
2015-01-07 18:53:39 +00:00
|
|
|
}
|
|
|
|
for name in ('SDL2', 'SDL2_ttf', 'SDL2_image', 'SDL2_mixer'):
|
2021-12-09 17:15:25 +00:00
|
|
|
f_path = '{}/{}.framework'.format(sdl2_frameworks_search_path, name)
|
2015-01-07 18:53:39 +00:00
|
|
|
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))
|
2015-11-29 18:04:10 +00:00
|
|
|
if name == 'SDL2_mixer':
|
|
|
|
_check_and_fix_sdl2_mixer(f_path)
|
2015-01-07 18:53:39 +00:00
|
|
|
|
|
|
|
if not sdl2_valid:
|
|
|
|
c_options['use_sdl2'] = False
|
2017-05-04 22:50:27 +00:00
|
|
|
print('SDL2 frameworks not found, fallback on pkg-config')
|
2015-01-07 18:53:39 +00:00
|
|
|
else:
|
|
|
|
c_options['use_sdl2'] = True
|
|
|
|
print('Activate SDL2 compilation')
|
|
|
|
|
2017-05-04 22:50:27 +00:00
|
|
|
if not sdl2_valid and platform != "ios":
|
2015-01-07 18:53:39 +00:00
|
|
|
# use pkg-config approach instead
|
|
|
|
sdl2_flags = pkgconfig('sdl2', 'SDL2_ttf', 'SDL2_image', 'SDL2_mixer')
|
|
|
|
if 'libraries' in sdl2_flags:
|
2017-05-04 22:50:27 +00:00
|
|
|
print('SDL2 found via pkg-config')
|
2015-01-07 18:53:39 +00:00
|
|
|
c_options['use_sdl2'] = True
|
|
|
|
|
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
|
|
|
|
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,
|
2019-06-10 06:16:20 +00:00
|
|
|
'embedsignature': use_embed_signature,
|
2019-06-10 03:01:07 +00:00
|
|
|
'language_level': 3,
|
|
|
|
'unraisable_tracebacks': True,
|
|
|
|
}
|
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():
|
2019-12-09 01:03:44 +00:00
|
|
|
includes, libs = get_isolated_env_paths()
|
|
|
|
|
2012-02-24 00:51:31 +00:00
|
|
|
flags = {
|
2014-08-23 11:45:04 +00:00
|
|
|
'libraries': [],
|
2019-12-09 01:03:44 +00:00
|
|
|
'include_dirs': [join(src_path, 'kivy', 'include')] + includes,
|
|
|
|
'library_dirs': [] + libs,
|
2012-02-24 00:51:31 +00:00
|
|
|
'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]
|
2014-04-14 18:12:03 +00:00
|
|
|
elif platform.startswith('freebsd'):
|
2015-06-22 16:59:45 +00:00
|
|
|
flags['include_dirs'] += [join(
|
|
|
|
environ.get('LOCALBASE', '/usr/local'), 'include')]
|
Windows: add support for ANGLE as an alternative for GL rendering
This can be achieve by asking a ES profile implementation to SDL2, and compile then copy ANGLE libEGL.dll and libGLESv2.dll to c:\Python27\share\sdl2\bin.
Support in kivy for ANGLE must be activated at compilation: USE_ANGLE=1 make
The changes intruduce a "dynamic" opengl backend, that uses SDL2 GetProcAddress to gather all the GL pointers that we need for opengl, and expose them in "cgl" context.
All the graphics implementation now use cgl (either a module or the new context for dynamic gl) as a base for accessing GL functions. The GL definitions are extracted and shared in c_opengl_def.
ANGLE give us:
- ability to execute Kivy application with default driver (at least for Virtualbox and intel, no need to install specific vendor graphics)
- works starting Direct3d 9 support (use dxdiag to find out)
- works on older computer (intel drop opengl support older graphics card (< 2011, according to a customer) on Windows 10 while there where no issue on Windows 7)
Known issues:
- stencil doesn't work on Windows 7 on Virtual BOX, but even their samples doesn't work, while firefox and chrome that uses angle (according to http://www.browserleaks.com/webgl)
- line doesn't show on Windows 10
TODO:
- continue to separate fully the GL context in order to dynamically switch to another implementation at runtime
- be able to use MOCK without recompilation
- be able to use DEBUG opengl (check glGetError after every command) without recompilation
- be able to either use DESKTOP opengl or ANGLE opengl without recompilation
- stencil fixes or alternative
- line fixes or alternative
Suggestions:
- if stencil is really an issue, there is a possibility to use scissor. It might be faster, but doesn't support stack, and have addional limitation, such as: scissor must be aligned to the windows while stencil can be rotated + position of the scissor must be in windows coordinate. They may have a possibility to make "hybrid" instructions that either use scissor or stencil depending the current matrix. On standard ui (without any scatter/rotation), only scissor would be used.
2016-05-30 21:51:36 +00:00
|
|
|
flags['library_dirs'] += [join(
|
2015-06-22 16:59:45 +00:00
|
|
|
environ.get('LOCALBASE', '/usr/local'), 'lib')]
|
2020-10-15 17:12:34 +00:00
|
|
|
elif platform == 'darwin' and c_options['use_osx_frameworks']:
|
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':
|
2020-10-15 17:12:34 +00:00
|
|
|
if 'SDKROOT' in environ:
|
|
|
|
sysroot = join(environ['SDKROOT'], 'System/Library/Frameworks')
|
|
|
|
else:
|
|
|
|
# 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 OS X{} 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]
|
2016-04-24 17:35:14 +00:00
|
|
|
elif platform == 'win32':
|
|
|
|
flags['include_dirs'] += [get_python_inc(prefix=sys.prefix)]
|
2017-02-02 21:59:20 +00:00
|
|
|
flags['library_dirs'] += [join(sys.prefix, "libs")]
|
2012-02-24 00:51:31 +00:00
|
|
|
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():
|
2016-06-12 00:03:23 +00:00
|
|
|
kivy_graphics_include = join(src_path, 'kivy', 'include')
|
|
|
|
flags = {'include_dirs': [kivy_graphics_include], 'libraries': []}
|
2016-06-18 02:36:04 +00:00
|
|
|
base_flags = {'include_dirs': [kivy_graphics_include], 'libraries': []}
|
2019-03-05 10:47:47 +00:00
|
|
|
cross_sysroot = environ.get('KIVY_CROSS_SYSROOT')
|
|
|
|
|
2016-01-08 23:50:59 +00:00
|
|
|
if c_options['use_opengl_mock']:
|
2016-06-18 02:36:04 +00:00
|
|
|
return flags, base_flags
|
2011-02-01 19:46:39 +00:00
|
|
|
if platform == 'win32':
|
2016-06-18 02:36:04 +00:00
|
|
|
flags['libraries'] = ['opengl32', 'glew32']
|
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':
|
2021-12-09 17:15:25 +00:00
|
|
|
flags['extra_link_args'] = ['-framework', 'OpenGL']
|
2011-02-01 19:46:39 +00:00
|
|
|
elif platform.startswith('freebsd'):
|
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']
|
2016-06-15 07:11:00 +00:00
|
|
|
flags['library_dirs'] = ['/usr/X11R6/lib']
|
2012-04-05 12:17:55 +00:00
|
|
|
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')]
|
2016-06-15 07:11:00 +00:00
|
|
|
flags['library_dirs'] = [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':
|
2019-03-05 10:47:47 +00:00
|
|
|
|
|
|
|
if not cross_sysroot:
|
|
|
|
flags['include_dirs'] = [
|
|
|
|
'/opt/vc/include',
|
|
|
|
'/opt/vc/include/interface/vcos/pthreads',
|
|
|
|
'/opt/vc/include/interface/vmcs_host/linux']
|
|
|
|
flags['library_dirs'] = ['/opt/vc/lib']
|
|
|
|
brcm_lib_files = (
|
|
|
|
'/opt/vc/lib/libbrcmEGL.so',
|
|
|
|
'/opt/vc/lib/libbrcmGLESv2.so')
|
|
|
|
|
|
|
|
else:
|
|
|
|
print("KIVY_CROSS_SYSROOT: " + cross_sysroot)
|
|
|
|
flags['include_dirs'] = [
|
|
|
|
cross_sysroot + '/usr/include',
|
|
|
|
cross_sysroot + '/usr/include/interface/vcos/pthreads',
|
|
|
|
cross_sysroot + '/usr/include/interface/vmcs_host/linux']
|
|
|
|
flags['library_dirs'] = [cross_sysroot + '/usr/lib']
|
|
|
|
brcm_lib_files = (
|
|
|
|
cross_sysroot + '/usr/lib/libbrcmEGL.so',
|
|
|
|
cross_sysroot + '/usr/lib/libbrcmGLESv2.so')
|
|
|
|
|
2017-09-06 06:55:26 +00:00
|
|
|
if all((exists(lib) for lib in brcm_lib_files)):
|
2019-12-22 13:50:50 +00:00
|
|
|
print('Found brcmEGL and brcmGLES library files '
|
2019-03-05 10:47:47 +00:00
|
|
|
'for rpi platform at ' + dirname(brcm_lib_files[0]))
|
2017-09-06 06:48:50 +00:00
|
|
|
gl_libs = ['brcmEGL', 'brcmGLESv2']
|
2017-09-01 11:48:22 +00:00
|
|
|
else:
|
2017-09-06 06:48:50 +00:00
|
|
|
print(
|
2019-12-22 13:50:50 +00:00
|
|
|
'Failed to find brcmEGL and brcmGLESv2 library files '
|
2017-09-06 06:48:50 +00:00
|
|
|
'for rpi platform, falling back to EGL and GLESv2.')
|
|
|
|
gl_libs = ['EGL', 'GLESv2']
|
|
|
|
flags['libraries'] = ['bcm_host'] + gl_libs
|
2018-10-29 18:29:42 +00:00
|
|
|
elif platform in ['mali', 'vc']:
|
2015-06-02 02:31:08 +00:00
|
|
|
flags['include_dirs'] = ['/usr/include/']
|
|
|
|
flags['library_dirs'] = ['/usr/lib/arm-linux-gnueabihf']
|
|
|
|
flags['libraries'] = ['GLESv2']
|
|
|
|
c_options['use_x11'] = True
|
|
|
|
c_options['use_egl'] = True
|
2010-11-03 21:05:03 +00:00
|
|
|
else:
|
2016-12-18 22:35:59 +00:00
|
|
|
flags['libraries'] = ['GL']
|
2016-06-18 02:36:04 +00:00
|
|
|
return flags, base_flags
|
2011-01-25 16:41:09 +00:00
|
|
|
|
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
|
|
|
|
2015-12-17 20:02:04 +00:00
|
|
|
if sdl2_flags and not sdl2_path and platform == 'darwin':
|
2015-12-17 18:08:24 +00:00
|
|
|
return sdl2_flags
|
|
|
|
|
2019-12-09 01:03:44 +00:00
|
|
|
includes, _ = get_isolated_env_paths()
|
|
|
|
|
2014-11-15 21:38:45 +00:00
|
|
|
# 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']
|
2015-03-18 19:30:32 +00:00
|
|
|
split_chr = ';' if platform == 'win32' else ':'
|
|
|
|
sdl2_paths = sdl2_path.split(split_chr) if sdl2_path else []
|
|
|
|
|
2015-11-22 20:12:13 +00:00
|
|
|
if not sdl2_paths:
|
2019-12-09 01:03:44 +00:00
|
|
|
sdl2_paths = []
|
|
|
|
for include in includes + [join(sys.prefix, 'include')]:
|
|
|
|
sdl_inc = join(include, 'SDL2')
|
|
|
|
if isdir(sdl_inc):
|
|
|
|
sdl2_paths.append(sdl_inc)
|
2015-11-22 20:12:13 +00:00
|
|
|
sdl2_paths.extend(['/usr/local/include/SDL2', '/usr/include/SDL2'])
|
|
|
|
|
2015-12-17 18:08:24 +00:00
|
|
|
flags['include_dirs'] = sdl2_paths
|
2013-08-20 23:35:34 +00:00
|
|
|
flags['extra_link_args'] = []
|
|
|
|
flags['extra_compile_args'] = []
|
2016-06-15 07:11:00 +00:00
|
|
|
flags['library_dirs'] = (
|
Windows: add support for ANGLE as an alternative for GL rendering
This can be achieve by asking a ES profile implementation to SDL2, and compile then copy ANGLE libEGL.dll and libGLESv2.dll to c:\Python27\share\sdl2\bin.
Support in kivy for ANGLE must be activated at compilation: USE_ANGLE=1 make
The changes intruduce a "dynamic" opengl backend, that uses SDL2 GetProcAddress to gather all the GL pointers that we need for opengl, and expose them in "cgl" context.
All the graphics implementation now use cgl (either a module or the new context for dynamic gl) as a base for accessing GL functions. The GL definitions are extracted and shared in c_opengl_def.
ANGLE give us:
- ability to execute Kivy application with default driver (at least for Virtualbox and intel, no need to install specific vendor graphics)
- works starting Direct3d 9 support (use dxdiag to find out)
- works on older computer (intel drop opengl support older graphics card (< 2011, according to a customer) on Windows 10 while there where no issue on Windows 7)
Known issues:
- stencil doesn't work on Windows 7 on Virtual BOX, but even their samples doesn't work, while firefox and chrome that uses angle (according to http://www.browserleaks.com/webgl)
- line doesn't show on Windows 10
TODO:
- continue to separate fully the GL context in order to dynamically switch to another implementation at runtime
- be able to use MOCK without recompilation
- be able to use DEBUG opengl (check glGetError after every command) without recompilation
- be able to either use DESKTOP opengl or ANGLE opengl without recompilation
- stencil fixes or alternative
- line fixes or alternative
Suggestions:
- if stencil is really an issue, there is a possibility to use scissor. It might be faster, but doesn't support stack, and have addional limitation, such as: scissor must be aligned to the windows while stencil can be rotated + position of the scissor must be in windows coordinate. They may have a possibility to make "hybrid" instructions that either use scissor or stencil depending the current matrix. On standard ui (without any scatter/rotation), only scissor would be used.
2016-05-30 21:51:36 +00:00
|
|
|
sdl2_paths if sdl2_paths else
|
|
|
|
['/usr/local/lib/'])
|
2013-08-20 23:35:34 +00:00
|
|
|
|
2016-11-20 18:45:55 +00:00
|
|
|
if sdl2_flags:
|
|
|
|
flags = merge(flags, sdl2_flags)
|
|
|
|
|
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()
|
2016-06-18 02:36:04 +00:00
|
|
|
gl_flags, gl_flags_base = determine_gl_flags()
|
2012-02-23 23:25:20 +00:00
|
|
|
|
|
|
|
# -----------------------------------------------------------------------------
|
|
|
|
# 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 = {
|
|
|
|
'buffer.pyx': ['common.pxi'],
|
2016-06-12 00:03:23 +00:00
|
|
|
'context.pxd': ['instructions.pxd', 'texture.pxd', 'vbo.pxd', 'cgl.pxd'],
|
|
|
|
'cgl.pxd': ['common.pxi', 'config.pxi', 'gl_redirect.h'],
|
2014-08-23 11:45:04 +00:00
|
|
|
'compiler.pxd': ['instructions.pxd'],
|
|
|
|
'compiler.pyx': ['context_instructions.pxd'],
|
2016-06-12 00:03:23 +00:00
|
|
|
'cgl.pyx': ['cgl.pxd'],
|
|
|
|
'cgl_mock.pyx': ['cgl.pxd'],
|
|
|
|
'cgl_sdl2.pyx': ['cgl.pxd'],
|
2016-06-18 02:36:04 +00:00
|
|
|
'cgl_gl.pyx': ['cgl.pxd'],
|
|
|
|
'cgl_glew.pyx': ['cgl.pxd'],
|
2014-08-23 11:45:04 +00:00
|
|
|
'context_instructions.pxd': [
|
|
|
|
'transformation.pxd', 'instructions.pxd', 'texture.pxd'],
|
2016-06-12 00:03:23 +00:00
|
|
|
'fbo.pxd': ['cgl.pxd', 'instructions.pxd', 'texture.pxd'],
|
2014-08-23 11:45:04 +00:00
|
|
|
'fbo.pyx': [
|
2016-06-12 00:03:23 +00:00
|
|
|
'config.pxi', 'opcodes.pxi', 'transformation.pxd', 'context.pxd'],
|
2014-08-23 11:45:04 +00:00
|
|
|
'gl_instructions.pyx': [
|
2016-06-12 00:03:23 +00:00
|
|
|
'config.pxi', 'opcodes.pxi', 'cgl.pxd', 'instructions.pxd'],
|
2014-08-23 11:45:04 +00:00
|
|
|
'instructions.pxd': [
|
|
|
|
'vbo.pxd', 'context_instructions.pxd', 'compiler.pxd', 'shader.pxd',
|
|
|
|
'texture.pxd', '../_event.pxd'],
|
|
|
|
'instructions.pyx': [
|
2016-06-12 00:03:23 +00:00
|
|
|
'config.pxi', 'opcodes.pxi', 'cgl.pxd',
|
|
|
|
'context.pxd', 'common.pxi', 'vertex.pxd', 'transformation.pxd'],
|
2015-07-04 20:00:59 +00:00
|
|
|
'opengl.pyx': [
|
2016-06-12 00:03:23 +00:00
|
|
|
'config.pxi', 'common.pxi', 'cgl.pxd', 'gl_redirect.h'],
|
2016-01-08 01:23:27 +00:00
|
|
|
'opengl_utils.pyx': [
|
2016-06-12 00:03:23 +00:00
|
|
|
'opengl_utils_def.pxi', 'cgl.pxd', ],
|
|
|
|
'shader.pxd': ['cgl.pxd', 'transformation.pxd', 'vertex.pxd'],
|
2014-08-23 11:45:04 +00:00
|
|
|
'shader.pyx': [
|
2016-06-12 00:03:23 +00:00
|
|
|
'config.pxi', 'common.pxi', 'cgl.pxd',
|
2016-01-08 01:23:27 +00:00
|
|
|
'vertex.pxd', 'transformation.pxd', 'context.pxd',
|
2016-06-12 00:03:23 +00:00
|
|
|
'gl_debug_logger.pxi'],
|
2014-08-23 11:45:04 +00:00
|
|
|
'stencil_instructions.pxd': ['instructions.pxd'],
|
|
|
|
'stencil_instructions.pyx': [
|
2016-06-12 00:03:23 +00:00
|
|
|
'config.pxi', 'opcodes.pxi', 'cgl.pxd',
|
|
|
|
'gl_debug_logger.pxi'],
|
2014-08-09 17:14:42 +00:00
|
|
|
'scissor_instructions.pyx': [
|
2016-06-12 00:03:23 +00:00
|
|
|
'config.pxi', 'opcodes.pxi', 'cgl.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'],
|
2016-06-12 00:03:23 +00:00
|
|
|
'texture.pxd': ['cgl.pxd'],
|
2014-08-23 11:45:04 +00:00
|
|
|
'texture.pyx': [
|
|
|
|
'config.pxi', 'common.pxi', 'opengl_utils_def.pxi', 'context.pxd',
|
2016-06-12 00:03:23 +00:00
|
|
|
'cgl.pxd', 'opengl_utils.pxd',
|
|
|
|
'img_tools.pxi', 'gl_debug_logger.pxi'],
|
|
|
|
'vbo.pxd': ['buffer.pxd', 'cgl.pxd', 'vertex.pxd'],
|
2014-08-23 11:45:04 +00:00
|
|
|
'vbo.pyx': [
|
2016-06-12 00:03:23 +00:00
|
|
|
'config.pxi', 'common.pxi', 'context.pxd',
|
|
|
|
'instructions.pxd', 'shader.pxd', 'gl_debug_logger.pxi'],
|
|
|
|
'vertex.pxd': ['cgl.pxd'],
|
2014-08-23 11:45:04 +00:00
|
|
|
'vertex.pyx': ['config.pxi', 'common.pxi'],
|
|
|
|
'vertex_instructions.pyx': [
|
2015-07-04 20:00:59 +00:00
|
|
|
'config.pxi', 'common.pxi', 'vbo.pxd', 'vertex.pxd',
|
|
|
|
'instructions.pxd', 'vertex_instructions.pxd',
|
2016-06-12 00:03:23 +00:00
|
|
|
'cgl.pxd', 'texture.pxd', 'vertex_instructions_line.pxi'],
|
2014-08-23 11:45:04 +00:00
|
|
|
'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']}),
|
2016-06-21 19:21:21 +00:00
|
|
|
'_clock.pyx': {},
|
2015-03-04 16:36:06 +00:00
|
|
|
'weakproxy.pyx': {},
|
2021-01-21 22:02:00 +00:00
|
|
|
'properties.pyx': merge(
|
|
|
|
base_flags, {'depends': ['_event.pxd', '_metrics.pxd']}),
|
|
|
|
'_metrics.pyx': merge(base_flags, {'depends': ['_event.pxd']}),
|
2016-06-18 02:36:04 +00:00
|
|
|
'graphics/buffer.pyx': merge(base_flags, gl_flags_base),
|
|
|
|
'graphics/context.pyx': merge(base_flags, gl_flags_base),
|
|
|
|
'graphics/compiler.pyx': merge(base_flags, gl_flags_base),
|
|
|
|
'graphics/context_instructions.pyx': merge(base_flags, gl_flags_base),
|
|
|
|
'graphics/fbo.pyx': merge(base_flags, gl_flags_base),
|
|
|
|
'graphics/gl_instructions.pyx': merge(base_flags, gl_flags_base),
|
|
|
|
'graphics/instructions.pyx': merge(base_flags, gl_flags_base),
|
|
|
|
'graphics/opengl.pyx': merge(base_flags, gl_flags_base),
|
|
|
|
'graphics/opengl_utils.pyx': merge(base_flags, gl_flags_base),
|
|
|
|
'graphics/shader.pyx': merge(base_flags, gl_flags_base),
|
|
|
|
'graphics/stencil_instructions.pyx': merge(base_flags, gl_flags_base),
|
|
|
|
'graphics/scissor_instructions.pyx': merge(base_flags, gl_flags_base),
|
|
|
|
'graphics/texture.pyx': merge(base_flags, gl_flags_base),
|
|
|
|
'graphics/transformation.pyx': merge(base_flags, gl_flags_base),
|
|
|
|
'graphics/vbo.pyx': merge(base_flags, gl_flags_base),
|
|
|
|
'graphics/vertex.pyx': merge(base_flags, gl_flags_base),
|
|
|
|
'graphics/vertex_instructions.pyx': merge(base_flags, gl_flags_base),
|
|
|
|
'graphics/cgl.pyx': merge(base_flags, gl_flags_base),
|
2016-12-18 21:22:44 +00:00
|
|
|
'graphics/cgl_backend/cgl_mock.pyx': merge(base_flags, gl_flags_base),
|
|
|
|
'graphics/cgl_backend/cgl_gl.pyx': merge(base_flags, gl_flags),
|
|
|
|
'graphics/cgl_backend/cgl_glew.pyx': merge(base_flags, gl_flags),
|
|
|
|
'graphics/cgl_backend/cgl_sdl2.pyx': merge(base_flags, gl_flags_base),
|
|
|
|
'graphics/cgl_backend/cgl_debug.pyx': merge(base_flags, gl_flags_base),
|
2014-08-29 23:21:59 +00:00
|
|
|
'core/text/text_layout.pyx': base_flags,
|
2017-12-17 06:50:48 +00:00
|
|
|
'core/window/window_info.pyx': base_flags,
|
2014-08-29 23:21:59 +00:00
|
|
|
'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
|
|
|
}),
|
2016-06-18 02:36:04 +00:00
|
|
|
'graphics/svg.pyx': merge(base_flags, gl_flags_base)
|
2014-08-29 23:21:59 +00:00
|
|
|
}
|
2011-02-13 15:06:19 +00:00
|
|
|
|
Windows: add support for ANGLE as an alternative for GL rendering
This can be achieve by asking a ES profile implementation to SDL2, and compile then copy ANGLE libEGL.dll and libGLESv2.dll to c:\Python27\share\sdl2\bin.
Support in kivy for ANGLE must be activated at compilation: USE_ANGLE=1 make
The changes intruduce a "dynamic" opengl backend, that uses SDL2 GetProcAddress to gather all the GL pointers that we need for opengl, and expose them in "cgl" context.
All the graphics implementation now use cgl (either a module or the new context for dynamic gl) as a base for accessing GL functions. The GL definitions are extracted and shared in c_opengl_def.
ANGLE give us:
- ability to execute Kivy application with default driver (at least for Virtualbox and intel, no need to install specific vendor graphics)
- works starting Direct3d 9 support (use dxdiag to find out)
- works on older computer (intel drop opengl support older graphics card (< 2011, according to a customer) on Windows 10 while there where no issue on Windows 7)
Known issues:
- stencil doesn't work on Windows 7 on Virtual BOX, but even their samples doesn't work, while firefox and chrome that uses angle (according to http://www.browserleaks.com/webgl)
- line doesn't show on Windows 10
TODO:
- continue to separate fully the GL context in order to dynamically switch to another implementation at runtime
- be able to use MOCK without recompilation
- be able to use DEBUG opengl (check glGetError after every command) without recompilation
- be able to either use DESKTOP opengl or ANGLE opengl without recompilation
- stencil fixes or alternative
- line fixes or alternative
Suggestions:
- if stencil is really an issue, there is a possibility to use scissor. It might be faster, but doesn't support stack, and have addional limitation, such as: scissor must be aligned to the windows while stencil can be rotated + position of the scissor must be in windows coordinate. They may have a possibility to make "hybrid" instructions that either use scissor or stencil depending the current matrix. On standard ui (without any scatter/rotation), only scissor would be used.
2016-05-30 21:51:36 +00:00
|
|
|
if c_options["use_sdl2"]:
|
2013-08-20 23:35:34 +00:00
|
|
|
sdl2_flags = determine_sdl2()
|
Windows: add support for ANGLE as an alternative for GL rendering
This can be achieve by asking a ES profile implementation to SDL2, and compile then copy ANGLE libEGL.dll and libGLESv2.dll to c:\Python27\share\sdl2\bin.
Support in kivy for ANGLE must be activated at compilation: USE_ANGLE=1 make
The changes intruduce a "dynamic" opengl backend, that uses SDL2 GetProcAddress to gather all the GL pointers that we need for opengl, and expose them in "cgl" context.
All the graphics implementation now use cgl (either a module or the new context for dynamic gl) as a base for accessing GL functions. The GL definitions are extracted and shared in c_opengl_def.
ANGLE give us:
- ability to execute Kivy application with default driver (at least for Virtualbox and intel, no need to install specific vendor graphics)
- works starting Direct3d 9 support (use dxdiag to find out)
- works on older computer (intel drop opengl support older graphics card (< 2011, according to a customer) on Windows 10 while there where no issue on Windows 7)
Known issues:
- stencil doesn't work on Windows 7 on Virtual BOX, but even their samples doesn't work, while firefox and chrome that uses angle (according to http://www.browserleaks.com/webgl)
- line doesn't show on Windows 10
TODO:
- continue to separate fully the GL context in order to dynamically switch to another implementation at runtime
- be able to use MOCK without recompilation
- be able to use DEBUG opengl (check glGetError after every command) without recompilation
- be able to either use DESKTOP opengl or ANGLE opengl without recompilation
- stencil fixes or alternative
- line fixes or alternative
Suggestions:
- if stencil is really an issue, there is a possibility to use scissor. It might be faster, but doesn't support stack, and have addional limitation, such as: scissor must be aligned to the windows while stencil can be rotated + position of the scissor must be in windows coordinate. They may have a possibility to make "hybrid" instructions that either use scissor or stencil depending the current matrix. On standard ui (without any scatter/rotation), only scissor would be used.
2016-05-30 21:51:36 +00:00
|
|
|
|
2016-06-18 02:36:04 +00:00
|
|
|
if c_options['use_sdl2'] and sdl2_flags:
|
2016-12-18 21:22:44 +00:00
|
|
|
sources['graphics/cgl_backend/cgl_sdl2.pyx'] = merge(
|
|
|
|
sources['graphics/cgl_backend/cgl_sdl2.pyx'], sdl2_flags)
|
2016-06-18 02:36:04 +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/audio/audio_sdl2.pyx',
|
|
|
|
'core/clipboard/_clipboard_sdl2.pyx'):
|
|
|
|
sources[source_file] = merge(
|
|
|
|
base_flags, sdl2_flags, sdl2_depends)
|
2013-08-20 23:35:34 +00:00
|
|
|
|
2018-03-16 00:53:04 +00:00
|
|
|
if c_options['use_pangoft2'] in (None, True) and platform not in (
|
2019-04-27 09:48:51 +00:00
|
|
|
'android', 'ios', 'win32'):
|
2017-08-08 18:58:59 +00:00
|
|
|
pango_flags = pkgconfig('pangoft2')
|
2018-03-16 00:53:04 +00:00
|
|
|
if pango_flags and 'libraries' in pango_flags:
|
|
|
|
print('Pango: pangoft2 found via pkg-config')
|
|
|
|
c_options['use_pangoft2'] = True
|
2019-02-25 10:36:18 +00:00
|
|
|
pango_depends = {'depends': [
|
|
|
|
'lib/pango/pangoft2.pxi',
|
|
|
|
'lib/pango/pangoft2.h']}
|
2017-08-08 18:58:59 +00:00
|
|
|
sources['core/text/_text_pango.pyx'] = merge(
|
|
|
|
base_flags, pango_flags, pango_depends)
|
2019-02-24 21:36:20 +00:00
|
|
|
print(sources['core/text/_text_pango.pyx'])
|
2017-08-06 13:38:16 +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]]
|
2019-02-12 01:03:12 +00:00
|
|
|
if mac_ver >= [10, 7] or platform == 'ios':
|
2014-08-23 11:45:04 +00:00
|
|
|
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(
|
2016-12-13 19:25:46 +00:00
|
|
|
base_flags, gl_flags)
|
2013-03-19 18:14:27 +00:00
|
|
|
sources['lib/vidcore_lite/bcm.pyx'] = merge(
|
2016-12-13 19:25:46 +00:00
|
|
|
base_flags, gl_flags)
|
2013-03-19 18:14:27 +00:00
|
|
|
|
2013-03-31 10:26:23 +00:00
|
|
|
if c_options['use_x11']:
|
2015-06-02 02:31:08 +00:00
|
|
|
libs = ['Xrender', 'X11']
|
|
|
|
if c_options['use_egl']:
|
|
|
|
libs += ['EGL']
|
|
|
|
else:
|
|
|
|
libs += ['GL']
|
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
|
|
|
|
#
|
2016-12-14 15:30:46 +00:00
|
|
|
# 'depends': [
|
2014-08-23 11:45:04 +00:00
|
|
|
# 'core/window/window_x11_keytab.c',
|
|
|
|
# 'core/window/window_x11_core.c'],
|
2015-06-02 02:31:08 +00:00
|
|
|
'libraries': libs})
|
2014-08-23 11:45:04 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
2012-02-23 23:25:20 +00:00
|
|
|
# -----------------------------------------------------------------------------
|
|
|
|
# extension modules
|
2012-06-16 15:46:48 +00:00
|
|
|
|
2019-04-27 09:48:51 +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)
|
2017-08-15 10:38:53 +00:00
|
|
|
|
|
|
|
deps_final = []
|
|
|
|
paths_to_test = ['graphics', 'include']
|
|
|
|
for dep in deps:
|
|
|
|
found = False
|
|
|
|
for path in paths_to_test:
|
|
|
|
filename = expand(src_path, path, dep)
|
|
|
|
if exists(filename):
|
|
|
|
deps_final.append(filename)
|
|
|
|
found = True
|
|
|
|
break
|
|
|
|
if not found:
|
|
|
|
print('ERROR: Dependency for {} not resolved: {}'.format(
|
|
|
|
fn, dep
|
|
|
|
))
|
|
|
|
|
|
|
|
return deps_final
|
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')
|
2020-12-10 21:13:43 +00:00
|
|
|
pyx_path = expand(src_path, pyx)
|
2015-01-28 19:45:24 +00:00
|
|
|
depends = [expand(src_path, x) for x in flags.pop('depends', [])]
|
|
|
|
c_depends = [expand(src_path, x) for x in flags.pop('c_depends', [])]
|
Change check for Cython to attempt fallback to setuptools on supporte… (#5998)
* Change check for Cython to attempt fallback to setuptools on supported platforms.
This attempts to solve Issue #5984 without causing more problems for Issue #5558.
* Correct argument to extras_require.
* Refactor the declaration and usage of Cython
- Use setuptools.setup by default if available for import.
- The objective for that complicated import/cython is commented.
- Also have more specific variable names, and have their usage be
clarified.
- Remove Cython from install_requires as it already is declared under
setup_requires, and that it conflicts with install_requires due to
issues in setuptools.
- https://github.com/pypa/setuptools/issues/209
- https://github.com/pypa/setuptools/issues/391
- This commit goes back to breaking installation in environments without
Cython, but should be rectified in the next commit.
* Actually fix the specific usage of Cython
- In order for setup.py to make use of the Cython installed during by
the setup_requires to be usable, it must be imported after it is
installed by that step, thus it cannot be done at the top level and
this can be achieved by importing it when it's actually called. A
build_ext factory function is created for this.
- Still allow whatever Cython already present on the current environment
be attempted to be used. This may end up being unnecessary as if it
is always declared in setup_requires (which isn't currently the case
due to the complicated/documented block), it _should_ pull in the
exact/supported version of Cython for usage. This should be
investigated so that this complicated logic may be avoided.
* Make distutils happy by not using factory function
- As it turns out, calling setup.py build_ext will result in a code path
within setuptools that will invoke distutils in a way that forces an
issubclass check, which ultimately results in an exception due to that
function not being a class.
- To fix this, we go back to constructing a base class except also using
the "new" style class (to make Python 2 happy) so that the __new__
method will actually be called so that the logic to select the Cython
version of build_ext will be invoked.
- Also use the super class protocol to invoke parent methods.
* Declare version bounds directly on setup_requires
- This allows us to fully remove the brittle version checks
- Also this allows us to directly declare setup_requires if Cython is
definitely required, as this would allow the correct version to be
installed directly by setuptools during the execution of the setup
step.
- No need to check for failed Cython imports due to the presence of the
setup_requires declaration.
* Add comment explaining the initialisation routine for KivyBuildExt.
Details of how setuptools deals with both cmdclass and when setup_requires
dependencies come in to scope are both relevant.
* Bring comment in to line with earlier changes.
The cython checks are significantly simpler now, and the rationale is also slightly different.
2019-03-04 10:49:42 +00:00
|
|
|
if not can_use_cython:
|
|
|
|
# can't use cython, so use the .c files instead.
|
2020-12-10 21:13:43 +00:00
|
|
|
pyx_path = '%s.c' % pyx_path[:-4]
|
2014-08-23 11:45:04 +00:00
|
|
|
if is_graphics:
|
2020-12-10 21:13:43 +00:00
|
|
|
depends = resolve_dependencies(pyx_path, depends)
|
2014-08-23 11:45:04 +00:00
|
|
|
f_depends = [x for x in depends if x.rsplit('.', 1)[-1] in (
|
|
|
|
'c', 'cpp', 'm')]
|
2020-12-10 21:13:43 +00:00
|
|
|
module_name = '.'.join(['kivy'] + pyx[:-4].split('/'))
|
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
|
2015-07-04 20:00:59 +00:00
|
|
|
ext_modules.append(CythonExtension(
|
2020-12-10 21:13:43 +00:00
|
|
|
module_name, [pyx_path] + 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
|
|
|
|
2016-12-17 07:50:52 +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
|
|
|
|
2016-12-17 09:41:12 +00:00
|
|
|
|
2012-02-23 23:25:20 +00:00
|
|
|
# -----------------------------------------------------------------------------
|
|
|
|
# automatically detect data files
|
2017-02-10 23:11:24 +00:00
|
|
|
split_examples = int(environ.get('KIVY_SPLIT_EXAMPLES', '0'))
|
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',
|
2015-11-04 00:00:56 +00:00
|
|
|
'avi', 'gif', 'txt', 'ttf', 'obj', 'mtl', 'kv', 'mpg',
|
2017-01-04 17:56:33 +00:00
|
|
|
'glsl', 'zip')
|
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))
|
2015-07-04 20:00:59 +00:00
|
|
|
if directory not in examples:
|
2010-11-03 21:05:03 +00:00
|
|
|
examples[directory] = []
|
|
|
|
examples[directory].append(filename)
|
|
|
|
|
2015-04-07 16:17:28 +00:00
|
|
|
binary_deps = []
|
|
|
|
binary_deps_path = join(src_path, 'kivy', 'binary_deps')
|
|
|
|
if isdir(binary_deps_path):
|
|
|
|
for root, dirnames, filenames in walk(binary_deps_path):
|
|
|
|
for fname in filenames:
|
|
|
|
binary_deps.append(
|
|
|
|
join(root.replace(binary_deps_path, 'binary_deps'), fname))
|
|
|
|
|
2019-06-23 20:43:38 +00:00
|
|
|
|
|
|
|
def glob_paths(*patterns, excludes=('.pyc', )):
|
|
|
|
files = []
|
|
|
|
base = Path(join(src_path, 'kivy'))
|
|
|
|
|
|
|
|
for pat in patterns:
|
|
|
|
for f in base.glob(pat):
|
|
|
|
if f.suffix in excludes:
|
|
|
|
continue
|
|
|
|
files.append(str(f.relative_to(base)))
|
|
|
|
return files
|
|
|
|
|
|
|
|
|
2012-02-23 23:25:20 +00:00
|
|
|
# -----------------------------------------------------------------------------
|
2010-11-03 21:05:03 +00:00
|
|
|
# setup !
|
2017-02-10 23:11:24 +00:00
|
|
|
if not build_examples:
|
|
|
|
setup(
|
|
|
|
name='Kivy',
|
2020-09-14 20:17:19 +00:00
|
|
|
version=__version__,
|
2017-02-10 23:11:24 +00:00
|
|
|
author='Kivy Team and other contributors',
|
|
|
|
author_email='kivy-dev@googlegroups.com',
|
|
|
|
url='http://kivy.org',
|
|
|
|
license='MIT',
|
|
|
|
description=(
|
|
|
|
'A software library for rapid development of '
|
|
|
|
'hardware-accelerated multitouch applications.'),
|
2017-09-09 08:59:51 +00:00
|
|
|
long_description=get_description(),
|
2019-05-16 16:13:18 +00:00
|
|
|
long_description_content_type='text/markdown',
|
2017-02-10 23:11:24 +00:00
|
|
|
ext_modules=ext_modules,
|
|
|
|
cmdclass=cmdclass,
|
2019-06-23 20:43:38 +00:00
|
|
|
packages=find_packages(include=['kivy*']),
|
2017-02-10 23:11:24 +00:00
|
|
|
package_dir={'kivy': 'kivy'},
|
2019-06-23 20:43:38 +00:00
|
|
|
package_data={
|
|
|
|
'kivy':
|
2019-11-29 15:00:31 +00:00
|
|
|
glob_paths('*.pxd', '*.pxi') +
|
2019-06-23 20:43:38 +00:00
|
|
|
glob_paths('**/*.pxd', '**/*.pxi') +
|
|
|
|
glob_paths('data/**/*.*') +
|
|
|
|
glob_paths('include/**/*.*') +
|
|
|
|
glob_paths('tools/**/*.*', excludes=('.pyc', '.enc')) +
|
|
|
|
glob_paths('graphics/**/*.h') +
|
|
|
|
glob_paths('tests/**/*.*') +
|
|
|
|
[
|
|
|
|
'setupconfig.py',
|
|
|
|
] + binary_deps
|
|
|
|
},
|
2017-02-10 23:11:24 +00:00
|
|
|
data_files=[] if split_examples else list(examples.items()),
|
|
|
|
classifiers=[
|
|
|
|
'Development Status :: 5 - Production/Stable',
|
|
|
|
'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',
|
|
|
|
'License :: OSI Approved :: MIT License',
|
|
|
|
'Natural Language :: English',
|
|
|
|
'Operating System :: MacOS :: MacOS X',
|
|
|
|
'Operating System :: Microsoft :: Windows',
|
|
|
|
'Operating System :: POSIX :: BSD :: FreeBSD',
|
|
|
|
'Operating System :: POSIX :: Linux',
|
2019-06-01 23:29:09 +00:00
|
|
|
'Programming Language :: Python :: 3.7',
|
2020-10-07 01:13:31 +00:00
|
|
|
'Programming Language :: Python :: 3.8',
|
|
|
|
'Programming Language :: Python :: 3.9',
|
2022-01-12 17:26:20 +00:00
|
|
|
'Programming Language :: Python :: 3.10',
|
2017-02-10 23:11:24 +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'),
|
2019-12-09 01:03:44 +00:00
|
|
|
'Topic :: Software Development :: User Interfaces'])
|
2017-02-10 23:11:24 +00:00
|
|
|
else:
|
|
|
|
setup(
|
|
|
|
name='Kivy-examples',
|
2020-09-14 20:17:19 +00:00
|
|
|
version=__version__,
|
2017-02-10 23:11:24 +00:00
|
|
|
author='Kivy Team and other contributors',
|
|
|
|
author_email='kivy-dev@googlegroups.com',
|
|
|
|
url='http://kivy.org',
|
|
|
|
license='MIT',
|
|
|
|
description=('Kivy examples.'),
|
2019-05-16 16:12:06 +00:00
|
|
|
long_description_content_type='text/markdown',
|
2017-09-09 08:59:51 +00:00
|
|
|
long_description=get_description(),
|
2017-02-10 23:11:24 +00:00
|
|
|
data_files=list(examples.items()))
|