forked from minou/chipmunk-android
-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathsetup.py
More file actions
75 lines (65 loc) · 2.48 KB
/
Copy pathsetup.py
File metadata and controls
75 lines (65 loc) · 2.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import sys
from os import environ
from os.path import dirname, join
if environ.get('CYMUNK_USE_SETUPTOOLS'):
from setuptools import setup, Extension
print('Using setuptools')
else:
from distutils.core import setup
from distutils.extension import Extension
print('Using distutils')
try:
from Cython.Distutils import build_ext
have_cython = True
except ImportError:
have_cython = False
platform = sys.platform
if platform == 'win32':
cstdarg = '-std=gnu99'
else:
cstdarg = '-std=c99'
c_chipmunk_root = join(dirname(__file__), 'cymunk', 'Chipmunk-Physics')
c_chipmunk_src = join(c_chipmunk_root, 'src')
c_chipmunk_incs = [join(c_chipmunk_root, 'include'),
join(c_chipmunk_root, 'include', 'chipmunk')]
c_chipmunk_files = [join(c_chipmunk_src, x) for x in (
'cpSpatialIndex.c', 'cpSpaceHash.c', 'constraints/cpPivotJoint.c',
'constraints/cpConstraint.c', 'constraints/cpSlideJoint.c',
'constraints/cpRotaryLimitJoint.c', 'constraints/cpGrooveJoint.c',
'constraints/cpGearJoint.c', 'constraints/cpRatchetJoint.c',
'constraints/cpSimpleMotor.c', 'constraints/cpDampedRotarySpring.c',
'constraints/cpPinJoint.c', 'constraints/cpDampedSpring.c', 'cpSpaceStep.c',
'cpArray.c', 'cpArbiter.c', 'cpCollision.c', 'cpBBTree.c', 'cpSweep1D.c',
'chipmunk.c', 'cpSpaceQuery.c', 'cpBB.c', 'cpShape.c', 'cpSpace.c',
'cpVect.c', 'cpPolyShape.c', 'cpSpaceComponent.c', 'cpBody.c',
'cpHashSet.c')]
if have_cython:
cymunk_files = [
'cymunk/cymunk.pyx'
]
cmdclass = {'build_ext': build_ext}
else:
cymunk_files = ['cymunk/cymunk.c']
cmdclass = {}
extra_compile_args = [cstdarg, '-ffast-math', '-fPIC', '-DCHIPMUNK_FFI']
if platform == "darwin":
extra_compile_args += ['-Wno-implicit-function-declaration', '-Wno-incompatible-function-pointer-types']
elif platform == "linux":
extra_compile_args += ['-Wno-error=incompatible-pointer-types', '-Wno-error=implicit-function-declaration']
ext = Extension('cymunk.cymunk',
cymunk_files + c_chipmunk_files,
include_dirs=c_chipmunk_incs,
extra_compile_args=extra_compile_args)
setup(
name='cymunk',
description='Cython bindings for Chipmunk',
author='Mathieu Virbel and Nicolas Niemczycki',
author_email='mat@kivy.org',
cmdclass=cmdclass,
packages=['cymunk'],
package_data={'cymunk': ['*.pxd', '*.pxi', 'chipmunk/*.h',
'chipmunk/constraints/*.h']},
package_dir={'cymunk': 'cymunk'},
ext_modules=[ext],
version='0.0.0.dev0'
)