From 9ab68d52c7ad1331926a828067f5eb7167c2bf3b Mon Sep 17 00:00:00 2001 From: DeepakYadav <41716815+deepak7376@users.noreply.github.com> Date: Sat, 6 Jul 2024 13:59:51 +0000 Subject: [PATCH] added version code in setup --- setup.py | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/setup.py b/setup.py index 85d66f5..d3e4862 100644 --- a/setup.py +++ b/setup.py @@ -1,21 +1,22 @@ -# setup.py from setuptools import setup, find_packages import subprocess import os -# Get the version from git tags -version = ( - subprocess.run(["git", "describe", "--tags"], stdout=subprocess.PIPE) - .stdout.decode("utf-8") - .strip() -) - -if "-" in version: - v, i, s = version.split("-") - version = v + "+" + i + ".git." + s +def get_git_version(): + try: + version = subprocess.run(["git", "describe", "--tags"], stdout=subprocess.PIPE, check=True).stdout.decode("utf-8").strip() + if "-" in version: + v, i, s = version.split("-") + version = v + "+" + i + ".git." + s + assert "-" not in version + assert "." in version + return version + except subprocess.CalledProcessError: + # Handle the case where there are no tags or the directory is not a Git repository + return "0.0.0" -assert "-" not in version -assert "." in version +# Get the version from git tags or set a default +version = get_git_version() # Write the version to a file with open("VERSION", "w", encoding="utf-8") as fh: @@ -29,7 +30,7 @@ name='wsn_sim', version=version, description='Wireless Sensor Network Simulator with AODV and DSR protocols', - long_description=long_description, + long_description=long_description, long_description_content_type='text/markdown', author='Deepak Yadav', author_email='dky.united@gmail.com',