Skip to content

Commit

Permalink
.version file as default method
Browse files Browse the repository at this point in the history
  • Loading branch information
DrYak committed Jul 22, 2020
1 parent 1373bc5 commit 62b3464
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/shorah/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,18 @@

all_dirs = os.path.abspath(__file__).split(os.sep)
base_dir = os.sep.join(all_dirs[:-all_dirs[::-1].index('shorah')])

try:
from pkg_resources import get_distribution #(get_distribution, DistributionNotFound)
__version__ = get_distribution('shorah').version
except: #DistributionNotFound:
# probably installed using Autotools
with open(os.path.join(base_dir, '.version'), 'r') as version_file:
version_fname = os.path.join(base_dir, '.version')
if os.path.exists(version_fname):
# probably installed using Autotools, e.g: bioconda package - the current recommended way
with open(version_fname, 'r') as version_file:
__version__ = version_file.read()
else:
# probably installed using setup.py
from pkg_resources import (get_distribution, DistributionNotFound)
try:
__version__ = get_distribution('shorah').version
except DistributionNotFound:
print("your message", file=sys.stderr)

# manipulate path to import functions
parent_dir = os.path.join(base_dir, 'src')
Expand Down

0 comments on commit 62b3464

Please sign in to comment.