Ejemplo n.º 1
0
def iter_files(file_sections):
    # XXX: what to do with multiple source for a same target ? It is not always
    # easy to avoid this situation, especially for python files and files
    # installed from wildcards. For now, we raise an exception unless the
    # sources have the exact same content, but this may not be enough (what if
    # category changes ? This may cause different target permissions and other
    # category-specific post-processing during install)
    installed_files = {}

    def _is_redundant(source, target):
        # If this install already installs something @ target, we raise an
        # error unless the content is exactly the same
        if not target in installed_files:
            installed_files[target] = source
            return False
        else:
            if not same_content(source, installed_files[target]):
                raise IOError("Multiple source for same target %r !" % target)
            else:
                return True

    if os.sep != "/":
        for kind in file_sections:
            for name, section in file_sections[kind].items():
                for source, target in section:
                    source = unnormalize_path(source)
                    target = unnormalize_path(target)
                    if not _is_redundant(source, target):
                        yield kind, source, target
    else:
        for kind in file_sections:
            for name, section in file_sections[kind].items():
                for source, target in section:
                    if not _is_redundant(source, target):
                        yield kind, source, target
Ejemplo n.º 2
0
def iter_files(file_sections):
    if os.sep != "/":
        for kind in file_sections:
            for name, section in file_sections[kind].items():
                for source, target in section:
                    yield kind, unnormalize_path(source), unnormalize_path(target)
    else:
        for kind in file_sections:
            for name, section in file_sections[kind].items():
                for source, target in section:
                    yield kind, source, target
Ejemplo n.º 3
0
 def normalize_paths(compiled_modules):
     if not compiled_modules:
         return {}
     else:
         for ext in compiled_modules.values():
             sources = []
             for s in ext.sources:
                 if isinstance(s, basestring):
                     sources.extend(expand_glob(s))
                 else:
                     print s
             if os.sep != "/":
                 sources = [unnormalize_path(s) for s in ext.sources]
             ext.sources = sources
         return compiled_modules
Ejemplo n.º 4
0
    def __init__(self, name=None, version=None, summary=None, url=None,
            author=None, author_email=None, maintainer=None,
            maintainer_email=None, license=None, description=None,
            platforms=None, packages=None, py_modules=None, extensions=None,
            install_requires=None, build_requires=None,
            download_url=None, extra_source_files=None, data_files=None,
            classifiers=None, provides=None, obsoletes=None, executables=None,
            hook_files=None, config_py=None, compiled_libraries=None,
            subpackages=None, description_from_file=None):
        # XXX: should we check that we have sequences when required
        # (py_modules, etc...) ?

        # Package content
        if not packages:
            self.packages = []
        else:
            self.packages = packages

        # Package content
        if not subpackages:
            self.subpackages = {}
        else:
            self.subpackages = subpackages

        if not py_modules:
            self.py_modules = []
        else:
            self.py_modules = py_modules

        def normalize_paths(compiled_modules):
            if not compiled_modules:
                return {}
            else:
                for ext in compiled_modules.values():
                    sources = []
                    for s in ext.sources:
                        if isinstance(s, basestring):
                            sources.extend(expand_glob(s))
                        else:
                            print s
                    if os.sep != "/":
                        sources = [unnormalize_path(s) for s in ext.sources]
                    ext.sources = sources
                return compiled_modules

        if extensions:
            self.extensions = extensions
        else:
            self.extensions = {}
        if compiled_libraries:
            self.compiled_libraries = compiled_libraries
        else:
            self.compiled_libraries = {}

        if not extra_source_files:
            self.extra_source_files = []
        else:
            self.extra_source_files = extra_source_files

        if not data_files:
            self.data_files = {}
        else:
            self.data_files = data_files

        if not executables:
            self.executables = {}
        else:
            self.executables = executables

        pkgs = []
        for p in self.packages:
            pkgs.append(p)
        for p in self.py_modules:
            pkgs.append(p)
        for p in self.extensions.values():
            pkgs.append(p.name)
        top_levels = [i for i in pkgs if not "." in i]

        # Package metadata
        _args = locals()
        kw = dict([(k, _args[k]) for k in _METADATA_FIELDS if k in _args])
        _set_metadata(self, **kw)

        if hook_files is not None:
            self.hook_files = hook_files
        else:
            self.hook_files = []

        if config_py is not None and os.sep != "/":
            self.config_py = unnormalize_path(config_py)
        else:
            self.config_py = config_py