Skip to content

Commit

Permalink
Making version work in envs where get_distribution does not.
Browse files Browse the repository at this point in the history
  • Loading branch information
dhermes committed Jan 22, 2015
1 parent 927c534 commit a126550
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
8 changes: 5 additions & 3 deletions gcloud/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

"""GCloud API access in idiomatic Python."""

from pkg_resources import get_distribution

__version__ = get_distribution('gcloud').version
try:
import pkg_resources
__version__ = pkg_resources.get_distribution('gcloud').version
except (ImportError, pkg_resources.DistributionNotFound): # pragma: NO COVER
__version__ = None
6 changes: 3 additions & 3 deletions gcloud/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@

""" Shared implementation of connections to API servers."""

from pkg_resources import get_distribution

import httplib2

import gcloud


class Connection(object):
"""A generic connection to Google Cloud Platform.
Expand All @@ -32,7 +32,7 @@ class Connection(object):
_EMPTY = object()
"""A pointer to represent an empty value for default arguments."""

USER_AGENT = "gcloud-python/{0}".format(get_distribution('gcloud').version)
USER_AGENT = "gcloud-python/{0}".format(gcloud.__version__)
"""The user agent for gcloud-python requests."""

def __init__(self, credentials=None):
Expand Down

0 comments on commit a126550

Please sign in to comment.