diff --git a/cinderlib/__init__.py b/cinderlib/__init__.py index c5902da..37a1189 100644 --- a/cinderlib/__init__.py +++ b/cinderlib/__init__.py @@ -12,7 +12,13 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # 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 from cinderlib import _fake_packages # noqa F401 from cinderlib import cinderlib @@ -21,8 +27,8 @@ from cinderlib import serialization from cinderlib import workarounds # noqa try: - __version__ = pkg_resources.get_distribution('cinderlib').version -except pkg_resources.DistributionNotFound: + __version__ = importlib_metadata.version('cinderlib') +except importlib_metadata.PackageNotFoundError: __version__ = '0.0.0' DEFAULT_PROJECT_ID = objects.DEFAULT_PROJECT_ID diff --git a/requirements.txt b/requirements.txt index afeb1c2..634976d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1,2 @@ cinder>=15.0.0 # Apache-2.0 +importlib_metadata>=1.7.0;python_version<'3.8' # Apache-2.0