Skip to content

Commit

Permalink
Remove dependency to pkg_resources (#9691)
Browse files Browse the repository at this point in the history
  • Loading branch information
ikkoham authored Mar 1, 2023
1 parent 7463342 commit b7a63c3
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions qiskit/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@

"""Contains the terra version."""

from collections.abc import Mapping
import os
import subprocess
import sys
from collections.abc import Mapping

ROOT_DIR = os.path.dirname(os.path.abspath(__file__))

Expand Down Expand Up @@ -101,7 +102,10 @@ def __init__(self):
self._loaded = False

def _load_versions(self):
import pkg_resources
if sys.version_info >= (3, 8):
from importlib.metadata import version
else:
from importlib_metadata import version

try:
# TODO: Update to use qiskit_aer instead when we remove the
Expand Down Expand Up @@ -148,7 +152,7 @@ def _load_versions(self):
except Exception:
self._version_dict["qiskit-machine-learning"] = None
try:
self._version_dict["qiskit"] = pkg_resources.get_distribution("qiskit").version
self._version_dict["qiskit"] = version("qiskit")
except Exception:
self._version_dict["qiskit"] = None
self._loaded = True
Expand Down

0 comments on commit b7a63c3

Please sign in to comment.