예제 #1
0
    def test_error_string(self):
        f = self.f
        f.write("NName: foo")
        f.flush()
        try:
            PackageDescription.from_file(f.name)
            raise AssertionError("Should raise here !")
        except ParseError:
            e = extract_exception()
            self.assertEqual(str(e), """\
  File "%s", line 1
NName: foo
^
Syntax error""" % f.name)
예제 #2
0
    def test_error_string(self):
        f = self.f
        f.write("NName: foo")
        f.flush()
        try:
            PackageDescription.from_file(f.name)
            raise AssertionError("Should raise here !")
        except ParseError:
            e = extract_exception()
            self.assertEqual(
                str(e), """\
  File "%s", line 1
NName: foo
^
Syntax error""" % f.name)
예제 #3
0
파일: sdist.py 프로젝트: dagss/Bento
    def run(self, ctx):
        o, a = self.parser.parse_args(ctx.cmd_opts)
        if o.help:
            self.parser.print_help()
            return

        filename = BENTO_SCRIPT
        if not len(a) > 0:
            if not os.path.exists(filename):
                raise UsageException("Missing %s file" % BENTO_SCRIPT)

        pkg = PackageDescription.from_file(filename)
        tarname = tarball_basename(pkg.name, pkg.version) + ".tar.gz"
        self.tarname = os.path.abspath(os.path.join("dist", tarname))
        self.topdir = "%s-%s" % (pkg.name, pkg.version)
        create_tarball(pkg, ctx.top_node, self.tarname, self.topdir)
예제 #4
0
파일: sdist.py 프로젝트: abadger/Bento
    def run(self, ctx):
        argv = ctx.get_command_arguments()
        p = ctx.options_context.parser
        o, a =  p.parse_args(argv)
        if o.help:
            p.print_help()
            return

        filename = BENTO_SCRIPT
        if not len(a) > 0:
            if not os.path.exists(filename):
                raise UsageException("Missing %s file" % BENTO_SCRIPT)

        pkg = PackageDescription.from_file(filename)
        tarname = tarball_basename(pkg.name, pkg.version) + ".tar.gz"
        self.tarname = os.path.abspath(os.path.join(o.output_dir, tarname))
        self.topdir = "%s-%s" % (pkg.name, pkg.version)
        create_tarball(pkg, ctx.top_node, self.tarname, self.topdir)
예제 #5
0
파일: dist.py 프로젝트: jjehannet/Bento
    def __init__(self, attrs=None):
        if attrs is None:
            attrs = {}

        if not "bento_info" in attrs:
            bento_info = "bento.info"
        else:
            bento_info = attrs["bento.info"]
        self.pkg = PackageDescription.from_file(bento_info)
        package_options = PackageOptions.from_file(bento_info)

        attrs = _setup_cmd_classes(attrs)

        d = pkg_to_distutils_meta(self.pkg)
        attrs.update(d)

        Distribution.__init__(self, attrs)

        self.packages = self.pkg.packages
        self.py_modules = self.pkg.py_modules
        if hasattr(self, "entry_points"):
            if self.entry_points is None:
                self.entry_points = {}
            console_scripts = [
                e.full_representation() for e in self.pkg.executables.values()
            ]
            if "console_scripts" in self.entry_points:
                self.entry_points["console_scripts"].extend(console_scripts)
            else:
                self.entry_points["console_scripts"] = console_scripts

        source_root = os.getcwd()
        build_root = os.path.join(source_root, "build")
        root = create_root_with_source_tree(source_root, build_root)
        self.top_node = root._ctx.srcnode
        self.build_node = root._ctx.bldnode
        self.run_node = root._ctx.srcnode

        self.global_context = global_context_factory(package_options)
        mods = set_main(self.pkg, self.top_node, self.build_node)
        self._setup_hooks(self.pkg, self.global_context, mods)
예제 #6
0
    def run(self, ctx):
        argv = ctx.get_command_arguments()
        p = ctx.options_context.parser
        o, a = p.parse_args(argv)
        if o.help:
            p.print_help()
            return
        bento_script = ctx.top_node.find_node(BENTO_SCRIPT)

        if not o.output:
            pkg_info = "PKG-INFO"
        else:
            pkg_info = o.output

        pkg = PackageDescription.from_file(bento_script.abspath())

        fid = open(pkg_info, "w")
        try:
            write_pkg_info(pkg, fid)
        finally:
            fid.close()
예제 #7
0
    def run(self, ctx):
        argv = ctx.command_argv
        p = ctx.options_context.parser
        o, a = p.parse_args(argv)
        if o.help:
            p.print_help()
            return
        bento_script = ctx.top_node.find_node(BENTO_SCRIPT)

        if not o.output:
            pkg_info = "PKG-INFO"
        else:
            pkg_info = o.output

        pkg = PackageDescription.from_file(bento_script.abspath())

        fid = open(pkg_info, "w")
        try:
            write_pkg_info(pkg, fid)
        finally:
            fid.close()
예제 #8
0
파일: dist.py 프로젝트: pberkes/Bento
    def __init__(self, attrs=None):
        if attrs is None:
            attrs = {}

        if not "bento_info" in attrs:
            bento_info = "bento.info"
        else:
            bento_info = attrs["bento.info"]
        self.pkg = PackageDescription.from_file(bento_info)
        self.package_options = PackageOptions.from_file(bento_info)


        attrs = _setup_cmd_classes(attrs)

        d = pkg_to_distutils_meta(self.pkg)
        attrs.update(d)

        Distribution.__init__(self, attrs)

        self.packages = self.pkg.packages
        self.py_modules = self.pkg.py_modules
        if hasattr(self, "entry_points"):
            if self.entry_points is None:
                self.entry_points = {}
            console_scripts = [e.full_representation() for e in self.pkg.executables.values()]
            if "console_scripts" in self.entry_points:
                self.entry_points["console_scripts"].extend(console_scripts)
            else:
                self.entry_points["console_scripts"] = console_scripts

        source_root = os.getcwd()
        build_root = os.path.join(source_root, "build")
        root = create_root_with_source_tree(source_root, build_root)
        self.top_node = root._ctx.srcnode
        self.build_node = root._ctx.bldnode
        self.run_node = root._ctx.srcnode

        self.global_context = global_context_factory(self.package_options)
        modules = set_main(self.top_node, self.build_node, self.pkg)
예제 #9
0
    def run(self, ctx):
        o, a = self.parser.parse_args(ctx.cmd_opts)
        if o.help:
            self.parser.print_help()
            return

        if len(a) < 1:
            raise UsageException("%s: error: %s subcommand require an argument" \
                    % (SCRIPT_NAME, "parse"))
        else:
            filename = a[0]

        if not o.output:
            pkg_info = "PKG-INFO"
        else:
            pkg_info = o.output

        pkg = PackageDescription.from_file(filename)

        fid = open(pkg_info, "w")
        try:
            write_pkg_info(pkg, fid)
        finally:
            fid.close()
예제 #10
0
파일: test_ipkg.py 프로젝트: abadger/Bento
    import \
        PackageDescription
from bento.core.utils \
    import \
        subst_vars
from bento.installed_package_description \
    import \
        InstalledPkgDescription, InstalledSection, ipkg_meta_from_pkg, iter_files

import bento.tests.bentos

# FIXME: use correct install path instead of python package hack
BENTOS_DIR = os.path.dirname(bento.tests.bentos.__file__)
SPHINX_META = os.path.join(BENTOS_DIR, "sphinx_meta.info")

SPHINX_META_PKG = PackageDescription.from_file(SPHINX_META)

class TestInstalledSection(unittest.TestCase):
    def test_simple(self):
        files = [("scripts/foo.py", "scripts/foo"),
                 ("scripts/bar.py", "scripts/bar.py")]
        section = InstalledSection("pythonfiles", "section1", "source", "target", files)

    def test_from_source_target(self):
        files = [("scripts/foo.py", "scripts/foo.py"),
                 ("scripts/bar.py", "scripts/bar.py")]
        r_section = InstalledSection("pythonfiles", "section1", "source", "target", files)

        files = ["scripts/foo.py", "scripts/bar.py"]
        section = InstalledSection.from_source_target_directories("pythonfiles",
                        "section1", "source", "target", files)
예제 #11
0
 def test_simple_filename(self):
     f = self.f
     f.write("NName: foo")
     f.flush()
     self.assertRaises(ParseError,
                       lambda: PackageDescription.from_file(f.name))
예제 #12
0
 def test_simple_filename(self):
     f = self.f
     f.write("NName: foo")
     f.flush()
     self.assertRaises(ParseError, lambda : PackageDescription.from_file(f.name))
예제 #13
0
import os

import bento.testing.bentos

from bento.core.package \
    import \
        PackageDescription
from bento.installed_package_description \
    import \
        InstalledSection, build_manifest_meta_from_pkg

# FIXME: use correct install path instead of python package hack
BENTOS_DIR = os.path.dirname(bento.testing.bentos.__file__)
SPHINX_META = os.path.join(BENTOS_DIR, "sphinx_meta.info")

SPHINX_META_PKG = PackageDescription.from_file(SPHINX_META)


def create_simple_build_manifest_args(top_node):
    files = ["scripts/foo.py", "scripts/bar.py"]
    srcdir = "source"

    nodes = [top_node.make_node(os.path.join(srcdir, f)) for f in files]
    for n in nodes:
        n.parent.mkdir()
        n.write("")
    section = InstalledSection.from_source_target_directories(
        "pythonfiles", "section1", os.path.join("$_srcrootdir", srcdir),
        "$prefix/target", files)
    sections = {"pythonfiles": {"section1": section}}