Skip to content

Commit

Permalink
added version.py (#7)
Browse files Browse the repository at this point in the history
* Updated README.md

* Add pytest tests and GitHub Actions workflow

* Add pytest tests and GitHub Actions workflow

* Add pytest tests and GitHub Actions workflow

* Added the Check version Capability

* added version.py
  • Loading branch information
muhammad-fiaz authored Dec 7, 2023
1 parent 044f37b commit 2c8b96f
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 1 deletion.
41 changes: 41 additions & 0 deletions checkversions/version.py
Original file line number Diff line number Diff line change
@@ -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

7 changes: 6 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -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:
Expand Down

0 comments on commit 2c8b96f

Please sign in to comment.