From 295a5f39af034de1a819915044323b2588666f11 Mon Sep 17 00:00:00 2001 From: Mike Date: Sat, 20 Feb 2021 07:26:25 +0000 Subject: [PATCH] Catch missing python modules and print message (#2221) * Add `python-requirements` target for main Sming Makefile to install core requirements * Catch missing optional python modules and print more obvious message --- Sming/Components/IFS | 2 +- Sming/Components/Storage/Tools/hwconfig/config.py | 8 +++++++- Sming/Makefile | 8 ++++++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/Sming/Components/IFS b/Sming/Components/IFS index 778a4a973f..cd16dc51c4 160000 --- a/Sming/Components/IFS +++ b/Sming/Components/IFS @@ -1 +1 @@ -Subproject commit 778a4a973ff5fa2eb091db653f66f2d41f737e59 +Subproject commit cd16dc51c49fc792e1ae92f96ab2d8eb74873538 diff --git a/Sming/Components/Storage/Tools/hwconfig/config.py b/Sming/Components/Storage/Tools/hwconfig/config.py index 9e4e8101c6..e0b373ec70 100644 --- a/Sming/Components/Storage/Tools/hwconfig/config.py +++ b/Sming/Components/Storage/Tools/hwconfig/config.py @@ -5,7 +5,13 @@ import os, partition, storage from common import * from builtins import classmethod -from rjsmin import jsmin + +try: + from rjsmin import jsmin +except ImportError as err: + sys.stderr.write("\n** %s: please run `make python-requirements` **\n\n" % str(err)) + sys.exit(1) + def findConfig(name): dirs = os.environ['HWCONFIG_DIRS'].split(' ') diff --git a/Sming/Makefile b/Sming/Makefile index c058d057e6..a64374e5ca 100644 --- a/Sming/Makefile +++ b/Sming/Makefile @@ -175,6 +175,14 @@ $(CLEAN_TESTS): ##@Tools +CACHE_VARS += PIP_ARGS +PIP_ARGS ?= +.PHONY: python-requirements +python-requirements: ##Install Python requirements for framework via pip (use PIP_ARGS=... for additional options) + @echo Installing Python requirements... + $(Q) $(PYTHON) -m pip install $(PIP_ARGS) -r $(SMING_HOME)/../Tools/requirements.txt + + # Recursive wildcard search # $1 -> list of directories # $2 -> file extensions filters (using % as wildcard)