2018-01-04 16:16:06 +01:00
|
|
|
# !/usr/bin/env python
|
|
|
|
#
|
|
|
|
# A library that provides a Python interface to the Telegram Bot API
|
2024-02-19 20:06:25 +01:00
|
|
|
# Copyright (C) 2015-2024
|
2018-01-04 16:16:06 +01:00
|
|
|
# Leandro Toledo de Souza <devs@python-telegram-bot.org>
|
|
|
|
#
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU Lesser Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU Lesser Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU Lesser Public License
|
|
|
|
# along with this program. If not, see [http://www.gnu.org/licenses/].
|
2021-10-08 08:17:00 +02:00
|
|
|
# pylint: disable=missing-module-docstring
|
2019-02-18 20:04:52 +01:00
|
|
|
import subprocess
|
2020-10-31 16:33:34 +01:00
|
|
|
import sys
|
|
|
|
from typing import Optional
|
2016-07-09 13:40:53 +02:00
|
|
|
|
|
|
|
from . import __version__ as telegram_ver
|
2021-03-14 16:41:35 +01:00
|
|
|
from .constants import BOT_API_VERSION
|
2016-07-09 13:40:53 +02:00
|
|
|
|
|
|
|
|
2020-10-06 19:28:40 +02:00
|
|
|
def _git_revision() -> Optional[str]:
|
2019-02-18 20:04:52 +01:00
|
|
|
try:
|
2024-02-07 20:45:57 +01:00
|
|
|
output = subprocess.check_output(
|
2019-02-18 20:04:52 +01:00
|
|
|
["git", "describe", "--long", "--tags"], stderr=subprocess.STDOUT
|
|
|
|
)
|
|
|
|
except (subprocess.SubprocessError, OSError):
|
|
|
|
return None
|
|
|
|
return output.decode().strip()
|
|
|
|
|
|
|
|
|
2024-02-07 20:45:57 +01:00
|
|
|
def print_ver_info() -> None:
|
2023-02-02 18:55:07 +01:00
|
|
|
"""Prints version information for python-telegram-bot, the Bot API and Python."""
|
2019-02-18 20:04:52 +01:00
|
|
|
git_revision = _git_revision()
|
2020-11-23 22:09:29 +01:00
|
|
|
print(f"python-telegram-bot {telegram_ver}" + (f" ({git_revision})" if git_revision else ""))
|
2021-03-14 16:41:35 +01:00
|
|
|
print(f"Bot API {BOT_API_VERSION}")
|
2020-11-23 22:09:29 +01:00
|
|
|
sys_version = sys.version.replace("\n", " ")
|
|
|
|
print(f"Python {sys_version}")
|
2016-07-09 13:40:53 +02:00
|
|
|
|
2016-12-11 22:44:52 +01:00
|
|
|
|
2024-02-07 20:45:57 +01:00
|
|
|
def main() -> None:
|
2023-02-02 18:55:07 +01:00
|
|
|
"""Prints version information for python-telegram-bot, the Bot API and Python."""
|
2016-12-11 22:44:52 +01:00
|
|
|
print_ver_info()
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|