From a9e36a30b3df11aeae9924d7b40950f23fc1b7c0 Mon Sep 17 00:00:00 2001 From: jab Date: Sat, 6 Jun 2015 15:59:13 +0000 Subject: [PATCH] add __version__ attribute --- bidict/__init__.py | 18 ++++++++++++++++-- setup.py | 2 +- tests/test_version.py | 4 ++++ 3 files changed, 21 insertions(+), 3 deletions(-) create mode 100644 tests/test_version.py diff --git a/bidict/__init__.py b/bidict/__init__.py index 066b1f5..c074244 100644 --- a/bidict/__init__.py +++ b/bidict/__init__.py @@ -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) diff --git a/setup.py b/setup.py index d0032f9..7157c40 100644 --- a/setup.py +++ b/setup.py @@ -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: diff --git a/tests/test_version.py b/tests/test_version.py new file mode 100644 index 0000000..db67ffd --- /dev/null +++ b/tests/test_version.py @@ -0,0 +1,4 @@ +import bidict + +def test_version(): + assert bidict.__version__