This repository was archived by the owner on Oct 23, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +15
-13
lines changed Expand file tree Collapse file tree 2 files changed +15
-13
lines changed Original file line number Diff line number Diff line change 88from __future__ import absolute_import
99
1010import logging
11- try :
12- import pkg_resources
13- except ImportError :
14- pkg_resources = None # NOQA
1511import sys
1612
1713# Using "NOQA" to preserve export compatibility
3228def get_version_from_app (module_name , app ):
3329 version = None
3430
35- # Try to pull version from pkg_resource first
31+ # Try to pull version from pkg_resources first
3632 # as it is able to detect version tagged with egg_info -b
37- if pkg_resources is not None :
33+ try :
34+ # Importing pkg_resources can be slow, so only import it
35+ # if we need it.
36+ import pkg_resources
37+ except ImportError :
38+ # pkg_resource is not available on Google App Engine
39+ pass
40+ else :
3841 # pull version from pkg_resources if distro exists
3942 try :
4043 return pkg_resources .get_distribution (module_name ).version
Original file line number Diff line number Diff line change 22
33import os .path
44
5- try :
6- import pkg_resources
7- except ImportError :
8- # pkg_resource is not available on Google App Engine
9- pkg_resources = None
10-
115from raven .utils .compat import text_type
126from .exceptions import InvalidGitRepository
137
@@ -68,7 +62,12 @@ def fetch_package_version(dist_name):
6862 """
6963 >>> fetch_package_version('sentry')
7064 """
71- if pkg_resources is None :
65+ try :
66+ # Importing pkg_resources can be slow, so only import it
67+ # if we need it.
68+ import pkg_resources
69+ except ImportError :
70+ # pkg_resource is not available on Google App Engine
7271 raise NotImplementedError ('pkg_resources is not available '
7372 'on this Python install' )
7473 dist = pkg_resources .get_distribution (dist_name )
You can’t perform that action at this time.
0 commit comments