diff --git a/checkversions/version.py b/checkversions/version.py new file mode 100644 index 0000000..480c4a4 --- /dev/null +++ b/checkversions/version.py @@ -0,0 +1,41 @@ + +# version.py + +import importlib.metadata + +def get_latest_release_version(package_name): + """ + Get the latest released version of a Python package. + + Args: + package_name (str): The name of the Python package. + + Returns: + str: The latest released version or '0.0.0' if not found. + + """ + try: + distribution = importlib.metadata.distribution(package_name) + return distribution.version + except importlib.metadata.PackageNotFoundError: + return '0.0.0' + +def get_Version(current_version): + """ + Check if there is a newer version of the package available. + + Args: + current_version (str): The current version of the package. + + Returns: + None: Prints a message indicating if a newer version is available. + + """ + package_name = 'checkversions' + latest_version = get_latest_release_version(package_name) + + if latest_version > current_version: + print(f"A newer version ({latest_version}) of checkversions is available.") + else: + pass + diff --git a/setup.py b/setup.py index 332ce74..47235d5 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,11 @@ from setuptools import setup, find_packages -VERSION = '0.0.1' +from checkversions.version import get_Version + +VERSION = "0.0.1" + +get_Version(VERSION) + DESCRIPTION = 'CheckVersions is a powerful and intuitive version comparison tool for software development.' with open("README.md", "r", encoding="utf-8") as fh: