From 4101e313cb34da1e85114c7e5ec233b9c1730bc0 Mon Sep 17 00:00:00 2001 From: Liam Toney Date: Tue, 30 Jan 2024 11:08:16 -0700 Subject: [PATCH] Update version number to be PEP 440 compliant (#18) * Make version # PEP 440 compliant * Fix version CLI test --- .environment.yml | 1 - environment.yml | 1 - sonify/__init__.py | 27 +++++++++++++++------------ tests/test_cli.py | 2 +- 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/.environment.yml b/.environment.yml index 346563b..0ab91b3 100644 --- a/.environment.yml +++ b/.environment.yml @@ -6,7 +6,6 @@ dependencies: - ffmpeg - obspy - pip - - setuptools<58.4.0 # https://github.com/pypa/setuptools/issues/2497 - tqdm # Lines above should be IDENTICAL to environment.yml - black diff --git a/environment.yml b/environment.yml index f84e6ba..2fc1eed 100644 --- a/environment.yml +++ b/environment.yml @@ -6,7 +6,6 @@ dependencies: - ffmpeg - obspy - pip - - setuptools<58.4.0 # https://github.com/pypa/setuptools/issues/2497 - tqdm - pip: - --editable . diff --git a/sonify/__init__.py b/sonify/__init__.py index 7ed9a5e..6c9a8dc 100644 --- a/sonify/__init__.py +++ b/sonify/__init__.py @@ -1,18 +1,21 @@ import subprocess from pathlib import Path -__version__ = subprocess.run( - [ - 'git', - '-C', - Path(__file__).resolve().parent, - 'rev-parse', - '--short=7', - 'HEAD', - ], - capture_output=True, - text=True, -).stdout.strip() +__version__ = ( + '0+g' # Makes the version number PEP 440 compliant + + subprocess.run( + [ + 'git', + '-C', + Path(__file__).resolve().parent, + 'rev-parse', + '--short=7', # First 7 characters of the commit hash + 'HEAD', + ], + capture_output=True, + text=True, + ).stdout.strip() +) del subprocess del Path diff --git a/tests/test_cli.py b/tests/test_cli.py index 4bf73c6..a8b3b96 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -15,4 +15,4 @@ def test_cli_version(): output = subprocess.run( ['sonify', '--version'], capture_output=True, text=True ).stdout.strip() - assert output == 'sonify, rev. {}'.format(os.environ['GITHUB_SHA'][:7]) + assert output == 'sonify, rev. 0+g{}'.format(os.environ['GITHUB_SHA'][:7])