def convert(ctx, filename, setup_args, monkey_patch_mode, verbose, output, log, show_output=True): if monkey_patch_mode == "automatic": try: if verbose: pprint("PINK", "Catching monkey (this may take a while) ...") monkey_patch_mode = detect_monkeys(filename, show_output, log) if verbose: pprint("PINK", "Detected mode: %s" % monkey_patch_mode) except ValueError: e = extract_exception() raise UsageException("Error while detecting setup.py type " \ "(original error: %s)" % str(e)) monkey_patch(ctx.top_node, monkey_patch_mode, filename) dist, package_objects = analyse_setup_py(filename, setup_args) pkg, options = build_pkg(dist, package_objects, ctx.top_node) out = static_representation(pkg, options) if output == '-': for line in out.splitlines(): pprint("YELLOW", line) else: fid = open(output, "w") try: fid.write(out) finally: fid.close()
def test_setuptools_include_package(self): top = self.top_node top.make_node("yeah.txt").write("") top.make_node("foo").mkdir() top.find_node("foo").make_node("__init__.py").write("") top.find_node("foo").make_node("foo.info").write("") top.make_node("MANIFEST.in").write("""\ include yeah.txt include foo/foo.info """) top.make_node("setup.py").write("""\ import setuptools from distutils.core import setup setup(name="foo", include_package_data=True, packages=["foo"]) """) monkey_patch(top, "setuptools", "setup.py") dist, package_objects = analyse_setup_py("setup.py", ["-n", "-q"]) pkg, options = build_pkg(dist, package_objects, top) self.assertEqual(pkg.data_files, {"foo_data": DataFiles("foo_data", ["foo.info"], "$sitedir/foo", "foo")}) self.assertEqual(pkg.extra_source_files, ["setup.py", "yeah.txt"])
def test_scripts(self): top = self.top_node top.make_node("foo").write("") top.make_node("setup.py").write("""\ from distutils.core import setup setup(name="foo", scripts=["foo"]) """) monkey_patch(top, "distutils", "setup.py") dist, package_objects = analyse_setup_py("setup.py", ["-n", "-q"]) pkg, options = build_pkg(dist, package_objects, top) self.assertEqual(pkg.data_files, {"foo_scripts": DataFiles("foo_scripts", ["foo"], "$bindir", ".")})