def subclass_with_self(cls, name=None, attr='env', reverse_name=None, **kwargs
    ):
    """Subclass an env-compatible class by settring its ``attr`` attribute
        to be this env instance.

        Env-compatible means that the class has an attribute that provides
        the default env it should use, e.g.::

            class Foo:
                env = None

        :param cls: The env-compatible class to subclass.
        :keyword name: Custom name for the target class.
        :keyword attr: Name of the attribute holding the app, default is
            ``env``.
        """
