sphinx/sphinx/__init__.py

84 lines
2.7 KiB
Python
Raw Normal View History

2007-07-23 04:02:25 -05:00
# -*- coding: utf-8 -*-
"""
Sphinx
~~~~~~
2008-01-16 14:27:25 -06:00
The Sphinx documentation toolchain.
2007-07-23 04:02:25 -05:00
2017-12-31 10:06:58 -06:00
:copyright: Copyright 2007-2018 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
2007-07-23 04:02:25 -05:00
"""
# Keep this file executable as-is in Python 3!
# (Otherwise getting the version out of it from setup.py is impossible.)
from __future__ import absolute_import
import os
import warnings
from os import path
2007-07-23 04:02:25 -05:00
from .cmd import build
from .deprecation import RemovedInNextVersionWarning
from .deprecation import RemovedInSphinx20Warning
2017-03-02 21:19:09 -06:00
# by default, all DeprecationWarning under sphinx package will be emit.
# Users can avoid this by using environment variable: PYTHONWARNINGS=
if 'PYTHONWARNINGS' not in os.environ:
warnings.filterwarnings('default',
category=RemovedInNextVersionWarning, module='sphinx')
# docutils.io using mode='rU' for open
warnings.filterwarnings('ignore', "'U' mode is deprecated",
DeprecationWarning, module='docutils.io')
2018-01-20 04:48:11 -06:00
__version__ = '1.8.0+'
__released__ = '1.8.0' # used when Sphinx builds its own docs
#: Version info for better programmatic use.
#:
#: A tuple of five elements; for Sphinx version 1.2.1 beta 3 this would be
#: ``(1, 2, 1, 'beta', 3)``. The fourth element can be one of: ``alpha``,
#: ``beta``, ``rc``, ``final``. ``final`` always has 0 as the last element.
#:
#: .. versionadded:: 1.2
#: Before version 1.2, check the string ``sphinx.__version__``.
2018-01-20 04:48:11 -06:00
version_info = (1, 8, 0, 'beta', 0)
package_dir = path.abspath(path.dirname(__file__))
__display_version__ = __version__ # used for command line version
if __version__.endswith('+'):
# try to find out the commit hash if checked out from git, and append
# it to __version__ (since we use this value from setup.py, it gets
# automatically propagated to an installed copy as well)
__display_version__ = __version__
__version__ = __version__[:-1] # remove '+' for PEP-440 version spec.
try:
import subprocess
p = subprocess.Popen(['git', 'show', '-s', '--pretty=format:%h',
path.join(package_dir, '..')],
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err = p.communicate()
if out:
2017-05-07 00:09:54 -05:00
__display_version__ += '/' + out.decode().strip()
except Exception:
pass
def main(*args, **kwargs):
warnings.warn(
'`sphinx.main()` has moved to `sphinx.cmd.build.main()`.',
RemovedInSphinx20Warning,
stacklevel=2,
)
return build.main(*args, **kwargs)
2007-07-23 04:02:25 -05:00
if __name__ == '__main__':
warnings.warn(
'`sphinx` has moved to `sphinx.build`.',
RemovedInSphinx20Warning,
stacklevel=2,
)
build.main()