Skip to content

Commit

Permalink
Improved version retrieval in setup.py
Browse files Browse the repository at this point in the history
  • Loading branch information
jrwdunham committed Nov 10, 2017
1 parent 74ee0cc commit cd8113c
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,31 @@
from codecs import open
from os import path

from metsrw import __version__

here = path.abspath(path.dirname(__file__))

HERE = path.abspath(path.dirname(__file__))

# Get the long description from the relevant file
with open(path.join(here, 'README.md'), encoding='utf-8') as f:
with open(path.join(HERE, 'README.md'), encoding='utf-8') as f:
long_description = f.read()


def get_version():
version = '0.1.0'
with open(path.join(HERE, 'metsrw', '__init__.py')) as fi:
for line in fi:
if line.startswith('__version__'):
parts = line.strip().split()
try:
version = parts[2].replace("'", '').replace('"', '').strip()
except (IndexError, AttributeError):
continue
return version


setup(
name='metsrw',
version=__version__,
version=get_version(),

description='Library for dealing with METS files.',
long_description=long_description,
Expand Down

0 comments on commit cd8113c

Please sign in to comment.