-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
vdk-control-cli: fix circular import dependecy (#1820)
There is a circular import issue between the vdk.internal.control.configuration.vdk_config and vdk.internal.control.command_groups.version_group.version modules. Specifically, vdk_config is importing version and version is importing cli_utils, which is importing vdk_config. This creates a cycle that cannot be resolved, which is causing the ImportError under certain circumstances. To fix this issue, I need to refactor the code to remove the circular import. I moved the methods for determining verison in version utils which is used by both vdk_config and version_group.version modules. --------- Signed-off-by: Antoni Ivanov <[email protected]>
- Loading branch information
1 parent
8cd3cdf
commit c5b9096
Showing
3 changed files
with
30 additions
and
27 deletions.
There are no files selected for viewing
27 changes: 2 additions & 25 deletions
27
projects/vdk-control-cli/src/vdk/internal/control/command_groups/version_group/version.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
projects/vdk-control-cli/src/vdk/internal/control/utils/version_utils.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Copyright 2023-2023 VMware, Inc. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
from pkg_resources import DistributionNotFound | ||
from pkg_resources import get_distribution | ||
|
||
# https://packaging.python.org/guides/single-sourcing-package-version/# | ||
try: | ||
# Change here if project is renamed and does not equal the setuptools metadata.name | ||
dist_name = "vdk-control-cli" | ||
__version__ = get_distribution(dist_name).version | ||
except DistributionNotFound: # pragma: no cover | ||
__version__ = "unknown" | ||
|
||
|
||
def build_details(): | ||
try: | ||
from vdk.internal.control import vdk_control_build_info | ||
|
||
build = [ | ||
f"{key}={value}" | ||
for key, value in vdk_control_build_info.__dict__.items() | ||
if not key.startswith("_") | ||
] | ||
return ", ".join(build) | ||
except: | ||
return "" |