From 7b19c1b87955c6dcf8087176a3ab9c7c8e16cffb 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/Components/Storage/requirements.txt | 1 - Sming/Makefile | 8 ++++++++ Tools/requirements.txt | 1 - 5 files changed, 16 insertions(+), 4 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/Components/Storage/requirements.txt b/Sming/Components/Storage/requirements.txt index bcc6ba09ac..d89304b1a8 100644 --- a/Sming/Components/Storage/requirements.txt +++ b/Sming/Components/Storage/requirements.txt @@ -1,2 +1 @@ jsonschema -rjsmin 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) diff --git a/Tools/requirements.txt b/Tools/requirements.txt index 941e353f13..ee96c8f8e1 100644 --- a/Tools/requirements.txt +++ b/Tools/requirements.txt @@ -1,3 +1,2 @@ pyserial jsonschema -rjsmin