drop use of pkg_resources
Importing pkg_resources scans all of the installed modules for data that won't be used. Switch to using importlib.metdata, which more efficiently loads the metadata for a package. Change-Id: I1709952cf0d0329e9b56c20edef50eff1696af22 Signed-off-by: Doug Hellmann <doug@doughellmann.com>
This commit is contained in:
parent
55e78be3b6
commit
6522756115
|
@ -12,7 +12,13 @@
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
# 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
|
||||||
|
|
||||||
from cinderlib import _fake_packages # noqa F401
|
from cinderlib import _fake_packages # noqa F401
|
||||||
from cinderlib import cinderlib
|
from cinderlib import cinderlib
|
||||||
|
@ -21,8 +27,8 @@ from cinderlib import serialization
|
||||||
from cinderlib import workarounds # noqa
|
from cinderlib import workarounds # noqa
|
||||||
|
|
||||||
try:
|
try:
|
||||||
__version__ = pkg_resources.get_distribution('cinderlib').version
|
__version__ = importlib_metadata.version('cinderlib')
|
||||||
except pkg_resources.DistributionNotFound:
|
except importlib_metadata.PackageNotFoundError:
|
||||||
__version__ = '0.0.0'
|
__version__ = '0.0.0'
|
||||||
|
|
||||||
DEFAULT_PROJECT_ID = objects.DEFAULT_PROJECT_ID
|
DEFAULT_PROJECT_ID = objects.DEFAULT_PROJECT_ID
|
||||||
|
|
|
@ -1 +1,2 @@
|
||||||
cinder>=15.0.0 # Apache-2.0
|
cinder>=15.0.0 # Apache-2.0
|
||||||
|
importlib_metadata>=1.7.0;python_version<'3.8' # Apache-2.0
|
||||||
|
|
Loading…
Reference in New Issue