Skip to content

Commit bb5ac5c

Browse files
committed
pkg_resources fix
1 parent a33a9ab commit bb5ac5c

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

src/ops/__init__.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,24 @@
88
# OF ANY KIND, either express or implied. See the License for the specific language
99
# governing permissions and limitations under the License.
1010

11-
import pkg_resources
1211
import re
1312
from distutils.version import StrictVersion
1413
from subprocess import call, Popen, PIPE
1514

1615
from six import PY3
1716

1817
from .cli import display
18+
try:
19+
from importlib import metadata as importlib_metadata
20+
except ImportError:
21+
import importlib_metadata
1922

2023

2124
def validate_ops_version(min_ops_version):
22-
current_ops_version = [
23-
x.version for x in pkg_resources.working_set if x.project_name == "ops-cli"][0]
25+
try:
26+
current_ops_version = importlib_metadata.version("ops-cli")
27+
except Exception:
28+
raise Exception("Cannot determine current ops-cli version from installed metadata.")
2429
if StrictVersion(current_ops_version) < StrictVersion(min_ops_version):
2530
raise Exception("The current ops version {0} is lower than the minimum required version {1}. "
2631
"Please upgrade by following the instructions seen here: "

src/ops/cli/terraform.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
from ops.hierarchical.composition_config_generator import TerraformConfigGenerator
1818
from distutils.version import StrictVersion
1919
from ops import validate_ops_version
20-
import pkg_resources
2120

2221
logger = logging.getLogger(__name__)
2322

0 commit comments

Comments
 (0)