code: def in_builddir(sub='.'):
      
      from functools import wraps
  
      def wrap_in_builddir(func):
          """Wrap the function for the new build directory."""
  
          @wraps(func)
          def wrap_in_builddir_func(self, *args, **kwargs):
              """The actual function inside the wrapper for the new builddir."""
              p = local.path(self.builddir) / sub
              if not p.exists():
                  LOG.error("%s does not exist.", p)
  
              if p == local.cwd:
                  LOG.debug("CWD already is %s", p)
                  return func(self, *args, *kwargs)
              with local.cwd(p):
                  return func(self, *args, **kwargs)
  
          return wrap_in_builddir_func
  
      return wrap_in_builddir
docs: Decorate a project phase with a local working directory change.
  
      Args:
          sub: An optional subdirectory to change into.