__version__ = "N/A"
__release_commit__ = "$Format:%H$"
__full_version__ = None
if __release_commit__[1:-1] == "Format:%H":
    try:
        import subprocess

        try:
            devnull = subprocess.DEVNULL
        except AttributeError:
            devnull = None  # Not supported, but not critical

        __version__ = (
            subprocess.check_output(
                ["git", "describe", "--tags"],
                stderr=devnull,
            )
            .strip()
            .decode("utf-8")
        )
        __release_commit__ = (
            subprocess.check_output(["git", "log", "--pretty=format:%H", "-n", "1"])
            .strip()
            .decode("utf-8")
        )
    except (subprocess.CalledProcessError, FileNotFoundError):
        __version__ = "N/A"
        __release_commit__ = "N/A"

if __version__.startswith("debian/"):
    __version__ = __version__[7:]

if __release_commit__ != "N/A":
    __full_version__ = "%s (commit: %s)" % (__version__, __release_commit__)
else:
    __full_version__ = __version__
