Skip to content

Commit

Permalink
Refactor: module-level import for fprime-packages
Browse files Browse the repository at this point in the history
  • Loading branch information
0x48piraj committed Jan 10, 2024
1 parent 3080397 commit 7c8db72
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 22 deletions.
5 changes: 2 additions & 3 deletions src/fprime/util/build_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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)
Expand Down
5 changes: 2 additions & 3 deletions src/fprime/util/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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}")
Expand Down
31 changes: 15 additions & 16 deletions src/fprime/util/versioning.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 7c8db72

Please sign in to comment.