8 from distutils
.core
import setup
, Command
, Extension
11 from Pyrex
.Distutils
import build_ext
13 from distutils
.command
.build_ext
import build_ext
16 ext_modules
= [Extension(
17 'bulletml._collision', [os
.path
.join('bulletml', '_collision.pyx')])]
19 from distutils
.command
.clean
import clean
as distutils_clean
20 from distutils
.command
.sdist
import sdist
as distutils_sdist
22 class clean(distutils_clean
):
24 # In addition to what the normal clean run does, remove pyc
25 # and pyo and backup files from the source tree.
26 distutils_clean
.run(self
)
27 def should_remove(filename
):
28 if (filename
.lower()[-4:] in [".pyc", ".pyo"] or
29 filename
.endswith("~") or
30 (filename
.startswith("#") and filename
.endswith("#"))):
34 for pathname
, dirs
, files
in os
.walk(os
.path
.dirname(__file__
)):
35 for filename
in filter(should_remove
, files
):
36 try: os
.unlink(os
.path
.join(pathname
, filename
))
37 except EnvironmentError as err
:
40 try: os
.unlink("MANIFEST")
43 for base
in ["coverage", "build", "dist"]:
44 path
= os
.path
.join(os
.path
.dirname(__file__
), base
)
45 if os
.path
.isdir(path
):
48 class coverage_cmd(Command
):
49 description
= "generate test coverage data"
52 def initialize_options(self
):
55 def finalize_options(self
):
61 count
=True, trace
=False,
62 ignoredirs
=[sys
.prefix
, sys
.exec_prefix
])
69 self
.run_command("test")
70 tracer
.runfunc(run_tests
)
71 results
= tracer
.results()
72 coverage
= os
.path
.join(os
.path
.dirname(__file__
), "coverage")
73 results
.write_results(show_missing
=True, coverdir
=coverage
)
74 map(os
.unlink
, glob
.glob(os
.path
.join(coverage
, "[!b]*.cover")))
75 try: os
.unlink(os
.path
.join(coverage
, "..setup.cover"))
80 for filename
in glob
.glob(os
.path
.join(coverage
, "*.cover")):
81 lines
= open(filename
, "rU").readlines()
82 total_lines
+= len(lines
)
84 [line
for line
in lines
if
85 (line
.startswith(">>>>>>") and
86 "finally:" not in line
and '"""' not in line
)])
87 pct
= 100.0 * (total_lines
- bad_lines
) / float(total_lines
)
88 print("Coverage data written to %s (%d/%d, %0.2f%%)" % (
89 coverage
, total_lines
- bad_lines
, total_lines
, pct
))
91 class sdist(distutils_sdist
):
93 self
.run_command("test")
94 distutils_sdist
.run(self
)
96 class test_cmd(Command
):
97 description
= "run automated tests"
99 ("to-run=", None, "list of tests to run (default all)"),
102 def initialize_options(self
):
106 def finalize_options(self
):
108 self
.to_run
= self
.to_run
.split(",")
112 if tests
.unit(self
.to_run
):
113 raise SystemExit("Test failures are listed above.")
115 if __name__
== "__main__":
116 setup(cmdclass
=dict(clean
=clean
, test
=test_cmd
, coverage
=coverage_cmd
,
117 sdist
=sdist
, build_ext
=build_ext
),
118 name
="python-bulletml", version
="1",
119 url
="http://code.google.com/p/python-bulletml/",
120 description
="parse and run BulletML scripts",
121 author
="Joe Wreschnig",
122 author_email
="joe.wreschnig@gmail.com",
124 packages
=["bulletml"],
125 data_files
=glob
.glob("examples/*/*.xml") + ["examples/template.xml"],
126 scripts
=["bulletml-runner", "bulletml-to-bulletyaml"],
127 ext_modules
=ext_modules
,
128 long_description
="""\
129 BulletML is the Bullet Markup Language. BulletML can describe the
130 barrage of bullets in shooting games. (For example Progear, Psyvariar,
131 Gigawing2, G DARIUS, XEVIOUS, ...) This module parses and executes
132 BulletML scripts in Python. All data structures in it are
135 In addition to the standard BulletML XML format, this module supports
136 an equivalent YAML format.
138 Finally, two simple collision routines are provided, bulletml.overlaps
139 for stationary circles and bulletml.collides for moving circles.
141 A sample renderer for Pygame is included.
143 More information is available at the BulletML homepage,
144 http://www.asahi-net.or.jp/~cs8k-cyu/bulletml/index_e.html, or the
145 python-bullet homepage, http://code.google.com/p/python-bulletml/.