def _detect_future_imports(session):
    """
    Detect all __future__ imports. Since these imports must come first in
    the source code, these are attempt to be detected outside of other
    spidering.

    Parameters
    ----------
    session: dictionary
        globals() from the user's environment
    """
    imports = []
    for k in list(session.keys()):
        v = session[k]
        if hasattr(v, '__module__'):
            if v.__module__ == '__future__':
                if k is 'print_function':
                    continue
                if not k.startswith('_'):
                    imports.append('from __future__ import %s' % k)
    return imports
