def get_version(name, version_length=2, placeholder="x"):
    """Ensures that the named package is installed and returns version
    strings to be used by Sphinx.

    Sphinx uses ``version`` to mean an abbreviated form of the full
    version string, which is called ``release``. In ``conf.py``::

        release, version = get_version("Flask")
        # release = 1.0.x, version = 1.0.3.dev0

    :param name: Name of package to get.
    :param version_length: How many values from ``release`` to use for
        ``version``.
    :param placeholder: Extra suffix to add to the version. The default
        produces versions like ``1.2.x``.
    :return: ``(release, version)`` tuple.
    """
    try:
        release = pkg_resources.get_distribution(name).version
    except ImportError:
        print(
            textwrap.fill(
                "'{name}' must be installed to build the documentation."
                " Install from source using `pip install -e .` in a"
                " virtualenv.".format(name=name)
            )
        )
        sys.exit(1)

    version = ".".join(release.split(".", version_length)[:version_length])

    if placeholder:
        version = "{}.{}".format(version, placeholder)

    return release, version
def get_version ( name , version_length = 2 , placeholder = "x" ) : try : release = pkg_resources . get_distribution ( name ) . version except ImportError : print ( textwrap . fill ( "'{name}' must be installed to build the documentation." " Install from source using `pip install -e .` in a" " virtualenv." . format ( name = name ) ) ) sys . exit ( 1 ) version = "." . join ( release . split ( "." , version_length ) [ : version_length ] ) if placeholder : version = "{}.{}" . format ( version , placeholder ) return release , version
Ensures that the named package is installed and returns version
    strings to be used by Sphinx.

    Sphinx uses ``version`` to mean an abbreviated form of the full
    version string, which is called ``release``. In ``conf.py``::

        release, version = get_version("Flask")
        # release = 1.0.x, version = 1.0.3.dev0

    :param name: Name of package to get.
    :param version_length: How many values from ``release`` to use for
        ``version``.
    :param placeholder: Extra suffix to add to the version. The default
        produces versions like ``1.2.x``.
    :return: ``(release, version)`` tuple.