Skip to content

Commit

Permalink
added version code in setup
Browse files Browse the repository at this point in the history
  • Loading branch information
deepak7376 committed Jul 6, 2024
1 parent e56ef5c commit 9ab68d5
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions setup.py
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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='[email protected]',
Expand Down

0 comments on commit 9ab68d5

Please sign in to comment.