def get_git_describe():
    if not os.path.exists(os.path.join(os.path.dirname(__file__), ".git")):
        raise CantInvokeGit("Not a git build")

    try:
        po = subprocess.Popen(
            ("git", "describe", "--tags", "--long", "--always"),
            stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    except OSError as e:
        raise CantInvokeGit(e)

    stdout, stderr = po.communicate()
    if po.returncode != 0:
        raise CantInvokeGit("Couldn't invoke git describe", stderr)

    return stdout.decode('utf-8').rstrip()
dataset/ETHPy150Open couchbase/couchbase-python-client/couchbase_version.py/get_git_describe/original