a6c07cd25aae80035a55fab7c0f111f9b517522f
8 from distutils
.core
import setup
, Command
, Extension
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__":
106 setup(cmdclass
=dict(clean
=clean
, test
=test_cmd
, coverage
=coverage_cmd
,
108 name
="python-bulletml", version
="3",
109 url
="https://yukkurigames.com/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 ext_modules
=[Extension(
118 'bulletml._collision',
119 [os
.path
.join('bulletml', '_collision.c')])],
120 long_description
="""\
121 BulletML is the Bullet Markup Language. BulletML can describe the
122 barrage of bullets in shooting games. (For example Progear, Psyvariar,
123 Gigawing2, G DARIUS, XEVIOUS, ...) This module parses and executes
124 BulletML scripts in Python. All data structures in it are
125 renderer-agnostic. A sample renderer for Pygame is included. The full
126 API documentation is contained in its Python docstrings.
128 In addition to the standard BulletML XML format, this module supports
129 an equivalent YAML format. For convenience, two simple collision
130 routines are provided, bulletml.overlaps for stationary circles and
131 bulletml.collides for moving circles.
133 More information is available at the BulletML homepage,
134 http://www.asahi-net.or.jp/~cs8k-cyu/bulletml/index_e.html, or the
135 python-bulletml homepage, https://yukkurigames.com/python-bulletml/.