Source

sphinx / sphinx / __init__.py

georg.brandl df246e3 




georg.brandl 60f4650 
georg.brandl df246e3 
Georg Brandl 3a0071d 
Georg Brandl 4da052f 
georg.brandl df246e3 

Georg Brandl 18ee47d 


georg.brandl df246e3 
Georg Brandl 254e0ff 
georg.brandl df246e3 
Georg Brandl f1f6416 

gbrandl 83433c2 
Georg Brandl 254e0ff 
georg.brandl 56867cb 
Georg Brandl 2a7cd94 














georg.brandl 56867cb 
georg.brandl 156653d 
Georg Brandl d3456c0 
Jon Waltman f0272d2 
Georg Brandl 18ee47d 
Jon Waltman f0272d2 
Georg Brandl f96bd93 
Jon Waltman f0272d2 









georg.brandl df246e3 
Georg Brandl f96bd93 
Georg Brandl 18ee47d 

Georg Brandl f96bd93 


mitsuhiko c2214cc 
Georg Brandl f96bd93 


Georg Brandl 634e86e 
Georg Brandl f96bd93 

mitsuhiko c2214cc 

Georg Brandl 18ee47d 
Georg Brandl f96bd93 

Georg Brandl 18ee47d 


mitsuhiko c2214cc 
Georg Brandl 18ee47d 
georg.brandl df246e3 
Georg Brandl f96bd93 

georg.brandl df246e3 


# -*- coding: utf-8 -*-
"""
    Sphinx
    ~~~~~~

    The Sphinx documentation toolchain.

    :copyright: Copyright 2007-2011 by the Sphinx team, see AUTHORS.
    :license: BSD, see LICENSE for details.
"""

# Keep this file executable as-is in Python 3!
# (Otherwise getting the version out of it from setup.py is impossible.)

import sys
from os import path

__version__  = '1.2pre'
__released__ = '1.2 (hg)'  # used when Sphinx builds its own docs

package_dir = path.abspath(path.dirname(__file__))

if '+' in __version__ or 'pre' in __version__:
    # try to find out the changeset hash if checked out from hg, and append
    # it to __version__ (since we use this value from setup.py, it gets
    # automatically propagated to an installed copy as well)
    try:
        import subprocess
        p = subprocess.Popen(['hg', 'id', '-i', '-R',
                              path.join(package_dir, '..')],
                             stdout=subprocess.PIPE, stderr=subprocess.PIPE)
        out, err = p.communicate()
        if out:
            __version__ += '/' + out.strip()
    except Exception:
        pass


def main(argv=sys.argv):
    """Sphinx build "main" command-line entry."""
    if sys.version_info[:3] < (2, 5, 0):
        sys.stderr.write('Error: Sphinx requires at least '
                         'Python 2.5 to run.\n')
        return 1
    if sys.version_info[:3] >= (3, 3, 0):
        try:
            import docutils
            x, y = docutils.__version__.split('.')[:2]
            if (int(x), int(y)) < (0, 10):
                sys.stderr.write('Error: Sphinx requires at least '
                                 'Docutils 0.10 for Python 3.3 and above.\n')
                return 1
        except Exception:
            pass
    try:
        from sphinx import cmdline
    except ImportError:
        err = sys.exc_info()[1]
        errstr = str(err)
        if errstr.lower().startswith('no module named'):
            whichmod = errstr[16:]
            hint = ''
            if whichmod.startswith('docutils'):
                whichmod = 'Docutils library'
            elif whichmod.startswith('jinja'):
                whichmod = 'Jinja2 library'
            elif whichmod == 'roman':
                whichmod = 'roman module (which is distributed with Docutils)'
                hint = ('This can happen if you upgraded docutils using\n'
                        'easy_install without uninstalling the old version'
                        'first.\n')
            else:
                whichmod += ' module'
            sys.stderr.write('Error: The %s cannot be found. '
                             'Did you install Sphinx and its dependencies '
                             'correctly?\n' % whichmod)
            if hint:
                sys.stderr.write(hint)
            return 1
        raise
    return cmdline.main(argv)


if __name__ == '__main__':
    sys.exit(main(sys.argv))