Skip to content
Snippets Groups Projects
Verified Commit 31a169a2 authored by Newbyte's avatar Newbyte :snowflake:
Browse files

mrhlpr, mrtest: Add --version command

This also effectively reverts 7d068e20,
because now we actually use the version for something in the program. It
also avoids the problems reported in
postmarketOS/mrhlpr#15 to the
best of my knowledge — I tried reproducing the bug as written in there
and did not get any build failures.

The primary purpose of this version command is for making
experimentation with mypyc easier, but I also can imagine it might be
nice for users to be able to get their version of mrtest easily.
parent b067a9ff
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
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")
......@@ -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
......
......@@ -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*"]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment