2011-02-01 19:46:39 +00:00
|
|
|
from fnmatch import filter as fnfilter
|
2011-03-29 15:25:43 +00:00
|
|
|
from sys import platform, argv
|
2011-02-01 19:46:39 +00:00
|
|
|
from os.path import join, dirname, realpath, sep, exists
|
2011-02-01 10:21:54 +00:00
|
|
|
from os import walk, environ
|
2011-02-19 00:08:40 +00:00
|
|
|
from distutils.core import setup
|
|
|
|
from distutils.extension import Extension
|
2010-11-03 21:05:03 +00:00
|
|
|
|
|
|
|
# extract version (simulate doc generation, kivy will be not imported)
|
2011-02-01 10:21:54 +00:00
|
|
|
environ['KIVY_DOC_INCLUDE'] = '1'
|
2010-11-03 21:05:03 +00:00
|
|
|
import kivy
|
|
|
|
|
|
|
|
# extra build commands go in the cmdclass dict {'command-name': CommandClass}
|
2011-01-20 17:17:29 +00:00
|
|
|
# see tools.packaging.{platform}.build.py for custom build commands for
|
|
|
|
# portable packages. also e.g. we use build_ext command from cython if its
|
|
|
|
# installed for c extensions.
|
2010-11-03 21:05:03 +00:00
|
|
|
cmdclass = {}
|
|
|
|
|
|
|
|
# add build rules for portable packages to cmdclass
|
2011-02-01 19:46:39 +00:00
|
|
|
if platform == 'win32':
|
2010-11-03 21:05:03 +00:00
|
|
|
from kivy.tools.packaging.win32.build import WindowsPortableBuild
|
|
|
|
cmdclass['build_portable'] = WindowsPortableBuild
|
2011-02-01 19:46:39 +00:00
|
|
|
elif platform == 'darwin':
|
2011-01-20 17:17:29 +00:00
|
|
|
from kivy.tools.packaging.osx.build import OSXPortableBuild
|
|
|
|
cmdclass['build_portable'] = OSXPortableBuild
|
2010-11-03 21:05:03 +00:00
|
|
|
|
|
|
|
from kivy.tools.packaging.factory import FactoryBuild
|
|
|
|
cmdclass['build_factory'] = FactoryBuild
|
|
|
|
|
2011-01-25 16:41:09 +00:00
|
|
|
#
|
|
|
|
# Detect options
|
|
|
|
#
|
|
|
|
c_options = {
|
|
|
|
'use_opengl_es2': True,
|
2011-01-25 18:55:48 +00:00
|
|
|
'use_opengl_debug': False,
|
2011-01-25 16:41:09 +00:00
|
|
|
'use_glew': False,
|
|
|
|
'use_mesagl': False}
|
|
|
|
|
2011-02-01 19:46:39 +00:00
|
|
|
# Detect which opengl version headers to use
|
|
|
|
if platform == 'win32':
|
2011-01-25 16:41:09 +00:00
|
|
|
print 'Windows platform detected, force GLEW usage.'
|
|
|
|
c_options['use_glew'] = True
|
2011-02-01 19:46:39 +00:00
|
|
|
elif platform == 'darwin':
|
|
|
|
# macosx is using their own gl.h
|
|
|
|
pass
|
|
|
|
else:
|
|
|
|
# searching GLES headers
|
|
|
|
default_header_dirs = ['/usr/include', '/usr/local/include']
|
|
|
|
found = False
|
|
|
|
for hdir in default_header_dirs:
|
|
|
|
filename = join(hdir, 'GLES2', 'gl2.h')
|
|
|
|
if exists(filename):
|
|
|
|
found = True
|
|
|
|
print 'Found GLES 2.0 headers at', filename
|
|
|
|
break
|
|
|
|
if not found:
|
|
|
|
print 'WARNING: GLES 2.0 headers are not found'
|
|
|
|
print 'Fallback to Desktop opengl headers.'
|
|
|
|
c_options['use_opengl_es2'] = False
|
2011-01-25 16:41:09 +00:00
|
|
|
|
|
|
|
print 'Generate config.h'
|
|
|
|
with open(join(dirname(__file__), 'kivy', 'graphics', 'config.h'), 'w') as fd:
|
|
|
|
fd.write('// Autogenerated file for Kivy C configuration\n')
|
|
|
|
for k, v in c_options.iteritems():
|
|
|
|
fd.write('#define __%s %d\n' % (k.upper(), int(v)))
|
|
|
|
|
|
|
|
print 'Generate config.pxi'
|
|
|
|
with open(join(dirname(__file__), 'kivy', 'graphics', 'config.pxi'), 'w') as fd:
|
|
|
|
fd.write('# Autogenerated file for Kivy Cython configuration\n')
|
|
|
|
for k, v in c_options.iteritems():
|
|
|
|
fd.write('DEF %s = %d\n' % (k.upper(), int(v)))
|
2010-11-03 21:05:03 +00:00
|
|
|
|
|
|
|
# extension modules
|
|
|
|
ext_modules = []
|
|
|
|
|
2010-12-16 22:00:14 +00:00
|
|
|
# list all files to compile
|
|
|
|
pyx_files = []
|
|
|
|
kivy_libs_dir = realpath(kivy.kivy_libs_dir)
|
2011-02-01 19:46:39 +00:00
|
|
|
for root, dirnames, filenames in walk(join(dirname(__file__), 'kivy')):
|
2010-12-16 22:00:14 +00:00
|
|
|
# ignore lib directory
|
2010-12-16 22:10:57 +00:00
|
|
|
if realpath(root).startswith(kivy_libs_dir):
|
2010-12-16 22:00:14 +00:00
|
|
|
continue
|
2011-02-01 19:46:39 +00:00
|
|
|
for filename in fnfilter(filenames, '*.pyx'):
|
|
|
|
pyx_files.append(join(root, filename))
|
2010-12-16 22:00:14 +00:00
|
|
|
|
|
|
|
# check for cython
|
2010-11-03 21:05:03 +00:00
|
|
|
try:
|
|
|
|
have_cython = True
|
|
|
|
from Cython.Distutils import build_ext
|
|
|
|
except:
|
|
|
|
have_cython = False
|
|
|
|
|
2011-01-09 23:37:16 +00:00
|
|
|
# create .c for every module
|
2011-02-01 19:46:39 +00:00
|
|
|
if 'sdist' in argv and have_cython:
|
2010-11-03 21:05:03 +00:00
|
|
|
from Cython.Compiler.Main import compile
|
|
|
|
print 'Generating C files...',
|
2010-12-16 22:00:14 +00:00
|
|
|
compile(pyx_files)
|
2010-11-03 21:05:03 +00:00
|
|
|
print 'Done !'
|
|
|
|
|
2011-01-20 17:26:01 +00:00
|
|
|
# add cython core extension modules if cython is available
|
2010-11-03 21:05:03 +00:00
|
|
|
if have_cython:
|
|
|
|
cmdclass['build_ext'] = build_ext
|
2011-01-09 23:37:16 +00:00
|
|
|
else:
|
|
|
|
pyx_files = ['%s.c' % x[:-4] for x in pyx_files]
|
|
|
|
|
|
|
|
if True:
|
2010-11-03 21:05:03 +00:00
|
|
|
libraries = []
|
|
|
|
include_dirs = []
|
|
|
|
extra_link_args = []
|
2011-02-01 19:46:39 +00:00
|
|
|
if platform == 'win32':
|
2010-11-03 21:05:03 +00:00
|
|
|
libraries.append('opengl32')
|
2011-02-01 19:46:39 +00:00
|
|
|
elif platform == 'darwin':
|
2010-11-03 21:05:03 +00:00
|
|
|
# On OSX, it's not -lGL, but -framework OpenGL...
|
|
|
|
extra_link_args = ['-framework', 'OpenGL']
|
2011-02-01 19:46:39 +00:00
|
|
|
elif platform.startswith('freebsd'):
|
2010-11-03 21:05:03 +00:00
|
|
|
include_dirs += ['/usr/local/include']
|
|
|
|
extra_link_args += ['-L', '/usr/local/lib']
|
|
|
|
else:
|
|
|
|
libraries.append('GL')
|
|
|
|
|
2011-01-25 16:41:09 +00:00
|
|
|
if c_options['use_glew']:
|
2011-02-01 19:46:39 +00:00
|
|
|
if platform == 'win32':
|
2011-01-25 18:55:48 +00:00
|
|
|
libraries.append('glew32')
|
|
|
|
else:
|
|
|
|
libraries.append('GLEW')
|
2011-01-25 16:41:09 +00:00
|
|
|
|
2011-02-01 23:17:24 +00:00
|
|
|
def get_modulename_from_file(filename):
|
|
|
|
pyx = '.'.join(filename.split('.')[:-1])
|
|
|
|
pyxl = pyx.split(sep)
|
|
|
|
while pyxl[0] != 'kivy':
|
|
|
|
pyxl.pop(0)
|
2011-02-01 23:40:17 +00:00
|
|
|
if pyxl[1] == 'kivy':
|
|
|
|
pyxl.pop(0)
|
2011-02-01 23:17:24 +00:00
|
|
|
return '.'.join(pyxl)
|
|
|
|
|
2011-02-13 15:06:19 +00:00
|
|
|
OrigExtension = Extension
|
2011-02-13 15:09:50 +00:00
|
|
|
|
2011-02-13 15:06:19 +00:00
|
|
|
def Extension(*args, **kwargs):
|
|
|
|
# Small hack to only compile for x86_64 on OSX.
|
|
|
|
# Is there a better way to do this?
|
|
|
|
if platform == 'darwin':
|
|
|
|
extra_args = ['-arch', 'x86_64']
|
2011-02-13 15:09:50 +00:00
|
|
|
kwargs['extra_compile_args'] = extra_args + \
|
|
|
|
kwargs.get('extra_compile_args', [])
|
|
|
|
kwargs['extra_link_args'] = extra_args + \
|
|
|
|
kwargs.get('extra_link_args', [])
|
2011-02-13 15:06:19 +00:00
|
|
|
return OrigExtension(*args, **kwargs)
|
|
|
|
|
2010-11-05 16:55:22 +00:00
|
|
|
# simple extensions
|
2010-12-16 22:10:57 +00:00
|
|
|
for pyx in (x for x in pyx_files if not 'graphics' in x):
|
2011-02-01 23:17:24 +00:00
|
|
|
module_name = get_modulename_from_file(pyx)
|
2010-12-16 22:10:57 +00:00
|
|
|
ext_modules.append(Extension(module_name, [pyx]))
|
2010-11-05 16:55:22 +00:00
|
|
|
|
|
|
|
# opengl aware modules
|
2010-12-16 22:10:57 +00:00
|
|
|
for pyx in (x for x in pyx_files if 'graphics' in x):
|
2011-02-01 23:17:24 +00:00
|
|
|
module_name = get_modulename_from_file(pyx)
|
2010-11-05 16:55:22 +00:00
|
|
|
ext_modules.append(Extension(
|
2010-12-16 22:10:57 +00:00
|
|
|
module_name, [pyx],
|
2010-11-05 16:55:22 +00:00
|
|
|
libraries=libraries,
|
2010-11-16 23:00:57 +00:00
|
|
|
include_dirs=include_dirs,
|
2011-01-20 17:17:29 +00:00
|
|
|
extra_link_args=extra_link_args))
|
2010-11-05 16:55:22 +00:00
|
|
|
|
2010-11-03 21:05:03 +00:00
|
|
|
|
2010-11-05 19:37:02 +00:00
|
|
|
#poly2try extension
|
2010-11-30 20:38:22 +00:00
|
|
|
"""
|
2010-11-05 19:37:02 +00:00
|
|
|
ext_modules.append(Extension('kivy.c_ext.p2t', [
|
2010-12-16 22:00:14 +00:00
|
|
|
'kivy/lib/poly2tri/src/p2t.pyx',
|
|
|
|
'kivy/lib/poly2tri/poly2tri/common/shapes.cc',
|
|
|
|
'kivy/lib/poly2tri/poly2tri/sweep/advancing_front.cc',
|
|
|
|
'kivy/lib/poly2tri/poly2tri/sweep/cdt.cc',
|
|
|
|
'kivy/lib/poly2tri/poly2tri/sweep/sweep.cc',
|
|
|
|
'kivy/lib/poly2tri/poly2tri/sweep/sweep_context.cc'
|
2010-11-05 19:37:02 +00:00
|
|
|
], language="c++"))
|
2010-11-30 20:38:22 +00:00
|
|
|
"""
|
2010-11-03 21:05:03 +00:00
|
|
|
|
|
|
|
#setup datafiles to be included in the disytibution, liek examples...
|
|
|
|
#extracts all examples files except sandbox
|
|
|
|
data_file_prefix = 'share/kivy-'
|
|
|
|
examples = {}
|
|
|
|
examples_allowed_ext = ('readme', 'py', 'wav', 'png', 'jpg', 'svg',
|
2011-01-31 23:25:15 +00:00
|
|
|
'avi', 'gif', 'txt', 'ttf', 'obj', 'mtl', 'kv')
|
2010-12-16 22:00:14 +00:00
|
|
|
for root, subFolders, files in walk('examples'):
|
2010-11-03 21:05:03 +00:00
|
|
|
if 'sandbox' in root:
|
|
|
|
continue
|
|
|
|
for file in files:
|
|
|
|
ext = file.split('.')[-1].lower()
|
|
|
|
if ext not in examples_allowed_ext:
|
|
|
|
continue
|
2010-12-16 22:00:14 +00:00
|
|
|
filename = join(root, file)
|
|
|
|
directory = '%s%s' % (data_file_prefix, dirname(filename))
|
2010-11-03 21:05:03 +00:00
|
|
|
if not directory in examples:
|
|
|
|
examples[directory] = []
|
|
|
|
examples[directory].append(filename)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# setup !
|
|
|
|
setup(
|
|
|
|
name='Kivy',
|
|
|
|
version=kivy.__version__,
|
|
|
|
author='Kivy Crew',
|
|
|
|
author_email='kivy-dev@googlegroups.com',
|
|
|
|
url='http://kivy.org/',
|
|
|
|
license='LGPL',
|
2011-01-31 22:51:04 +00:00
|
|
|
description='A software library for rapid development of ' + \
|
|
|
|
'hardware-accelerated multitouch applications.',
|
2010-11-03 21:05:03 +00:00
|
|
|
ext_modules=ext_modules,
|
|
|
|
cmdclass=cmdclass,
|
|
|
|
packages=[
|
|
|
|
'kivy',
|
|
|
|
'kivy.core',
|
|
|
|
'kivy.core.audio',
|
|
|
|
'kivy.core.camera',
|
|
|
|
'kivy.core.clipboard',
|
|
|
|
'kivy.core.image',
|
2010-11-05 04:27:58 +00:00
|
|
|
'kivy.core.gl',
|
2010-11-03 21:05:03 +00:00
|
|
|
'kivy.core.spelling',
|
|
|
|
'kivy.core.text',
|
|
|
|
'kivy.core.video',
|
2010-11-05 04:27:58 +00:00
|
|
|
'kivy.core.window',
|
2010-11-03 21:05:03 +00:00
|
|
|
'kivy.graphics',
|
|
|
|
'kivy.input',
|
|
|
|
'kivy.input.postproc',
|
|
|
|
'kivy.input.providers',
|
|
|
|
'kivy.lib',
|
|
|
|
'kivy.lib.osc',
|
|
|
|
'kivy.modules',
|
|
|
|
'kivy.tools',
|
|
|
|
'kivy.tools.packaging',
|
|
|
|
'kivy.tools.packaging.win32',
|
|
|
|
'kivy.tools.packaging.osx',
|
2010-11-05 04:27:58 +00:00
|
|
|
'kivy.uix',
|
2010-11-03 21:05:03 +00:00
|
|
|
],
|
|
|
|
package_dir={'kivy': 'kivy'},
|
|
|
|
package_data={'kivy': [
|
2011-01-09 23:37:16 +00:00
|
|
|
'data/*.kv',
|
|
|
|
'data/fonts/*.ttf',
|
|
|
|
'data/images/*.png',
|
2011-01-31 23:07:49 +00:00
|
|
|
'data/logo/*.png',
|
2011-01-09 23:37:16 +00:00
|
|
|
'data/glsl/*.png',
|
|
|
|
'data/glsl/*.vs',
|
|
|
|
'data/glsl/*.fs',
|
2010-11-03 21:05:03 +00:00
|
|
|
'tools/packaging/README.txt',
|
|
|
|
'tools/packaging/win32/kivy.bat',
|
2011-01-31 23:49:50 +00:00
|
|
|
'tools/packaging/win32/kivyenv.sh',
|
2010-11-03 21:05:03 +00:00
|
|
|
'tools/packaging/win32/README.txt',
|
2011-01-20 17:17:29 +00:00
|
|
|
'tools/packaging/osx/kivy.sh']},
|
2010-11-03 21:05:03 +00:00
|
|
|
data_files=examples.items(),
|
|
|
|
classifiers=[
|
|
|
|
'Development Status :: 3 - Alpha',
|
|
|
|
'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',
|
2011-01-20 17:17:29 +00:00
|
|
|
'License :: OSI Approved :: GNU Library or Lesser '
|
|
|
|
'General Public License (LGPL)',
|
2010-11-03 21:05:03 +00:00
|
|
|
'Natural Language :: English',
|
|
|
|
'Operating System :: MacOS :: MacOS X',
|
|
|
|
'Operating System :: Microsoft :: Windows',
|
|
|
|
'Operating System :: POSIX :: BSD :: FreeBSD',
|
|
|
|
'Operating System :: POSIX :: Linux',
|
|
|
|
'Programming Language :: Python :: 2.6',
|
|
|
|
'Programming Language :: Python :: 2.7',
|
|
|
|
'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',
|
2011-01-20 17:17:29 +00:00
|
|
|
'Topic :: Software Development :: User Interfaces'])
|
|
|
|
|