Ability to ignore files in activate/deactivate for extensions.
This commit is contained in:
parent
ff9cb94f4f
commit
de91c95e8e
@ -72,8 +72,7 @@ def traverse(self, dest_root, **kwargs):
|
|||||||
|
|
||||||
order=[pre|post] -- Whether to do pre- or post-order traveral.
|
order=[pre|post] -- Whether to do pre- or post-order traveral.
|
||||||
|
|
||||||
ignore=<container> -- Optional container of root-relative
|
ignore=<predicate> -- Predicate indicating which files to ignore.
|
||||||
paths to ignore.
|
|
||||||
|
|
||||||
follow_nonexisting -- Whether to descend into directories in
|
follow_nonexisting -- Whether to descend into directories in
|
||||||
src that do not exit in dest.
|
src that do not exit in dest.
|
||||||
@ -85,9 +84,7 @@ def traverse(self, dest_root, **kwargs):
|
|||||||
raise ValueError("Order must be 'pre' or 'post'.")
|
raise ValueError("Order must be 'pre' or 'post'.")
|
||||||
|
|
||||||
# List of relative paths to ignore under the src root.
|
# List of relative paths to ignore under the src root.
|
||||||
ignore = kwargs.get('ignore', None)
|
ignore = kwargs.get('ignore', lambda filename: False)
|
||||||
if isinstance(ignore, basestring):
|
|
||||||
ignore = (ignore,)
|
|
||||||
|
|
||||||
# Whether to descend when dirs dont' exist in dest.
|
# Whether to descend when dirs dont' exist in dest.
|
||||||
follow_nonexisting = kwargs.get('follow_nonexisting', True)
|
follow_nonexisting = kwargs.get('follow_nonexisting', True)
|
||||||
@ -98,7 +95,7 @@ def traverse(self, dest_root, **kwargs):
|
|||||||
dest_dirpath = os.path.join(dest_root, rel_path)
|
dest_dirpath = os.path.join(dest_root, rel_path)
|
||||||
|
|
||||||
# Don't descend into ignored directories
|
# Don't descend into ignored directories
|
||||||
if ignore and dest_dirpath in ignore:
|
if ignore(dest_dirpath):
|
||||||
return
|
return
|
||||||
|
|
||||||
# Don't descend into dirs in dest that do not exist in src.
|
# Don't descend into dirs in dest that do not exist in src.
|
||||||
@ -118,7 +115,7 @@ def traverse(self, dest_root, **kwargs):
|
|||||||
# Ignore particular paths inside the install root.
|
# Ignore particular paths inside the install root.
|
||||||
src_relpath = src_file[len(self._root):]
|
src_relpath = src_file[len(self._root):]
|
||||||
src_relpath = src_relpath.lstrip(os.path.sep)
|
src_relpath = src_relpath.lstrip(os.path.sep)
|
||||||
if ignore and src_relpath in ignore:
|
if ignore(src_relpath):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
yield (src_file, dest_file)
|
yield (src_file, dest_file)
|
||||||
|
@ -995,14 +995,15 @@ def activate(self, extension, **kwargs):
|
|||||||
always executed.
|
always executed.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
ignore_files = set(spack.install_layout.hidden_file_paths)
|
def ignore(filename):
|
||||||
ignore_files.update(kwargs.get('ignore', ()))
|
return (filename in spack.install_layout.hidden_file_paths or
|
||||||
|
kwargs.get('ignore', lambda f: False)(filename))
|
||||||
|
|
||||||
tree = LinkTree(extension.prefix)
|
tree = LinkTree(extension.prefix)
|
||||||
conflict = tree.find_conflict(self.prefix, ignore=ignore_files)
|
conflict = tree.find_conflict(self.prefix, ignore=ignore)
|
||||||
if conflict:
|
if conflict:
|
||||||
raise ExtensionConflictError(conflict)
|
raise ExtensionConflictError(conflict)
|
||||||
tree.merge(self.prefix, ignore=ignore_files)
|
tree.merge(self.prefix, ignore=ignore)
|
||||||
|
|
||||||
|
|
||||||
def do_deactivate(self):
|
def do_deactivate(self):
|
||||||
@ -1026,11 +1027,12 @@ def deactivate(self, extension, **kwargs):
|
|||||||
always executed.
|
always executed.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
ignore_files = set(spack.install_layout.hidden_file_paths)
|
def ignore(filename):
|
||||||
ignore_files.update(kwargs.get('ignore', ()))
|
return (filename in spack.install_layout.hidden_file_paths or
|
||||||
|
kwargs.get('ignore', lambda f: False)(filename))
|
||||||
|
|
||||||
tree = LinkTree(extension.prefix)
|
tree = LinkTree(extension.prefix)
|
||||||
tree.unmerge(self.prefix, ignore=ignore_files)
|
tree.unmerge(self.prefix, ignore=ignore)
|
||||||
|
|
||||||
|
|
||||||
def do_clean(self):
|
def do_clean(self):
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
from spack import *
|
from spack import *
|
||||||
|
|
||||||
class PyNose(Package):
|
class PyNose(Package):
|
||||||
"""nose extends the test loading and running features of unittest, making it easier to write, find and run tests."""
|
"""nose extends the test loading and running features of unittest,
|
||||||
|
making it easier to write, find and run tests."""
|
||||||
|
|
||||||
homepage = "https://pypi.python.org/pypi/nose"
|
homepage = "https://pypi.python.org/pypi/nose"
|
||||||
url = "https://pypi.python.org/packages/source/n/nose/nose-1.3.4.tar.gz"
|
url = "https://pypi.python.org/packages/source/n/nose/nose-1.3.4.tar.gz"
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
from spack import *
|
from spack import *
|
||||||
import os
|
import os
|
||||||
|
import re
|
||||||
|
|
||||||
class Python(Package):
|
class Python(Package):
|
||||||
"""The Python programming language."""
|
"""The Python programming language."""
|
||||||
@ -59,19 +60,21 @@ def setup_extension_environment(self, module, spec, ext_spec):
|
|||||||
mkdirp(module.site_packages_dir)
|
mkdirp(module.site_packages_dir)
|
||||||
|
|
||||||
|
|
||||||
def add_ignore_files(self, args):
|
def make_ignore(self, args):
|
||||||
"""Add some ignore files to activate/deactivate args."""
|
"""Add some ignore files to activate/deactivate args."""
|
||||||
ignore = set(args.get('ignore', ()))
|
orig_ignore = args.get('ignore', lambda f: False)
|
||||||
ignore.add(os.path.join(self.site_packages_dir, 'site.py'))
|
def ignore(filename):
|
||||||
ignore.add(os.path.join(self.site_packages_dir, 'site.pyc'))
|
return (re.search(r'/site\.pyc?$', filename) or
|
||||||
args.update(ignore=ignore)
|
re.search(r'\.pth$', filename) or
|
||||||
|
orig_ignore(filename))
|
||||||
|
return ignore
|
||||||
|
|
||||||
|
|
||||||
def activate(self, ext_pkg, **args):
|
def activate(self, ext_pkg, **args):
|
||||||
self.add_ignore_files(args)
|
args.update(ignore=self.make_ignore(args))
|
||||||
super(Python, self).activate(ext_pkg, **args)
|
super(Python, self).activate(ext_pkg, **args)
|
||||||
|
|
||||||
|
|
||||||
def deactivate(self, ext_pkg, **args):
|
def deactivate(self, ext_pkg, **args):
|
||||||
self.add_ignore_files(args)
|
args.update(ignore=self.make_ignore(args))
|
||||||
super(Python, self).deactivate(ext_pkg, **args)
|
super(Python, self).deactivate(ext_pkg, **args)
|
||||||
|
Loading…
Reference in New Issue
Block a user