diff --git a/mrhlpr/frontend.py b/mrhlpr/frontend.py index 95620084571ad3c3c607bebe63f802671cb7bd32..d34298b1f0f96c3bbdbd263675ab9cfbac72d5dc 100644 --- a/mrhlpr/frontend.py +++ b/mrhlpr/frontend.py @@ -16,6 +16,7 @@ from . import ci_labels # type: ignore[attr-defined] from . import git from . import gitlab from . import mr +from . import version def print_status(mr_id: int, no_cache: bool = False) -> None: @@ -178,6 +179,9 @@ def parse_args() -> argparse.Namespace: action="store_true", help="display debug log: all git commands and" " locations of http cache files", ) + parser.add_argument( + "-V", "--version", action="version", version=version.get_full_version_information() + ) sub = parser.add_subparsers(title="action", dest="action") sub.required = True diff --git a/mrhlpr/version.py b/mrhlpr/version.py new file mode 100644 index 0000000000000000000000000000000000000000..009db8311b9cb4185d5540896d8657f6cb36ccc8 --- /dev/null +++ b/mrhlpr/version.py @@ -0,0 +1,14 @@ +from typing import Final + +VERSION: Final[str] = "1.5.0" + + +def get_full_version_information() -> str: + """Provides a full version string, including an educated guess about whether the program was + compiled by mypyc.""" + return f"{VERSION} (compiled: {'yes' if is_mypyc_compiled() else 'no'})" + + +def is_mypyc_compiled() -> bool: + """Attempts to determine whether the program was compiled by mypyc.""" + return not __file__.endswith(".py") diff --git a/mrtest/frontend.py b/mrtest/frontend.py index c5b748cbcbde1218a5034b25930d818c84b7ed80..7a2b434c8db526f90ae7db199ad1a840e19fb4b7 100644 --- a/mrtest/frontend.py +++ b/mrtest/frontend.py @@ -6,6 +6,7 @@ import argparse import logging import sys +import mrhlpr.version import mrtest.add_packages import mrtest.origin import mrtest.upgrade_packages @@ -57,6 +58,9 @@ def parse_args() -> argparse.Namespace: action="store_true", help="display debug log: all commands and locations of" " http cache files", ) + parser.add_argument( + "-V", "--version", action="version", version=mrhlpr.version.get_full_version_information() + ) sub = parser.add_subparsers(title="action", dest="action") sub.required = True diff --git a/pyproject.toml b/pyproject.toml index a5e631cbd86810699d9399fcf0a1124008bfa2fc..737c55864d08768e489a9691e0c411723c99225e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "mrhlpr" -version = "1.5.0" +dynamic = ["version"] authors = [ {name = "postmarketOS Developers", email="info@postmarketos.org"} ] @@ -35,6 +35,9 @@ api = ["python-gitlab>=4.0.0"] [project.urls] Homepage = "https://www.postmarketos.org" +[tool.setuptools.dynamic] +version = {attr = "mrhlpr.version.VERSION"} + [tool.setuptools.packages.find] include = ["mrhlpr*", "mrtest*"]