import functools


def wraps_py2(wrapped, *args):
    """Wrap a function and add the __wrapped__ attribute.

    In Python 2, functools.wraps does not add the __wrapped__ attribute, and it
    becomes impossible to retrieve the signature of the wrapped method.

    """
    def decorator(wrapper):
        functools.update_wrapper(wrapper, wrapped, *args)
        wrapper.__wrapped__ = wrapped
        return wrapper
    return decorator