switch to importlib.metadata to find package version
Importing pkg_resources has a side-effect of reading all of the metadata for every installed python package. The newer importlib.metadata module can load the metadata for one package at a time, which makes this library load more quickly and improves the startup-time performance of applications that use it such as python-openstackclient. importlib.metadata is part of the python 3.8 standard library and is distributed separately for other versions of python. Change-Id: Ib1870a3d102116f84c7677601fd44fdac41a13a6 Signed-off-by: Doug Hellmann <doug@doughellmann.com>
This commit is contained in:
parent
61a0ff8ace
commit
e8dd381e62
|
@ -2,6 +2,7 @@ coverage===4.0
|
||||||
ddt===1.0.1
|
ddt===1.0.1
|
||||||
dulwich===0.15.0
|
dulwich===0.15.0
|
||||||
elasticsearch===2.0.0
|
elasticsearch===2.0.0
|
||||||
|
importlib_metadata==1.7.0
|
||||||
jaeger-client==3.8.0
|
jaeger-client==3.8.0
|
||||||
netaddr===0.7.18
|
netaddr===0.7.18
|
||||||
openstackdocstheme==2.2.1
|
openstackdocstheme==2.2.1
|
||||||
|
|
|
@ -13,6 +13,11 @@
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import pkg_resources
|
try:
|
||||||
|
# For Python 3.8 and later
|
||||||
|
import importlib.metadata as importlib_metadata
|
||||||
|
except ImportError:
|
||||||
|
# For everyone else
|
||||||
|
import importlib_metadata
|
||||||
|
|
||||||
__version__ = pkg_resources.get_distribution("osprofiler").version
|
__version__ = importlib_metadata.version("osprofiler")
|
||||||
|
|
|
@ -6,3 +6,4 @@ PrettyTable<0.8,>=0.7.2 # BSD
|
||||||
requests>=2.14.2 # Apache-2.0
|
requests>=2.14.2 # Apache-2.0
|
||||||
six>=1.10.0 # MIT
|
six>=1.10.0 # MIT
|
||||||
WebOb>=1.7.1 # MIT
|
WebOb>=1.7.1 # MIT
|
||||||
|
importlib_metadata>=1.7.0;python_version<'3.8' # Apache-2.0
|
||||||
|
|
Loading…
Reference in New Issue