diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 816d5fc..648a09c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -41,4 +41,5 @@ jobs: echo Test source .venv/bin/activate coverage run -m unittest || exit 1 + coverage report [ -n "$CODACY_PROJECT_TOKEN" ] && coverage combine && coverage xml -o cobertura.xml && bash <(curl -Ls https://coverage.codacy.com/get.sh) report -r cobertura.xml diff --git a/poetry.lock b/poetry.lock index 53c65fc..39da348 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1103,6 +1103,17 @@ category = "main" optional = false python-versions = "*" +[[package]] +name = "single-source" +version = "0.3.0" +description = "Access to the project version in Python code for PEP 621-style projects" +category = "main" +optional = false +python-versions = ">=3.6,<4.0" + +[package.dependencies] +importlib_metadata = {version = ">=3.0,<5", markers = "python_version < \"3.8\""} + [[package]] name = "six" version = "1.16.0" @@ -1247,7 +1258,7 @@ testing = ["pytest (>=6)", "pytest-checkdocs (>=2.4)", "pytest-flake8", "pytest- [metadata] lock-version = "1.1" python-versions = ">=3.7.0, <4.0.0" -content-hash = "3e21b3d9a8d196a0e896b4dec41624bf71cc8967fbd42f094afe871639d3f748" +content-hash = "237337e04594d877cea819e9ff6b56d18fa1c4583396f1ec3eca53d98378add7" [metadata.files] androguard = [ @@ -2196,6 +2207,10 @@ setuptools-scm = [ simplegeneric = [ {file = "simplegeneric-0.8.1.zip", hash = "sha256:dc972e06094b9af5b855b3df4a646395e43d1c9d0d39ed345b7393560d0b9173"}, ] +single-source = [ + {file = "single-source-0.3.0.tar.gz", hash = "sha256:b12705af958ca99d56ea9ce40bd9cc749378f4fe7ad03b1f9067e29daceef27d"}, + {file = "single_source-0.3.0-py3-none-any.whl", hash = "sha256:7bc87168ced50f638b6ab0cda4cc1ce9e80ee0e1220014397050d336d021a597"}, +] six = [ {file = "six-1.16.0-py2.py3-none-any.whl", hash = "sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254"}, {file = "six-1.16.0.tar.gz", hash = "sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926"}, diff --git a/psa_car_controller/__init__.py b/psa_car_controller/__init__.py index e69de29..51e090d 100644 --- a/psa_car_controller/__init__.py +++ b/psa_car_controller/__init__.py @@ -0,0 +1,4 @@ +from pathlib import Path +from single_source import get_version + +__version__ = get_version(__name__, Path(__file__), default_return="dev") diff --git a/psa_car_controller/psacc/application/car_controller.py b/psa_car_controller/psacc/application/car_controller.py index 0d2978a..f17191f 100644 --- a/psa_car_controller/psacc/application/car_controller.py +++ b/psa_car_controller/psacc/application/car_controller.py @@ -4,6 +4,7 @@ import logging import threading from os import environ, path +import psa_car_controller from oauth2_client.credentials_manager import OAuthError from .charge_control import ChargeControls @@ -36,6 +37,8 @@ def parse_args(): parser.add_argument("--offline", help="offline limited mode", action='store_true') parser.add_argument("--web-conf", help="ignore if config files not existing yet", action='store_true') parser.add_argument("-b", "--base-path", help="base path for web app", default="/") + parser.add_argument('--version', action='version', version='PSACC {}'.format(psa_car_controller.__version__)) + return parser.parse_args() diff --git a/pyproject.toml b/pyproject.toml index 4c53810..fe04c17 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -36,6 +36,7 @@ certifi = ">=14.05.14" six = ">=1.10" python-dateutil = ">=2.5.3" urllib3 = ">=1.15.1" +single-source = "^0.3.0" [tool.poetry.dev-dependencies] prospector = ">=1.3.0"