示例#1
0
    def _static_representation(self, bento_info):
        r_pkg = PackageDescription.from_string(bento_info)
        # We recompute pkg to avoid dealing with stylistic difference between
        # original and static_representation
        pkg = PackageDescription.from_string(static_representation(r_pkg))

        self.assertEqual(static_representation(pkg), static_representation(r_pkg))
示例#2
0
    def _static_representation(self, bento_info):
        r_pkg = PackageDescription.from_string(bento_info)
        # We recompute pkg to avoid dealing with stylistic difference between
        # original and static_representation
        pkg = PackageDescription.from_string(static_representation(r_pkg))

        self.assertEqual(static_representation(pkg),
                         static_representation(r_pkg))
示例#3
0
    def test_simple_package(self):
        bento_info = """\
Name: foo
Version: 1.0

ExtraSourceFiles: yeah.info

Library:
    Packages: foo, foo.bar
    Modules: fubar
"""
        archive_list = [
            op.join("foo-1.0", f) for f in [
                "yeah.info", "PKG_INFO",
                op.join("foo", "__init__.py"),
                op.join("foo", "bar", "__init__.py"), "fubar.py"
            ]
        ]

        create_fake_package_from_bento_info(self.top_node, bento_info)
        package = PackageDescription.from_string(bento_info)

        sdist = SdistCommand()
        opts = OptionsContext.from_command(sdist)
        cmd_argv = ["--output-file=foo.zip", "--format=zip"]

        context = SdistContext(None, cmd_argv, opts, package, self.run_node)
        run_command_in_context(context, sdist)

        self._assert_archive_equality(op.join("dist", "foo.zip"), archive_list)
    def test_iter_source_nodes(self):
        r_files = set([op.join("src", "foo.c"),
            op.join("src", "bar.c"),
            op.join("src", "fubar.c"),
            op.join("foo", "__init__.py"),
            op.join("foo", "bar", "__init__.py"),
            "fu.py", "foo.1"])

        bento_info = """\
Name: foo

DataFiles: foo
    TargetDir: $sharedir
    Files: foo.1

Library:
    Extension: _foo
        Sources: src/foo.c, src/bar.c
    CompiledLibrary: fubar
        Sources: src/fubar.c
    Packages: foo, foo.bar
    Modules: fu
"""
        create_fake_package_from_bento_info(self.top_node, bento_info)

        package = PackageDescription.from_string(bento_info)
        node_package = NodeRepresentation(self.top_node, self.top_node)
        node_package.update_package(package)

        files = set(n.path_from(self.top_node) for n in node_package.iter_source_nodes())
        self.assertEqual(files, r_files)
示例#5
0
    def test_extra_source_registration(self):
        bento_info = """\
Name: foo
Version: 1.0

Library:
    Modules: fubar
"""
        archive_list = [
            op.join("foo-1.0", f)
            for f in ["fubar.py", "yeah.info", "PKG_INFO"]
        ]

        extra_node = self.top_node.make_node("yeah.info")
        extra_node.write("")

        create_fake_package_from_bento_info(self.top_node, bento_info)
        package = PackageDescription.from_string(bento_info)

        sdist = SdistCommand()
        opts = OptionsContext.from_command(sdist)
        cmd_argv = ["--output-file=foo.zip", "--format=zip"]

        context = SdistContext(None, cmd_argv, opts, package, self.run_node)
        context.register_source_node(self.top_node.find_node("yeah.info"))
        run_command_in_context(context, sdist)

        self._assert_archive_equality(op.join("dist", "foo.zip"), archive_list)
示例#6
0
    def test_simple_package(self):
        bento_info = """\
Name: foo
Version: 1.0

ExtraSourceFiles: yeah.info

Library:
    Packages: foo, foo.bar
    Modules: fubar
"""
        archive_list = [op.join("foo-1.0", f) for f in ["yeah.info",
                                                        op.join("foo", "__init__.py"),
                                                        op.join("foo", "bar", "__init__.py"),
                                                        "fubar.py"]]

        create_fake_package_from_bento_info(self.top_node, bento_info)
        package = PackageDescription.from_string(bento_info)

        sdist = SdistCommand()
        opts = OptionsContext.from_command(sdist)
        cmd_argv = ["--output-file=foo.zip", "--format=zip"]

        context = SdistContext(None, cmd_argv, opts, package, self.run_node)
        sdist.run(context)
        sdist.shutdown(context)
        context.shutdown()

        archive = self.run_node.find_node(op.join("dist", "foo.zip"))
        z = zipfile.ZipFile(archive.abspath(), "r")
        for f in archive_list:
            if not f in z.namelist():
                self.failUnless(op.join("foo-1.0", f) in files)
示例#7
0
    def test_compiled_library(self):
        from bento.backends.distutils_backend import DistutilsBuildContext

        r_full_name = "lib/_foo"

        bento_info = """\
Name: foo

Library:
    CompiledLibrary: lib/_foo
        Sources: foo.c
"""
        package = PackageDescription.from_string(bento_info)
        create_fake_package_from_bento_info(self.top_node, bento_info)

        options = OptionsContext.from_command(BuildCommand())
        context = DistutilsBuildContext(None, [], options, package, self.run_node)
        context.pre_recurse(self.top_node)
        try:
            def builder(a):
                self.assertEqual(a.name, r_full_name)
                builder.is_called = True
            builder.is_called = False
            context.register_compiled_library_builder("lib/_foo", builder)
        finally:
            context.post_recurse()
        context.compile()

        self.assertTrue(builder.is_called, "registered builder not called")
示例#8
0
    def _run_configure(self,
                       bentos,
                       bscripts=None,
                       configure_argv=None,
                       build_argv=None):
        from bento.backends.waf_backend import make_stream_logger
        from bento.backends.waf_backend import WafBackend

        top_node = self.top_node

        bento_info = bentos["bento.info"]
        package = PackageDescription.from_string(bento_info)
        package_options = PackageOptions.from_string(bento_info)

        create_fake_package_from_bento_info(top_node, bento_info)
        top_node.make_node("bento.info").safe_write(bento_info)

        global_context = create_global_context(package, package_options,
                                               WafBackend())
        conf, configure = prepare_command(global_context, "configure",
                                          configure_argv, package, top_node)
        run_command_in_context(conf, configure)

        bld, build = prepare_command(global_context, "build", build_argv,
                                     package, top_node)
        bld.waf_context.logger = make_stream_logger("build", cStringIO())
        return conf, configure, bld, build
示例#9
0
    def test_extra_source_registration(self):
        bento_info = """\
Name: foo
Version: 1.0

Library:
    Modules: fubar
"""
        archive_list = [op.join("foo-1.0", f) for f in ["fubar.py", "yeah.info"]]

        extra_node = self.top_node.make_node("yeah.info")
        extra_node.write("")

        create_fake_package_from_bento_info(self.top_node, bento_info)
        package = PackageDescription.from_string(bento_info)

        sdist = SdistCommand()
        opts = OptionsContext.from_command(sdist)
        cmd_argv = ["--output-file=foo.zip", "--format=zip"]

        context = SdistContext(None, cmd_argv, opts, package, self.run_node)
        context.register_source_node(self.top_node.find_node("yeah.info"))
        sdist.run(context)
        sdist.shutdown(context)
        context.shutdown()

        archive = self.run_node.find_node(op.join("dist", "foo.zip"))
        z = zipfile.ZipFile(archive.abspath(), "r")
        for f in archive_list:
            if not f in z.namelist():
                self.failUnless(op.join("foo-1.0", f) in files)
示例#10
0
    def test_template_filling(self):
        bento_info = """\
Name: foo
Version: 1.0

MetaTemplateFile: release.py.in

Library:
    Modules: fubar
"""
        archive_list = [op.join("foo-1.0", f) for f in ["fubar.py", "release.py.in", "release.py"]]

        template = self.top_node.make_node("release.py.in")
        template.write("""\
NAME = $NAME
VERSION = $VERSION
""")

        create_fake_package_from_bento_info(self.top_node, bento_info)
        package = PackageDescription.from_string(bento_info)

        sdist = SdistCommand()
        opts = OptionsContext.from_command(sdist)
        cmd_argv = ["--output-file=foo.zip", "--format=zip"]

        context = SdistContext(None, cmd_argv, opts, package, self.run_node)
        run_command_in_context(context, sdist)

        self._assert_archive_equality(op.join("dist", "foo.zip"), archive_list)
示例#11
0
    def test_compiled_library(self):
        from bento.backends.distutils_backend import DistutilsBuildContext

        r_full_name = "lib/_foo"

        bento_info = """\
Name: foo

Library:
    CompiledLibrary: lib/_foo
        Sources: foo.c
"""
        package = PackageDescription.from_string(bento_info)
        create_fake_package_from_bento_info(self.top_node, bento_info)

        options = OptionsContext.from_command(BuildCommand())
        context = DistutilsBuildContext(None, [], options, package,
                                        self.run_node)
        context.pre_recurse(self.top_node)
        try:

            def builder(a):
                self.assertEqual(a.name, r_full_name)
                builder.is_called = True

            builder.is_called = False
            context.register_compiled_library_builder("lib/_foo", builder)
        finally:
            context.post_recurse()
        context.compile()

        self.assertTrue(builder.is_called, "registered builder not called")
示例#12
0
    def test_simple(self):
        text = """\
NName: foo
"""
        error_msg = "Unrecognized keyword: 'NName'"
        self.assertRaisesRegex(ParseError, error_msg,
                               lambda: PackageDescription.from_string(text))
示例#13
0
    def test_simple_package(self):
        bento_info = """\
Name: foo
Version: 1.0

ExtraSourceFiles: yeah.info

Library:
    Packages: foo, foo.bar
    Modules: fubar
"""
        archive_list = [op.join("foo-1.0", f) for f in ["yeah.info",
                                                        op.join("foo", "__init__.py"),
                                                        op.join("foo", "bar", "__init__.py"),
                                                        "fubar.py"]]

        create_fake_package_from_bento_info(self.top_node, bento_info)
        package = PackageDescription.from_string(bento_info)

        sdist = SdistCommand()
        opts = OptionsContext.from_command(sdist)
        cmd_argv = ["--output-file=foo.zip", "--format=zip"]

        context = SdistContext(None, cmd_argv, opts, package, self.run_node)
        run_command_in_context(context, sdist)

        self._assert_archive_equality(op.join("dist", "foo.zip"), archive_list)
    def test_iter_source_nodes(self):
        r_files = set([
            op.join("src", "foo.c"),
            op.join("src", "bar.c"),
            op.join("src", "fubar.c"),
            op.join("foo", "__init__.py"),
            op.join("foo", "bar", "__init__.py"), "fu.py", "foo.1"
        ])

        bento_info = """\
Name: foo

DataFiles: foo
    TargetDir: $sharedir
    Files: foo.1

Library:
    Extension: _foo
        Sources: src/foo.c, src/bar.c
    CompiledLibrary: fubar
        Sources: src/fubar.c
    Packages: foo, foo.bar
    Modules: fu
"""
        create_fake_package_from_bento_info(self.top_node, bento_info)

        package = PackageDescription.from_string(bento_info)
        node_package = NodeRepresentation(self.top_node, self.top_node)
        node_package.update_package(package)

        files = set(
            n.path_from(self.top_node)
            for n in node_package.iter_source_nodes())
        self.assertEqual(files, r_files)
示例#15
0
    def test_extra_source_registration(self):
        bento_info = """\
Name: foo
Version: 1.0

Library:
    Modules: fubar
"""
        archive_list = [op.join("foo-1.0", f) for f in ["fubar.py", "yeah.info"]]

        extra_node = self.top_node.make_node("yeah.info")
        extra_node.write("")

        create_fake_package_from_bento_info(self.top_node, bento_info)
        package = PackageDescription.from_string(bento_info)

        sdist = SdistCommand()
        opts = OptionsContext.from_command(sdist)
        cmd_argv = ["--output-file=foo.zip", "--format=zip"]

        context = SdistContext(None, cmd_argv, opts, package, self.run_node)
        context.register_source_node(self.top_node.find_node("yeah.info"))
        run_command_in_context(context, sdist)

        self._assert_archive_equality(op.join("dist", "foo.zip"), archive_list)
示例#16
0
    def test_template_filling(self):
        bento_info = """\
Name: foo
Version: 1.0

MetaTemplateFiles: release.py.in

Library:
    Modules: fubar
"""
        archive_list = [
            op.join("foo-1.0", f)
            for f in ["fubar.py", "release.py.in", "release.py", "PKG_INFO"]
        ]

        template = self.top_node.make_node("release.py.in")
        template.write("""\
NAME = $NAME
VERSION = $VERSION
""")

        create_fake_package_from_bento_info(self.top_node, bento_info)
        package = PackageDescription.from_string(bento_info)

        sdist = SdistCommand()
        opts = OptionsContext.from_command(sdist)
        cmd_argv = ["--output-file=foo.zip", "--format=zip"]

        context = SdistContext(None, cmd_argv, opts, package, self.run_node)
        run_command_in_context(context, sdist)

        self._assert_archive_equality(op.join("dist", "foo.zip"), archive_list)
示例#17
0
    def test_template_filling(self):
        bento_info = """\
Name: foo
Version: 1.0

MetaTemplateFile: release.py.in

Library:
    Modules: fubar
"""
        archive_list = [op.join("foo-1.0", f) for f in ["fubar.py", "release.py.in", "release.py"]]

        template = self.top_node.make_node("release.py.in")
        template.write("""\
NAME = $NAME
VERSION = $VERSION
""")

        create_fake_package_from_bento_info(self.top_node, bento_info)
        package = PackageDescription.from_string(bento_info)

        sdist = SdistCommand()
        opts = OptionsContext.from_command(sdist)
        cmd_argv = ["--output-file=foo.zip", "--format=zip"]

        context = SdistContext(None, cmd_argv, opts, package, self.run_node)
        sdist.run(context)
        sdist.shutdown(context)
        context.shutdown()

        archive = self.run_node.find_node(op.join("dist", "foo.zip"))
        z = zipfile.ZipFile(archive.abspath(), "r")
        for f in archive_list:
            if not f in z.namelist():
                self.fail("File %s not found in archive" % (f,))
示例#18
0
    def test_simple(self):
        text = """\
NName: foo
"""
        error_msg = """\
yacc: Syntax error at line 1, Token\(WORD, 'NName'\)
\t'NName: foo'"""
        self.assertRaisesRegexp(ParseError, error_msg, lambda : PackageDescription.from_string(text))
示例#19
0
    def test_simple(self):
        text = """\
NName: foo
"""
        error_msg = """\
yacc: Syntax error at line 1, Token\(WORD, 'NName'\)
\t'NName: foo'"""
        self.assertRaisesRegexp(ParseError, error_msg,
                                lambda: PackageDescription.from_string(text))
示例#20
0
    def _run_build_with_pre_hook(self, hook_func):
        package = PackageDescription.from_string(BENTO_INFO)
        global_context = prepare_package(self.top_node, BENTO_INFO)

        conf, configure = prepare_command(global_context, "configure", [], package, self.top_node)
        run_command_in_context(conf, configure)

        pre_hook = PreHookWrapper(hook_func, self.build_node.path_from(self.top_node), self.top_node.abspath())
        bld, build = prepare_command(global_context, "build", [], package, self.top_node)
        run_command_in_context(bld, build, pre_hooks=[pre_hook])

        return bld
示例#21
0
    def _run_build_with_pre_hook(self, hook_func):
        package = PackageDescription.from_string(BENTO_INFO)
        global_context = prepare_package(self.top_node, BENTO_INFO)

        conf, configure = prepare_command(global_context, "configure", [], package, self.top_node)
        run_command_in_context(conf, configure)

        pre_hook = PreHookWrapper(hook_func, self.build_node.path_from(self.top_node), self.top_node.abspath())
        bld, build = prepare_command(global_context, "build", [], package, self.top_node)
        run_command_in_context(bld, build, pre_hooks=[pre_hook])

        return bld
示例#22
0
    def test_simple(self):
        text = """\
Name: foo

DataFiles: data
    TargetDir: $datadir
    Files:
        foo.data
"""
        r_data = DataFiles("data", files=["foo.data"], target_dir="$datadir")
        pkg = PackageDescription.from_string(text)
        self.failUnless("data" in pkg.data_files)
        self.assertEqual(pkg.data_files["data"].__dict__, r_data.__dict__)
示例#23
0
    def test_simple(self):
        text = """\
Name: foo

DataFiles: data
    TargetDir: $datadir
    Files:
        foo.data
"""
        r_data = DataFiles("data", files=["foo.data"], target_dir="$datadir")
        pkg = PackageDescription.from_string(text)
        self.assertTrue("data" in pkg.data_files)
        self.assertEqual(pkg.data_files["data"].__dict__, r_data.__dict__)
def _run_convert_command(top_node, run_node, setup_py, bento_info, cmd_argv):
    setup_node = top_node.make_node("setup.py")
    setup_node.safe_write(setup_py)

    create_fake_package_from_bento_info(top_node, bento_info)
    package = PackageDescription.from_string(bento_info)

    cmd = ConvertCommand()
    opts = OptionsContext.from_command(cmd)

    context = CmdContext(None, cmd_argv, opts, package, run_node)
    cmd.run(context)
    cmd.finish(context)
    context.finish()
示例#25
0
    def _run_command(self):
        setup_node = self.top_node.make_node("setup.py")
        setup_node.safe_write("")

        create_fake_package_from_bento_info(self.top_node, "")
        package = PackageDescription.from_string("")

        cmd = DetectTypeCommand()
        opts = OptionsContext.from_command(cmd)

        context = CmdContext(None, [], opts, package, self.run_node)
        cmd.run(context)
        cmd.finish(context)
        context.finish()
    def _run_command(self):
        setup_node = self.top_node.make_node("setup.py")
        setup_node.safe_write("")

        create_fake_package_from_bento_info(self.top_node, "")
        package = PackageDescription.from_string("")

        cmd = DetectTypeCommand()
        opts = OptionsContext.from_command(cmd)

        context = CmdContext(None, [], opts, package, self.run_node)
        cmd.run(context)
        cmd.finish(context)
        context.finish()
示例#27
0
def _run_convert_command(top_node, run_node, setup_py, bento_info, cmd_argv):
    setup_node = top_node.make_node("setup.py")
    setup_node.safe_write(setup_py)

    create_fake_package_from_bento_info(top_node, bento_info)
    package = PackageDescription.from_string(bento_info)

    cmd = ConvertCommand()
    opts = OptionsContext.from_command(cmd)

    context = CmdContext(None, cmd_argv, opts, package, run_node)
    cmd.run(context)
    cmd.finish(context)
    context.finish()
示例#28
0
    def test_simple(self):
        n = self.top_node.make_node("doc/conf.py")
        n.parent.mkdir()
        n.write("")

        n = self.top_node.make_node("doc/contents.rst")
        n.write("")

        bento_info = "Name: foo"
        package = PackageDescription.from_string(bento_info)

        sphinx = SphinxCommand()
        opts = OptionsContext.from_command(sphinx)
        context = ContextWithBuildDirectory(None, [], opts, package, self.run_node)

        run_command_in_context(context, sphinx)
示例#29
0
    def _execute_build(self, bento_info):
        create_fake_package_from_bento_info(self.top_node, bento_info)
        # FIXME: this should be done automatically in create_fake_package_from_bento_info
        self.top_node.make_node("bento.info").safe_write(bento_info)

        package = PackageDescription.from_string(bento_info)
        package_options = PackageOptions.from_string(bento_info)

        global_context = create_global_context(package, package_options, YakuBackend())
        conf, configure = prepare_command(global_context, "configure", [], package, self.run_node)
        run_command_in_context(conf, configure)

        bld, build = prepare_command(global_context, "build", [], package, self.run_node)
        run_command_in_context(bld, build)

        return bld
示例#30
0
    def test_simple(self):
        n = self.top_node.make_node("doc/conf.py")
        n.parent.mkdir()
        n.write("")

        n = self.top_node.make_node("doc/contents.rst")
        n.write("")

        bento_info = "Name: foo"
        package = PackageDescription.from_string(bento_info)

        sphinx = SphinxCommand()
        opts = OptionsContext.from_command(sphinx)
        context = ContextWithBuildDirectory(None, [], opts, package, self.run_node)

        run_command_in_context(context, sphinx)
示例#31
0
    def _execute_build(self, bento_info):
        create_fake_package_from_bento_info(self.top_node, bento_info)
        # FIXME: this should be done automatically in create_fake_package_from_bento_info
        self.top_node.make_node("bento.info").safe_write(bento_info)

        package = PackageDescription.from_string(bento_info)
        package_options = PackageOptions.from_string(bento_info)

        global_context = create_global_context(package, package_options, YakuBackend())
        conf, configure = prepare_command(global_context, "configure", [], package, self.run_node)
        run_command_in_context(conf, configure)

        bld, build = prepare_command(global_context, "build", [], package, self.run_node)
        run_command_in_context(bld, build)

        return bld
示例#32
0
文件: test_egg.py 项目: B-Rich/Bento
    def _prepare_egg_info(self):
        create_fake_package(self.top_node, ["sphinx", "sphinx.builders"],
                            ["cat.py"], [Extension("_dog", [os.path.join("src", "dog.c")])])
        build_manifest_file = self.build_node.make_node(BUILD_MANIFEST_PATH)
        build_manifest_file.parent.mkdir()
        build_manifest_file.write("")

        files = [os.path.join("sphinx", "builders", "__init__.py"),
                 os.path.join("sphinx", "__init__.py"),
                 os.path.join("src", "dog.c"),
                 os.path.join("cat.py")]

        pkg = PackageDescription.from_string(DESCR)
        meta = PackageMetadata.from_package(pkg)
        executables = pkg.executables

        return EggInfo(meta, executables, files)
示例#33
0
    def test_simple_waf(self):
        from bento.backends.waf_backend import make_stream_logger
        from bento.backends.waf_backend import WafBackend

        top_node = self.top_node

        package = PackageDescription.from_string(BENTO_INFO_WITH_EXT)
        package_options = PackageOptions.from_string(BENTO_INFO_WITH_EXT)

        create_fake_package_from_bento_info(top_node, BENTO_INFO_WITH_EXT)
        top_node.make_node("bento.info").safe_write(BENTO_INFO_WITH_EXT)

        global_context = create_global_context(package, package_options, WafBackend())
        conf, configure = prepare_command(global_context, "configure", [], package, top_node)
        run_command_in_context(conf, configure)

        bld, build = prepare_command(global_context, "build", [], package, top_node)
        bld.waf_context.logger = make_stream_logger("build", cStringIO())
        run_command_in_context(bld, build)
示例#34
0
    def setUp(self):
        self.package = PackageDescription.from_string("""\
Name: foo
""")
        self.cwd = tempfile.mkdtemp()
        try:
            self.old_cwd = os.getcwd()
            os.chdir(self.cwd)

            filename = op.join(self.cwd, "foo.bin")
            fp = open(filename, "wb")
            try:
                fp.write(six.b("garbage"))
            finally:
                fp.close()

        except:
            shutil.rmtree(self.cwd)
            raise
示例#35
0
    def test_simple_waf(self):
        from bento.backends.waf_backend import make_stream_logger
        from bento.backends.waf_backend import WafBackend

        top_node = self.top_node

        package = PackageDescription.from_string(BENTO_INFO_WITH_EXT)
        package_options = PackageOptions.from_string(BENTO_INFO_WITH_EXT)

        create_fake_package_from_bento_info(top_node, BENTO_INFO_WITH_EXT)
        top_node.make_node("bento.info").safe_write(BENTO_INFO_WITH_EXT)

        global_context = create_global_context(package, package_options, WafBackend())
        conf, configure = prepare_command(global_context, "configure", [], package, top_node)
        run_command_in_context(conf, configure)

        bld, build = prepare_command(global_context, "build", [], package, top_node)
        bld.waf_context.logger = make_stream_logger("build", cStringIO())
        run_command_in_context(bld, build)
示例#36
0
    def setUp(self):
        self.package = PackageDescription.from_string("""\
Name: foo
""")
        self.cwd = tempfile.mkdtemp()
        try:
            self.old_cwd = os.getcwd()
            os.chdir(self.cwd)

            filename = op.join(self.cwd, "foo.bin")
            fp = open(filename, "wb")
            try:
                fp.write(six.b("garbage"))
            finally:
                fp.close()

        except:
            shutil.rmtree(self.cwd)
            raise
示例#37
0
    def _prepare_egg_info(self):
        create_fake_package(
            self.top_node, ["sphinx", "sphinx.builders"], ["cat.py"],
            [Extension("_dog", [os.path.join("src", "dog.c")])])
        build_manifest_file = self.build_node.make_node(BUILD_MANIFEST_PATH)
        build_manifest_file.parent.mkdir()
        build_manifest_file.write("")

        files = [
            os.path.join("sphinx", "builders", "__init__.py"),
            os.path.join("sphinx", "__init__.py"),
            os.path.join("src", "dog.c"),
            os.path.join("cat.py")
        ]

        pkg = PackageDescription.from_string(DESCR)
        meta = PackageMetadata.from_package(pkg)
        executables = pkg.executables

        return EggInfo(meta, executables, files)
示例#38
0
    def _run_configure(self, bentos, bscripts=None, configure_argv=None, build_argv=None):
        from bento.backends.waf_backend import make_stream_logger
        from bento.backends.waf_backend import WafBackend

        top_node = self.top_node

        bento_info = bentos["bento.info"]
        package = PackageDescription.from_string(bento_info)
        package_options = PackageOptions.from_string(bento_info)

        create_fake_package_from_bento_info(top_node, bento_info)
        top_node.make_node("bento.info").safe_write(bento_info)

        global_context = create_global_context(package, package_options, WafBackend())
        conf, configure = prepare_command(global_context, "configure",
                configure_argv, package, top_node)
        run_command_in_context(conf, configure)

        bld, build = prepare_command(global_context, "build", build_argv, package, top_node)
        bld.waf_context.logger = make_stream_logger("build", cStringIO())
        return conf, configure, bld, build
示例#39
0
    def test_prune_extra_files(self):
        files = ["doc/foo.info", "yeah.txt", "foo/__init__.py"]
        for f in files:
            n = self.top_node.make_node(f)
            n.parent.mkdir()
            n.write("")

        bento_info = """\
Name: foo

ExtraSourceFiles: yeah.txt

DataFiles: doc
    SourceDir: .
    TargetDir: $sitedir
    Files: doc/foo.info

Library:
    Packages: foo
"""
        pkg = PackageDescription.from_string(bento_info)
        files = prune_extra_files(files, pkg, self.top_node)
        self.assertEqual(files, ["yeah.txt"])
    def test_sources_glob(self):
        bento_info = """\
Name: foo

Library:
    Extension: _foo
        Sources: src/foo.c, src/bar.c
"""
        create_fake_package_from_bento_info(self.top_node, bento_info)

        bento_info = """\
Name: foo

Library:
    Extension: _foo
        Sources: src/*.c
"""
        pkg = PackageDescription.from_string(bento_info)
        node_pkg = NodeRepresentation(self.top_node, self.top_node)
        node_pkg.update_package(pkg)

        extensions = dict(node_pkg.iter_category("extensions"))
        self.assertEqual(len(extensions), 1)
        self.assertEqual(len(extensions["_foo"].nodes), 2)
    def test_sources_glob(self):
        bento_info = """\
Name: foo

Library:
    Extension: _foo
        Sources: src/foo.c, src/bar.c
"""
        create_fake_package_from_bento_info(self.top_node, bento_info)

        bento_info = """\
Name: foo

Library:
    Extension: _foo
        Sources: src/*.c
"""
        pkg = PackageDescription.from_string(bento_info)
        node_pkg = NodeRepresentation(self.top_node, self.top_node)
        node_pkg.update_package(pkg)

        extensions = dict(node_pkg.iter_category("extensions"))
        self.assertEqual(len(extensions), 1)
        self.assertEqual(len(extensions["_foo"].nodes), 2)
示例#42
0
    def test_simple(self):
        text = """\
NName: foo
"""
        error_msg = "Unrecognized keyword: 'NName'"
        self.assertRaisesRegexp(ParseError, error_msg, lambda : PackageDescription.from_string(text))