Skip to content

Commit 95ccd5c

Browse files
committed
Added __version__ attr, read from setup.py
1 parent 3bc41f5 commit 95ccd5c

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ def readme():
88

99
configuration = {
1010
"name": "stumpy",
11-
"version": "1.0",
11+
"version": "1.0.0",
1212
"python_requires=": ">=3.5",
1313
"author": "Sean M. Law",
1414
"author_email": "seanmylaw@gmail.com",

stumpy/__init__.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,19 @@
1717
)
1818
from .mstumped import mstumped # noqa: F401
1919
from .chains import atsc, allc # noqa: F401
20+
21+
from pkg_resources import get_distribution, DistributionNotFound
22+
import os.path
23+
24+
try:
25+
_dist = get_distribution("stumpy")
26+
# Normalize case for Windows systems
27+
dist_loc = os.path.normcase(_dist.location)
28+
here = os.path.normcase(__file__)
29+
if not here.startswith(os.path.join(dist_loc, "stumpy")):
30+
# not installed, but there is another version that *is*
31+
raise DistributionNotFound
32+
except DistributionNotFound:
33+
__version__ = "Please install this project with setup.py"
34+
else:
35+
__version__ = _dist.version

0 commit comments

Comments
 (0)