From 2ee2b2cb33dbe123d7163fd031f00fb1d4a39a96 Mon Sep 17 00:00:00 2001 From: "Joshua M. Boniface" Date: Wed, 25 Oct 2023 01:51:08 -0400 Subject: [PATCH] Avoid loading pkg_resources until needed This import took forever (0.2s) and was used only for the version command, so don't import it except where it's needed. --- client-cli/pvc/cli/cli.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/client-cli/pvc/cli/cli.py b/client-cli/pvc/cli/cli.py index 4629d195..c31e4636 100644 --- a/client-cli/pvc/cli/cli.py +++ b/client-cli/pvc/cli/cli.py @@ -25,9 +25,8 @@ from functools import wraps from json import dump as jdump from json import dumps as jdumps from json import loads as jloads -from os import environ, makedirs, path -from pkg_resources import get_distribution from lxml.etree import fromstring, tostring +from os import environ, makedirs, path from re import sub, match from yaml import load as yload from yaml import SafeLoader as SafeYAMLLoader @@ -115,6 +114,8 @@ def version(ctx, param, value): if not value or ctx.resilient_parsing: return + from pkg_resources import get_distribution + version = get_distribution("pvc").version echo(CLI_CONFIG, f"Parallel Virtual Cluster CLI client version {version}") ctx.exit()