Skip to content

Commit

Permalink
Use setuptools_scm to get a valid version string
Browse files Browse the repository at this point in the history
  • Loading branch information
jgoeders committed Oct 25, 2023
1 parent 2bf4441 commit e93333e
Showing 1 changed file with 8 additions and 25 deletions.
33 changes: 8 additions & 25 deletions spydrnet/release.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down

0 comments on commit e93333e

Please sign in to comment.