sphinx/sphinx/__init__.py

64 lines
2.1 KiB
Python
Raw Normal View History

2007-07-23 04:02:25 -05:00
"""
Sphinx
~~~~~~
2008-01-16 14:27:25 -06:00
The Sphinx documentation toolchain.
2007-07-23 04:02:25 -05:00
2019-01-02 01:00:30 -06:00
:copyright: Copyright 2007-2019 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.)
import os
import subprocess
import warnings
from os import path
from subprocess import PIPE
2007-07-23 04:02:25 -05:00
from .deprecation import RemovedInNextVersionWarning
2017-03-02 21:19:09 -06:00
2018-01-22 07:05:38 -06:00
if False:
# For type annotation
from typing import Any # NOQA
# 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)
# docutils.io using mode='rU' for open
warnings.filterwarnings('ignore', "'U' mode is deprecated",
DeprecationWarning, module='docutils.io')
2019-04-08 10:12:06 -05:00
__version__ = '2.0.1'
2019-03-28 10:22:15 -05:00
__released__ = '2.0.1' # 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__``.
2019-04-08 10:12:06 -05:00
version_info = (2, 0, 1, 'final', 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:
ret = subprocess.run(['git', 'show', '-s', '--pretty=format:%h'],
stdout=PIPE, stderr=PIPE, encoding='ascii')
if ret.stdout:
__display_version__ += '/' + ret.stdout.strip()
except Exception:
pass