Skip to content

Commit

Permalink
Another iteration on __init__.py
Browse files Browse the repository at this point in the history
  • Loading branch information
taldcroft committed Mar 8, 2019
1 parent 4baa69d commit 6b5748b
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions Ska/engarchive/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,26 @@
from pkg_resources import get_distribution, DistributionNotFound

try:
# Normally use the generic __name__ here, but for the dual Ska.engarchive
# and cheta install, hardwire to 'Ska.engarchive' which is the package name.
__version__ = get_distribution('Ska.engarchive').version
except DistributionNotFound:
# package is not installed
pass
_dist = get_distribution('Ska.engarchive') # hard-code only for this dual-name package
__version__ = _dist.version
assert __file__.startswith(_dist.location)

except (AssertionError, DistributionNotFound):
try:
# get_distribution found a different package from this file, must be in source repo
from setuptools_scm import get_version
from pathlib import Path

root = Path('..')
try:
__version__ = get_version(root=root, relative_to=__file__)
except LookupError:
__version__ = get_version(root=root / '..', relative_to=__file__)

except Exception:
import warnings
warnings.warn('Failed to find a package version, setting to 0.0.0')
__version__ = '0.0.0'


def test(*args, **kwargs):
Expand Down

0 comments on commit 6b5748b

Please sign in to comment.