示例#1
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)
示例#2
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)
示例#3
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,))
示例#4
0
def register_commands(global_context):
    global_context.register_command("help", HelpCommand())
    global_context.register_command("configure", ConfigureCommand())
    global_context.register_command("build", BuildCommand())
    global_context.register_command("install", InstallCommand())
    global_context.register_command("convert", ConvertCommand())
    global_context.register_command("sdist", SdistCommand())
    global_context.register_command("build_egg", BuildEggCommand())
    global_context.register_command("build_wininst", BuildWininstCommand())
    global_context.register_command("sphinx", SphinxCommand())
    global_context.register_command("register_pypi", RegisterPyPI())
    global_context.register_command("upload_pypi", UploadPyPI())

    global_context.register_command("build_pkg_info",
                                    BuildPkgInfoCommand(),
                                    public=False)
    global_context.register_command("parse", ParseCommand(), public=False)
    global_context.register_command("detect_type",
                                    DetectTypeCommand(),
                                    public=False)

    if sys.platform == "darwin":
        import bento.commands.build_mpkg
        global_context.register_command(
            "build_mpkg",
            bento.commands.build_mpkg.BuildMpkgCommand(),
            public=False)
        global_context.set_before("build_mpkg", "build")

    if sys.platform == "win32":
        from bento.commands.build_msi \
            import \
                BuildMsiCommand
        global_context.register_command("build_msi", BuildMsiCommand())
        global_context.set_before("build_msi", "build")
示例#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", "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)
示例#7
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)
def register_commands(global_context):
    global_context.register_command("configure", ConfigureCommand())
    global_context.register_command("build", BuildCommand())
    global_context.register_command("install", InstallCommand())
    global_context.register_command("sdist", SdistCommand())
    global_context.register_command("build_egg", BuildEggCommand())