Skip to content
This repository was archived by the owner on Aug 2, 2022. It is now read-only.

Commit f7ad8a6

Browse files
committed
Improved version search for package setup.
1 parent cac0b9f commit f7ad8a6

File tree

1 file changed

+9
-15
lines changed

1 file changed

+9
-15
lines changed

setup.py

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,27 +22,21 @@ def read(*paths):
2222
return fid.read()
2323

2424

25-
def get_version():
25+
def get_version(path):
2626
"""Get the module version."""
2727

28-
with open('biosppy/version.py', 'r') as fid:
29-
txt = fid.read()
28+
with open(path, 'r') as fid:
29+
m = re.search("version\s*=\s*'([\w.]+)'", fid.read())
30+
if m is None:
31+
raise RuntimeError("Could not find version string.")
32+
version = m.group(1)
33+
version = version.strip()
3034

31-
m = re.search("version\s*=\s*'([\w.]+)'", txt)
32-
33-
if m:
34-
try:
35-
ver = m.group(1)
36-
except IndexError:
37-
raise Exception("Could not parse version string.")
38-
39-
ver = ver.strip()
40-
41-
return ver
35+
return version
4236

4337

4438
setup(name='biosppy',
45-
version=get_version(),
39+
version=get_version('biosppy/version.py'),
4640
description="A toolbox for biosignal processing written in Python.",
4741
long_description=read('README.rst'),
4842
url='https://github.com/PIA-Group/BioSPPy',

0 commit comments

Comments
 (0)