From c7907a823c9a3c9b2a68a2441e909b8c0a5218fa Mon Sep 17 00:00:00 2001 From: Junjie Mao Date: Fri, 19 Oct 2018 21:10:01 +0800 Subject: [PATCH] kconfig: a faster way to check the availability of python3 package It is faster to check the existance of a certain library by trying importing that library, instead of invoking pip3 for a complete list of installed libraries. Time of the check can be significantly reduced. # time pip3 list ... real 0m6.038s user 0m0.652s sys 0m0.036s # time python3 -c "import kconfiglib" real 0m0.037s user 0m0.036s sys 0m0.000s Tracked-On: #1588 Signed-off-by: Junjie Mao Reviewed-by: Anthony Xu --- hypervisor/scripts/kconfig/kconfig.mk | 1 - scripts/deps.mk | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/hypervisor/scripts/kconfig/kconfig.mk b/hypervisor/scripts/kconfig/kconfig.mk index bf122bfe3..7b3e814d7 100644 --- a/hypervisor/scripts/kconfig/kconfig.mk +++ b/hypervisor/scripts/kconfig/kconfig.mk @@ -34,7 +34,6 @@ $(eval $(call override_config,PLATFORM,sbl)) $(eval $(call override_config,RELEASE,n)) $(eval $(call check_dep_exec,python3,KCONFIG_DEPS)) -$(eval $(call check_dep_exec,pip3,KCONFIG_DEPS)) $(eval $(call check_dep_py3lib,kconfiglib,KCONFIG_DEPS)) # This target invoke silentoldconfig to generate or update a .config. Useful as diff --git a/scripts/deps.mk b/scripts/deps.mk index 687ef5590..2eeae7c28 100644 --- a/scripts/deps.mk +++ b/scripts/deps.mk @@ -21,7 +21,7 @@ endef define check_dep_py3lib = $(2) += check_py3lib_$(1) check_py3lib_$(1): - @if ! pip3 list 2>/dev/null | grep $(1) > /dev/null 2>&1; then \ + @if ! python3 -c "import $(1)" > /dev/null 2>&1; then \ echo "******** Missing prerequisite tool ********"; \ echo "The python3 library *$(1)* is not installed"; \ echo "Please refer to the Getting Started Guide" \