8 from distutils
.core
import setup
, Command
9 from distutils
.command
.clean
import clean
as distutils_clean
10 from distutils
.command
.sdist
import sdist
as distutils_sdist
12 class clean(distutils_clean
):
14 # In addition to what the normal clean run does, remove pyc
15 # and pyo and backup files from the source tree.
16 distutils_clean
.run(self
)
17 def should_remove(filename
):
18 if (filename
.lower()[-4:] in [".pyc", ".pyo"] or
19 filename
.endswith("~") or
20 (filename
.startswith("#") and filename
.endswith("#"))):
24 for pathname
, dirs
, files
in os
.walk(os
.path
.dirname(__file__
)):
25 for filename
in filter(should_remove
, files
):
26 try: os
.unlink(os
.path
.join(pathname
, filename
))
27 except EnvironmentError as err
:
30 try: os
.unlink("MANIFEST")
33 for base
in ["coverage", "build", "dist"]:
34 path
= os
.path
.join(os
.path
.dirname(__file__
), base
)
35 if os
.path
.isdir(path
):
38 class coverage_cmd(Command
):
39 description
= "generate test coverage data"
42 def initialize_options(self
):
45 def finalize_options(self
):
51 count
=True, trace
=False,
52 ignoredirs
=[sys
.prefix
, sys
.exec_prefix
])
59 self
.run_command("test")
60 tracer
.runfunc(run_tests
)
61 results
= tracer
.results()
62 coverage
= os
.path
.join(os
.path
.dirname(__file__
), "coverage")
63 results
.write_results(show_missing
=True, coverdir
=coverage
)
64 map(os
.unlink
, glob
.glob(os
.path
.join(coverage
, "[!b]*.cover")))
65 try: os
.unlink(os
.path
.join(coverage
, "..setup.cover"))
70 for filename
in glob
.glob(os
.path
.join(coverage
, "*.cover")):
71 lines
= open(filename
, "rU").readlines()
72 total_lines
+= len(lines
)
74 [line
for line
in lines
if
75 (line
.startswith(">>>>>>") and
76 "finally:" not in line
and '"""' not in line
)])
77 pct
= 100.0 * (total_lines
- bad_lines
) / float(total_lines
)
78 print("Coverage data written to %s (%d/%d, %0.2f%%)" % (
79 coverage
, total_lines
- bad_lines
, total_lines
, pct
))
81 class sdist(distutils_sdist
):
83 self
.run_command("test")
84 distutils_sdist
.run(self
)
86 class test_cmd(Command
):
87 description
= "run automated tests"
89 ("to-run=", None, "list of tests to run (default all)"),
92 def initialize_options(self
):
96 def finalize_options(self
):
98 self
.to_run
= self
.to_run
.split(",")
102 if tests
.unit(self
.to_run
):
103 raise SystemExit("Test failures are listed above.")
105 if __name__
== "__main__":
107 clean
=clean
, test
=test_cmd
, coverage
=coverage_cmd
, sdist
=sdist
),
108 name
="python-bulletml", version
="1",
109 url
="http://code.google.com/p/python-bulletml/",
110 description
="parse and run BulletML scripts",
111 author
="Joe Wreschnig",
112 author_email
="joe.wreschnig@gmail.com",
114 packages
=["bulletml"],
115 data_files
=glob
.glob("examples/*/*.xml") + ["examples/template.xml"],
116 scripts
=["bulletml-runner", "bulletml-to-bulletyaml"],
117 long_description
="""\
118 BulletML is the Bullet Markup Language. BulletML can describe the
119 barrage of bullets in shooting games. (For example Progear, Psyvariar,
120 Gigawing2, G DARIUS, XEVIOUS, ...) This module parses and executes
121 BulletML scripts in Python. All data structures in it are
124 In addition to the standard BulletML XML format, this module supports
125 an equivalent YAML format.
127 Finally, two simple collision routines are provided, bulletml.overlaps
128 for stationary circles and bulletml.collides for moving circles.
130 A sample renderer for Pygame is included.
132 More information is available at the BulletML homepage,
133 http://www.asahi-net.or.jp/~cs8k-cyu/bulletml/index_e.html, or the
134 python-bullet homepage, http://code.google.com/p/python-bulletml/.