diff options
author | Doug Hellmann <doug@doughellmann.com> | 2020-07-05 19:35:41 -0400 |
---|---|---|
committer | Hervé Beraud <hberaud@redhat.com> | 2020-07-06 11:07:17 +0200 |
commit | e8dd381e626d48f11c6b8c9e296433b23e88124b (patch) | |
tree | 2d20d4970fdd86ed65effa14c8ea0ca0f8ec401f | |
parent | 61a0ff8ace87e917d31231f28f3be6b21a113624 (diff) | |
download | osprofiler-e8dd381e626d48f11c6b8c9e296433b23e88124b.tar.gz |
switch to importlib.metadata to find package version3.3.0
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>
-rw-r--r-- | lower-constraints.txt | 1 | ||||
-rw-r--r-- | osprofiler/__init__.py | 9 | ||||
-rw-r--r-- | requirements.txt | 1 |
3 files changed, 9 insertions, 2 deletions
diff --git a/lower-constraints.txt b/lower-constraints.txt index a857357..2ced6ac 100644 --- a/lower-constraints.txt +++ b/lower-constraints.txt @@ -2,6 +2,7 @@ coverage===4.0 ddt===1.0.1 dulwich===0.15.0 elasticsearch===2.0.0 +importlib_metadata==1.7.0 jaeger-client==3.8.0 netaddr===0.7.18 openstackdocstheme==2.2.1 diff --git a/osprofiler/__init__.py b/osprofiler/__init__.py index 22bedd3..e9adf59 100644 --- a/osprofiler/__init__.py +++ b/osprofiler/__init__.py @@ -13,6 +13,11 @@ # License for the specific language governing permissions and limitations # 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") diff --git a/requirements.txt b/requirements.txt index 2239282..7719bc4 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,3 +6,4 @@ PrettyTable<0.8,>=0.7.2 # BSD requests>=2.14.2 # Apache-2.0 six>=1.10.0 # MIT WebOb>=1.7.1 # MIT +importlib_metadata>=1.7.0;python_version<'3.8' # Apache-2.0 |