Skip to content

Commit 1d03382

Browse files
committed
chg: adopt now-standard __version__ type
This follows the modern convention that module.__version__ be a string. For convenience, we will expose a version_info property which is the `SetuptoolsVersion`-compatible parsed version which supports the PEP 440 options for handling pre/post-releases, local changes, etc.
1 parent 58a80e1 commit 1d03382

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

pysolr.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import re
1010
import time
1111
from xml.etree import ElementTree
12-
from pkg_resources import get_distribution, DistributionNotFound
12+
from pkg_resources import DistributionNotFound, get_distribution, parse_version
1313

1414
import requests
1515

@@ -58,12 +58,15 @@
5858
__all__ = ['Solr']
5959

6060
try:
61-
__version__ = get_distribution(__name__).version
61+
pkg_distribution = get_distribution(__name__)
62+
__version__ = pkg_distribution.version
63+
version_info = pkg_distribution.parsed_version
6264
except DistributionNotFound:
63-
__version__ = (0, 0, 'dev0')
65+
__version__ = '0.0.dev0'
66+
version_info = parse_version(__version__)
6467

6568
def get_version():
66-
return "%s.%s.%s" % __version__[:3]
69+
return __version__
6770

6871

6972
DATETIME_REGEX = re.compile('^(?P<year>\d{4})-(?P<month>\d{2})-(?P<day>\d{2})T(?P<hour>\d{2}):(?P<minute>\d{2}):(?P<second>\d{2})(\.\d+)?Z$')

0 commit comments

Comments
 (0)