コード例 #1
0
ファイル: test_pkg_objects.py プロジェクト: aspidites/Bento
 def test_from_dict(self):
     parsed_dict = {"name": "data",
                    "files": ["foo.c", "yo.c"], "target_dir": "foo"}
     data = DataFiles.from_parse_dict(parsed_dict)
     self.assertEqual(data.name, "data")
     self.assertEqual(data.files, ["foo.c", "yo.c"])
     self.assertEqual(data.target_dir, "foo")
コード例 #2
0
ファイル: test_convert.py プロジェクト: yuhonghong7035/Bento
    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"])
コード例 #3
0
 def test_from_dict(self):
     parsed_dict = {"name": "data",
                    "files": ["foo.c", "yo.c"], "target_dir": "foo"}
     data = DataFiles.from_parse_dict(parsed_dict)
     self.assertEqual(data.name, "data")
     self.assertEqual(data.files, ["foo.c", "yo.c"])
     self.assertEqual(data.target_dir, "foo")
コード例 #4
0
ファイル: core.py プロジェクト: yuhonghong7035/Bento
def build_pkg(dist, package_objects, top_node):
    pkg = distutils_to_package_description(dist)
    modules = []
    for m in pkg.py_modules:
        if isinstance(m, basestring):
            modules.append(m)
        else:
            warnings.warn("The module %s it not understood" % str(m))
    pkg.py_modules = modules

    path_options = []
    data_sections = {}

    extra_source_files = []
    if package_objects.extra_source_files:
        extra_source_files.extend(
            [canonalize_path(f) for f in package_objects.extra_source_files])

    for pkg_name, source_dir, target_dir, files in package_objects.iter_data_files(
            top_node):
        if len(files) > 0:
            if len(pkg_name) > 0:
                name = "%s_data" % pkg_name.replace(".", "_")
            else:
                name = "dist_data"
            source_dir = canonalize_path(source_dir)
            target_dir = canonalize_path(target_dir)
            files = [canonalize_path(f) for f in files]
            data_sections[name] = DataFiles(name, files, target_dir,
                                            source_dir)
    pkg.data_files.update(data_sections)

    if dist.scripts:
        name = "%s_scripts" % pkg.name
        target_dir = "$bindir"
        pkg.data_files[name] = DataFiles(name, dist.scripts, target_dir, ".")

    # numpy.distutils bug: packages are appended twice to the Distribution
    # instance, so we prune the list here
    pkg.packages = sorted(list(set(pkg.packages)))
    options = {"path_options": path_options}

    pkg.extra_source_files = sorted(
        prune_extra_files(extra_source_files, pkg, top_node))

    return pkg, options
コード例 #5
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__)
コード例 #6
0
ファイル: test_convert.py プロジェクト: yuhonghong7035/Bento
    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", ".")})
コード例 #7
0
ファイル: package.py プロジェクト: abadger/Bento
def build_data_files_from_dict(data_files_d):
    data_files = {}
    for name, data_file_d in data_files_d.items():
        data_files[name] = DataFiles.from_parse_dict(data_file_d)
    return data_files
コード例 #8
0
ファイル: package.py プロジェクト: pfmoore/Bento
def build_data_files_from_dict(data_files_d):
    data_files = {}
    for name, data_file_d in data_files_d.items():
        data_files[name] = DataFiles.from_parse_dict(data_file_d)
    return data_files
コード例 #9
0
 def test_simple(self):
     data = DataFiles("data", files=["foo.c"])
     self.assertEqual(data.name, "data")
     self.assertEqual(data.files, ["foo.c"])
     self.assertEqual(data.source_dir, ".")
     self.assertEqual(data.target_dir, "$sitedir")