diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..7fbdfb0 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1 @@ +include Pipfile diff --git a/app.sh b/app.sh index 8a0fa6e..84971fb 100755 --- a/app.sh +++ b/app.sh @@ -4,4 +4,4 @@ # command and debug level # -exec python producer.py +exec packages-releases-job diff --git a/producer.py b/producer.py index df5519b..3415726 100644 --- a/producer.py +++ b/producer.py @@ -20,28 +20,19 @@ import logging import asyncio import random -from typing import List - import os -import click as cli +from typing import List -from version import __version__ +from importlib.metadata import version +from prometheus_client import CollectorRegistry, Gauge, Counter, push_to_gateway +import click as cli -from thoth.common import __version__ as __common__version__ from thoth.common import init_logging - -from thoth.storages import __version__ as __storages__version__ from thoth.storages import GraphDatabase - -from thoth.messaging import __version__ as __messaging__version__ import thoth.messaging.producer as producer from thoth.messaging import package_released_message from thoth.messaging.package_releases import MessageContents as PackageReleasedContent - -from prometheus_client import CollectorRegistry, Gauge, Counter, push_to_gateway - -from thoth.python import __version__ as __python__version__ from thoth.python import Source from thoth.python import AIOSource from thoth.python.exceptions import NotFoundError @@ -53,7 +44,14 @@ p = producer.create_producer() _LOGGER = logging.getLogger("thoth.package_releases_job") -__service_version__ = f"{__version__}+storages.{__storages__version__}.common.{__common__version__}.messaging.{__messaging__version__}.python.{__python__version__}" # noqa: E501 +__version__: str = "0.11.11" + +__service_version__ = ( + f"{__version__}+" + + ".".join(version(f"thoth-{p}") for p in ["storages", "common", "messaging"]) + + f".python.{version('thoth-python')}" +) + _LOGGER.info("Thoth-package-releases-job-producer v%s", __service_version__) _THOTH_DEPLOYMENT_NAME = os.environ["THOTH_DEPLOYMENT_NAME"] @@ -307,7 +305,3 @@ def main( ) except Exception as e: _LOGGER.exception(f"An error occurred pushing the metrics: {str(e)}") - - -if __name__ == "__main__": - main() diff --git a/pyproject.toml b/pyproject.toml index a5c5a22..6a6bb76 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,13 +4,18 @@ description = "Check packages updates on Python package indexes" readme = "README.rst" requires-python = ">=3.8" license = {file = "LICENSE"} -version = "v0.11.10" +dynamic = ["version", "dependencies"] [project.scripts] package-releases-job = "producer:main" [build-system] -requires = ["setuptools", "wheel"] +requires = ["setuptools", "wheel", "setuptools-pipfile"] + +[tool.setuptools.dynamic] +version = {attr = "producer.__version__"} + +[tool.setuptools-pipfile] [tool.black] line-length = 120 diff --git a/version.py b/version.py deleted file mode 100644 index f8d49f7..0000000 --- a/version.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python3 -# Package Releases Job -# Copyright(C) 2020 Red Hat, Inc. -# -# This program is free software: you can redistribute it and / or modify -# it under the terms of the GNU General 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 General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -"""This file carries the version of the package releases job.""" - -__version__ = "0.11.11"