From e93333e6f6994ab64758b7505efb591f0f7fc59c Mon Sep 17 00:00:00 2001 From: Jeff Goeders Date: Wed, 25 Oct 2023 14:41:09 -0600 Subject: [PATCH] Use setuptools_scm to get a valid version string --- spydrnet/release.py | 33 ++++++++------------------------- 1 file changed, 8 insertions(+), 25 deletions(-) diff --git a/spydrnet/release.py b/spydrnet/release.py index c2919354..52a5803b 100644 --- a/spydrnet/release.py +++ b/spydrnet/release.py @@ -94,7 +94,7 @@ def _get_second_period_index(string_value): def update_versionfile(): import datetime import time - import subprocess + import setuptools_scm global version global date @@ -104,30 +104,13 @@ def update_versionfile(): ) date = time.asctime(date_info.timetuple()) - # check for git on path - git_exists = False - for path in os.environ["PATH"].split(os.pathsep): - exe_file = Path(path, "git") - if Path(exe_file).is_file() and os.access(exe_file, os.X_OK): - git_exists = True - else: - exe_file = Path(path, "git.exe") - if Path(exe_file).is_file() and os.access(exe_file, os.X_OK): - git_exists = True - - if git_exists: - git_subprocess = subprocess.Popen( - "git describe", shell=True, cwd=directory, stdout=subprocess.PIPE - ) - git_describe_output = git_subprocess.stdout.read().decode() - - git_version = git_describe_output.strip() - if git_version.startswith("v"): - version_file = Path(directory, "VERSION") - with open(version_file, "w") as fh: - fh.write(git_version + "\n") - fh.write(date + "\n") - version = git_version[1:] + git_version = setuptools_scm.get_version() + + version_file = Path(directory, "VERSION") + with open(version_file, "w") as fh: + fh.write(git_version + "\n") + fh.write(date + "\n") + version = git_version return version