add __version__ attribute

This commit is contained in:
jab 2015-06-06 15:59:13 +00:00
parent e6dd75525a
commit a9e36a30b3
3 changed files with 21 additions and 3 deletions

View File

@ -1,7 +1,14 @@
# -*- coding: utf-8 -*-
"""
Main package which pulls in all bidirectional dict types
and utilities for working with one-to-one mappings.
Efficient, Pythonic bidirectional map implementation
and related functionality.
.. :copyright: (c) 2015 Joshua Bronson.
.. :license: ISCL. See LICENSE for details.
"""
from ._common import BidirectionalMapping, CollapseException
from ._bidict import bidict
from ._collapsing import collapsingbidict
@ -19,3 +26,10 @@ __all__ = (
'pairs',
'inverted',
)
try:
from pkg_resources import resource_string
__version__ = resource_string(__name__, 'VERSION').decode('ascii').strip()
except Exception as e:
from warnings import warn
warn('Failed to read/set version: %r' % e)

View File

@ -6,7 +6,7 @@ try:
with open('bidict/VERSION', encoding='utf8') as f:
version = f.read().strip()
except Exception as e:
version = '999999'
version = '0.0.0'
warn('Could not open bidict/VERSION, using bogus version (%s): %r' %
(version, e))
try:

4
tests/test_version.py Normal file
View File

@ -0,0 +1,4 @@
import bidict
def test_version():
assert bidict.__version__