File: setup.py

package info (click to toggle)
python-box2d 2.0.2%2Bsvn20100109.244-1
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd, squeeze, wheezy
  • size: 2,864 kB
  • ctags: 3,280
  • sloc: cpp: 11,679; python: 10,103; xml: 477; makefile: 85; sh: 8
file content (109 lines) | stat: -rw-r--r-- 3,302 bytes parent folder | download
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#!/usr/bin/env python
"""
Setup script for pyBox2D distribution.

For installation instructions, see INSTALL.

Basic install steps:
 setup.py build

If that worked, then:
 setup.py install
"""

import os
from glob import glob

try:
    from setuptools import (setup, Extension)
    print 'Using setuptools.'
except:
    from distutils.core import (setup, Extension)
    print 'Setuptools not found; falling back on distutils.'

# release version number
box2d_version  = '2.0.2'
release_number = 1

# create the version string
version_str = "%sb%s" % (box2d_version, str(release_number))

def write_init(): 
    # read in the license header
    license_header = open(os.path.join('Box2D', 'pybox2d_license_header.txt')).read()

    # create the source code for the file
    init_source = [ "",
        "from Box2D import *",
        "__version__      = '%s'"    % version_str,
        "__version_info__ = (%s,%d)" % (box2d_version.replace('.', ','), release_number),
        ]

    # and create the __init__ file with the appropriate version string
    f=open('__init__.py', 'w')
    f.write(license_header)
    f.write( '\n'.join(init_source) )
    f.close()
    
source_paths = [
    'Box2D/Dynamics/',
    'Box2D/Dynamics/Contacts/',
    'Box2D/Dynamics/Controllers/',
    'Box2D/Dynamics/Joints/',
    'Box2D/Common/',
    'Box2D/Collision/',
    'Box2D/Collision/Shapes/',
    ]

# glob all of the paths and then flatten the list into one
box2d_source_files = ['Box2D/Box2D.i'] + \
    sum( [glob(os.path.join(path, "*.cpp")) for path in source_paths], [])

# arguments to pass to SWIG. for old versions of SWIG, -O (optimize) might not be present.
swig_arguments = '-c++ -IBox2D -O -includeall -ignoremissing -w201 -outdir .'

pybox2d_extension = \
    Extension('Box2D._Box2D', box2d_source_files, extra_compile_args=['-I.'], language='c++')

LONG_DESCRIPTION = \
""" 2D physics library Box2D %s for usage in Python.

    After installing please be sure to try out the testbed demos.
    They require either pygame or pyglet and are available on the
    homepage.

    pybox2d homepage: http://pybox2d.googlecode.com
    Box2D's homepage: http://www.box2d.org
    """ % (box2d_version,)

CLASSIFIERS = [
    "Development Status :: 4 - Beta",
    "Intended Audience :: Developers",
    "License :: OSI Approved :: zlib/libpng License",
    "Operating System :: Microsoft :: Windows",
    "Operating System :: MacOS :: MacOS X",
    "Operating System :: POSIX",
    "Programming Language :: Python",
    "Games :: Physics Libraries"
    ]

write_init()

setup_dict = dict(
    name             = "Box2D",
    version          = version_str,
    author           = "Ken Lauer",
    author_email     = "sirkne at gmail dot com",
    description      = "Python Box2D",
    license          = "zlib",
    url              ="http://pybox2d.googlecode.com/",
    long_description = LONG_DESCRIPTION,
    classifiers      = CLASSIFIERS,
    packages         = ['Box2D'],
    package_dir      = {'Box2D': '.'},
    options          = { 'build_ext': { 'swig_opts' : swig_arguments } },
    ext_modules      = [ pybox2d_extension ]
    )

# run the actual setup from distutils
setup( **setup_dict )