mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Keep sphinx/__init__.py executable with Python 3.
This commit is contained in:
parent
c683c6ed83
commit
7866ce29c6
@ -9,6 +9,9 @@
|
||||
: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
|
||||
|
||||
@ -35,13 +38,14 @@ if '+' in __version__ or 'pre' in __version__:
|
||||
|
||||
def main(argv=sys.argv):
|
||||
if sys.version_info[:3] < (2, 4, 0):
|
||||
print >>sys.stderr, \
|
||||
'Error: Sphinx requires at least Python 2.4 to run.'
|
||||
sys.stderr.write('Error: Sphinx requires at least '
|
||||
'Python 2.4 to run.\n')
|
||||
return 1
|
||||
|
||||
try:
|
||||
from sphinx import cmdline
|
||||
except ImportError, err:
|
||||
except ImportError:
|
||||
err = sys.exc_info()[1]
|
||||
errstr = str(err)
|
||||
if errstr.lower().startswith('no module named'):
|
||||
whichmod = errstr[16:]
|
||||
@ -54,14 +58,14 @@ def main(argv=sys.argv):
|
||||
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.')
|
||||
'first.\n')
|
||||
else:
|
||||
whichmod += ' module'
|
||||
print >>sys.stderr, ('Error: The %s cannot be found. '
|
||||
sys.stderr.write('Error: The %s cannot be found. '
|
||||
'Did you install Sphinx and its dependencies '
|
||||
'correctly?' % whichmod)
|
||||
'correctly?\n' % whichmod)
|
||||
if hint:
|
||||
print >> sys.stderr, hint
|
||||
sys.stderr.write(hint)
|
||||
return 1
|
||||
raise
|
||||
return cmdline.main(argv)
|
||||
|
Loading…
Reference in New Issue
Block a user