Skip to content

Commit

Permalink
Update version number to be PEP 440 compliant (#18)
Browse files Browse the repository at this point in the history
* Make version # PEP 440 compliant

* Fix version CLI test
  • Loading branch information
liamtoney authored Jan 30, 2024
1 parent 9374c63 commit 4101e31
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 15 deletions.
1 change: 0 additions & 1 deletion .environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ dependencies:
- ffmpeg
- obspy
- pip
- setuptools<58.4.0 # https://github.com/pypa/setuptools/issues/2497
- tqdm
- pip:
- --editable .
27 changes: 15 additions & 12 deletions sonify/__init__.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])

0 comments on commit 4101e31

Please sign in to comment.