diff --git a/Makefile b/Makefile index e40c5ff..5d9607c 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,4 @@ +include mk/python.mk DCURL_DIR := deps/dcurl DCURL_LIB := $(DCURL_DIR)/build/libdcurl.so DEPS += $(DCURL_LIB) @@ -19,7 +20,7 @@ TESTS += $(wildcard tests/tangleid/*.sh) check: server.py $(DCURL_LIB) @ TMP_PID=`mktemp /tmp/server_pid.XXXXXX`; \ echo "Running test suite..." ; \ - ( python $^ & echo $$! > $${TMP_PID} ); \ + ( $(PYTHON) $^ & echo $$! > $${TMP_PID} ); \ sleep 3 ; \ for i in $(TESTS); do \ ( echo "\n\n==[ $$i ]==\n"; $$i || kill -9 `cat $${TMP_PID}` ) \ diff --git a/mk/python.mk b/mk/python.mk new file mode 100644 index 0000000..d325f82 --- /dev/null +++ b/mk/python.mk @@ -0,0 +1,12 @@ +PYTHON = python3 +PYTHON := $(shell which $(PYTHON)) +ifndef PYTHON +$(error "python3 is required.") +endif + +# check "iota" module in Python installation +PY_CHECK_MOD_IOTA := $(shell $(PYTHON) -c "import iota" 2>/dev/null && \ + echo 1 || echo 0) +ifneq ("$(PY_CHECK_MOD_IOTA)","1") + $(error "skip $@ because PyOTA is not installed.") +endif