Exemplo n.º 1
0
 def remove_files_from_view(self, view, merge_map):
     bin_dir = self.spec.prefix.bin
     for src, dst in merge_map.items():
         if not path_contains_subdirectory(src, bin_dir):
             view.remove_file(src, dst)
         else:
             os.remove(dst)
Exemplo n.º 2
0
    def remove_files_from_view(self, view, merge_map):
        ignore_namespace = False
        if self.py_namespace:
            ext_map = view.extensions_layout.extension_map(self.extendee_spec)
            remaining_namespaces = set(spec.package.py_namespace
                                       for name, spec in ext_map.items()
                                       if name != self.name)
            if self.py_namespace in remaining_namespaces:
                namespace_init = match_predicate(
                    r'site-packages/{0}/__init__.py'.format(self.py_namespace))
                ignore_namespace = True

        bin_dir = self.spec.prefix.bin
        global_view = (
            self.extendee_spec.prefix == view.get_projection_for_spec(
                self.spec))

        to_remove = []
        for src, dst in merge_map.items():
            if ignore_namespace and namespace_init(dst):
                continue

            if global_view or not path_contains_subdirectory(src, bin_dir):
                to_remove.append(dst)
            else:
                os.remove(dst)

        view.remove_files(to_remove)
Exemplo n.º 3
0
 def remove_files_from_view(self, view, merge_map):
     bin_dir = self.spec.prefix.bin
     for src, dst in merge_map.items():
         if not path_contains_subdirectory(src, bin_dir):
             view.remove_file(src, dst)
         else:
             os.remove(dst)
Exemplo n.º 4
0
    def add_files_to_view(self, view, merge_map):
        bin_dir = self.spec.prefix.bin
        for src, dst in merge_map.items():
            if not path_contains_subdirectory(src, bin_dir):
                view.link(src, dst)
            elif not os.path.islink(src):
                copy(src, dst)
                if 'script' in get_filetype(src):
                    filter_file(
                        self.spec.prefix,
                        os.path.abspath(
                            view.get_projection_for_spec(self.spec)
                        ),
                        dst,
                        backup=False
                    )
            else:
                # orig_link_target = os.path.realpath(src) is insufficient when
                # the spack install tree is located at a symlink or a
                # descendent of a symlink. What we need here is the real
                # relative path from the python prefix to src
                # TODO: generalize this logic in the link_tree object
                #    add a method to resolve a link relative to the link_tree
                #    object root.
                realpath_src = os.path.realpath(src)
                realpath_prefix = os.path.realpath(self.spec.prefix)
                realpath_rel = os.path.relpath(realpath_src, realpath_prefix)
                orig_link_target = os.path.join(self.spec.prefix, realpath_rel)

                new_link_target = os.path.abspath(merge_map[orig_link_target])
                view.link(new_link_target, dst)
Exemplo n.º 5
0
 def add_files_to_view(self, view, merge_map):
     bin_dir = self.spec.prefix.bin
     for src, dst in merge_map.items():
         if not path_contains_subdirectory(src, bin_dir):
             view.link(src, dst)
         elif not os.path.islink(src):
             shutil.copy2(src, dst)
             if 'script' in get_filetype(src):
                 filter_file(self.spec.prefix, os.path.abspath(view.root),
                             dst)
         else:
             orig_link_target = os.path.realpath(src)
             new_link_target = os.path.abspath(merge_map[orig_link_target])
             view.link(new_link_target, dst)
Exemplo n.º 6
0
 def add_files_to_view(self, view, merge_map):
     bin_dir = self.spec.prefix.bin
     for src, dst in merge_map.items():
         if not path_contains_subdirectory(src, bin_dir):
             view.link(src, dst)
         elif not os.path.islink(src):
             copy(src, dst)
             if 'script' in get_filetype(src):
                 filter_file(
                     self.spec.prefix, os.path.abspath(view.root), dst)
         else:
             orig_link_target = os.path.realpath(src)
             new_link_target = os.path.abspath(merge_map[orig_link_target])
             view.link(new_link_target, dst)
Exemplo n.º 7
0
 def add_files_to_view(self, view, merge_map):
     bin_dir = self.spec.prefix.bin
     python_prefix = self.extendee_spec.prefix
     global_view = same_path(python_prefix, view.root)
     for src, dst in merge_map.items():
         if os.path.exists(dst):
             continue
         elif global_view or not path_contains_subdirectory(src, bin_dir):
             view.link(src, dst)
         elif not os.path.islink(src):
             shutil.copy2(src, dst)
             if 'script' in get_filetype(src):
                 filter_file(python_prefix, os.path.abspath(view.root), dst)
         else:
             orig_link_target = os.path.realpath(src)
             new_link_target = os.path.abspath(merge_map[orig_link_target])
             view.link(new_link_target, dst)
Exemplo n.º 8
0
Arquivo: python.py Projeto: LLNL/spack
 def add_files_to_view(self, view, merge_map):
     bin_dir = self.spec.prefix.bin
     python_prefix = self.extendee_spec.prefix
     global_view = same_path(python_prefix, view.root)
     for src, dst in merge_map.items():
         if os.path.exists(dst):
             continue
         elif global_view or not path_contains_subdirectory(src, bin_dir):
             view.link(src, dst)
         elif not os.path.islink(src):
             shutil.copy2(src, dst)
             if 'script' in get_filetype(src):
                 filter_file(
                     python_prefix, os.path.abspath(view.root), dst)
         else:
             orig_link_target = os.path.realpath(src)
             new_link_target = os.path.abspath(merge_map[orig_link_target])
             view.link(new_link_target, dst)
Exemplo n.º 9
0
Arquivo: python.py Projeto: LLNL/spack
    def remove_files_from_view(self, view, merge_map):
        ignore_namespace = False
        if self.py_namespace:
            ext_map = view.extensions_layout.extension_map(self.extendee_spec)
            remaining_namespaces = set(
                spec.package.py_namespace for name, spec in ext_map.items()
                if name != self.name)
            if self.py_namespace in remaining_namespaces:
                namespace_init = match_predicate(
                    r'site-packages/{0}/__init__.py'.format(self.py_namespace))
                ignore_namespace = True

        bin_dir = self.spec.prefix.bin
        global_view = self.extendee_spec.prefix == view.root
        for src, dst in merge_map.items():
            if ignore_namespace and namespace_init(dst):
                continue

            if global_view or not path_contains_subdirectory(src, bin_dir):
                view.remove_file(src, dst)
            else:
                os.remove(dst)
Exemplo n.º 10
0
 def add_files_to_view(self, view, merge_map, skip_if_exists=True):
     bin_dir = self.spec.prefix.bin
     python_prefix = self.extendee_spec.prefix
     python_is_external = self.extendee_spec.external
     global_view = same_path(python_prefix,
                             view.get_projection_for_spec(self.spec))
     for src, dst in merge_map.items():
         if os.path.exists(dst):
             continue
         elif global_view or not path_contains_subdirectory(src, bin_dir):
             view.link(src, dst)
         elif not os.path.islink(src):
             shutil.copy2(src, dst)
             is_script = is_nonsymlink_exe_with_shebang(src)
             if is_script and not python_is_external:
                 filter_file(
                     python_prefix,
                     os.path.abspath(view.get_projection_for_spec(
                         self.spec)), dst)
         else:
             orig_link_target = os.path.realpath(src)
             new_link_target = os.path.abspath(merge_map[orig_link_target])
             view.link(new_link_target, dst)
Exemplo n.º 11
0
def in_system_subdirectory(path):
    system_dirs = [
        '/lib/', '/lib64/', '/usr/lib/', '/usr/lib64/', '/usr/local/lib/',
        '/usr/local/lib64/'
    ]
    return any(path_contains_subdirectory(path, x) for x in system_dirs)