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 <junjie.mao@intel.com>
Reviewed-by: Anthony Xu <anthony.xu@intel.com>
This commit is contained in:
Junjie Mao 2018-10-19 21:10:01 +08:00 committed by lijinxia
parent 256108f16b
commit c7907a823c
2 changed files with 1 additions and 2 deletions

View File

@ -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

View File

@ -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" \