From 7c8db72bce625760971811548f3e02fec585d52d Mon Sep 17 00:00:00 2001 From: Piyush Raj Date: Wed, 10 Jan 2024 09:38:35 +0530 Subject: [PATCH] Refactor: module-level import for fprime-packages --- src/fprime/util/build_helper.py | 5 ++--- src/fprime/util/commands.py | 5 ++--- src/fprime/util/versioning.py | 31 +++++++++++++++---------------- 3 files changed, 19 insertions(+), 22 deletions(-) diff --git a/src/fprime/util/build_helper.py b/src/fprime/util/build_helper.py index a58dabc3..0893e7d0 100644 --- a/src/fprime/util/build_helper.py +++ b/src/fprime/util/build_helper.py @@ -19,7 +19,7 @@ from fprime.fbuild.cli import get_target from fprime.fbuild.target import NoSuchTargetException -from .versioning import VersionException, get_version, get_toolchain +from .versioning import VersionException, get_version, FPRIME_PIP_PACKAGES # Attempt to get pkg_resources from "setuptools" try: @@ -68,8 +68,7 @@ def validate_tools_from_requirements(build: Build): return # Now check each required tool for fprime - tools = get_toolchain() - for tool in tools: + for tool in FPRIME_PIP_PACKAGES: for possible in possibilities: try: package_version_check(tool, possible) diff --git a/src/fprime/util/commands.py b/src/fprime/util/commands.py index eeff1174..e1738770 100644 --- a/src/fprime/util/commands.py +++ b/src/fprime/util/commands.py @@ -18,7 +18,7 @@ from fprime.fbuild.builder import Build, InvalidBuildCacheException from fprime.util.code_formatter import ClangFormatter -from .versioning import VersionException, get_toolchain +from .versioning import VersionException, FPRIME_PIP_PACKAGES from fprime.util.cookiecutter_wrapper import ( new_component, new_deployment, @@ -221,9 +221,8 @@ def run_version_check( print("[WARNING] Cannot import 'pkg_resources'. Will not check tool versions.") return - tools = get_toolchain() print("Pip packages:") - for tool in tools: + for tool in FPRIME_PIP_PACKAGES: try: version = pkg_resources.get_distribution(tool).version print(f" {tool}=={version}") diff --git a/src/fprime/util/versioning.py b/src/fprime/util/versioning.py index ed10555e..68f783c8 100644 --- a/src/fprime/util/versioning.py +++ b/src/fprime/util/versioning.py @@ -8,22 +8,21 @@ class VersionException(Exception): pass -def get_toolchain(): - return [ - "fprime-tools", - "fprime-gds", - "fprime-fpp-to-xml", - "fprime-fpp-to-json", - "fprime-fpp-to-cpp", - "fprime-fpp-syntax", - "fprime-fpp-locate-uses", - "fprime-fpp-locate-defs", - "fprime-fpp-from-xml", - "fprime-fpp-format", - "fprime-fpp-filenames", - "fprime-fpp-depend", - "fprime-fpp-check", - ] +FPRIME_PIP_PACKAGES = [ + "fprime-tools", + "fprime-gds", + "fprime-fpp-to-xml", + "fprime-fpp-to-json", + "fprime-fpp-to-cpp", + "fprime-fpp-syntax", + "fprime-fpp-locate-uses", + "fprime-fpp-locate-defs", + "fprime-fpp-from-xml", + "fprime-fpp-format", + "fprime-fpp-filenames", + "fprime-fpp-depend", + "fprime-fpp-check", +] def get_version(package: str, requirements: Path):