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.
|
: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
|
import sys
|
||||||
from os import path
|
from os import path
|
||||||
|
|
||||||
@ -35,13 +38,14 @@ if '+' in __version__ or 'pre' in __version__:
|
|||||||
|
|
||||||
def main(argv=sys.argv):
|
def main(argv=sys.argv):
|
||||||
if sys.version_info[:3] < (2, 4, 0):
|
if sys.version_info[:3] < (2, 4, 0):
|
||||||
print >>sys.stderr, \
|
sys.stderr.write('Error: Sphinx requires at least '
|
||||||
'Error: Sphinx requires at least Python 2.4 to run.'
|
'Python 2.4 to run.\n')
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from sphinx import cmdline
|
from sphinx import cmdline
|
||||||
except ImportError, err:
|
except ImportError:
|
||||||
|
err = sys.exc_info()[1]
|
||||||
errstr = str(err)
|
errstr = str(err)
|
||||||
if errstr.lower().startswith('no module named'):
|
if errstr.lower().startswith('no module named'):
|
||||||
whichmod = errstr[16:]
|
whichmod = errstr[16:]
|
||||||
@ -54,14 +58,14 @@ def main(argv=sys.argv):
|
|||||||
whichmod = 'roman module (which is distributed with Docutils)'
|
whichmod = 'roman module (which is distributed with Docutils)'
|
||||||
hint = ('This can happen if you upgraded docutils using\n'
|
hint = ('This can happen if you upgraded docutils using\n'
|
||||||
'easy_install without uninstalling the old version'
|
'easy_install without uninstalling the old version'
|
||||||
'first.')
|
'first.\n')
|
||||||
else:
|
else:
|
||||||
whichmod += ' module'
|
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 '
|
'Did you install Sphinx and its dependencies '
|
||||||
'correctly?' % whichmod)
|
'correctly?\n' % whichmod)
|
||||||
if hint:
|
if hint:
|
||||||
print >> sys.stderr, hint
|
sys.stderr.write(hint)
|
||||||
return 1
|
return 1
|
||||||
raise
|
raise
|
||||||
return cmdline.main(argv)
|
return cmdline.main(argv)
|
||||||
|
Loading…
Reference in New Issue
Block a user