python_version_full := $(wordlist 2,4,$(subst ., ,$(shell python --version 2>&1)))
python_version_major := $(word 1,${python_version_full})
python_version_minor := $(word 2,${python_version_full})
python_version_patch := $(word 3,${python_version_full})
my_cmd.python.2 := python2 some_script.py2
my_cmd.python.3 := python3 some_script.py3
my_cmd := ${my_cmd.python.${python_version_major}}
all :
@echo ${python_version_full}
@echo ${python_version_major}
@echo ${python_version_minor}
@echo ${python_version_patch}
@echo ${my_cmd}
.PHONY : all
良好的使用它,但我真的需要處理它的Makefile ... – Rizo 2011-02-08 13:03:32
內。在這種情況下,看這裏:HTTP:/ /old.nabble.com/Detecting-which-Python-version-is-used-by-SIP-and-PyQt-td30033430.html – 2011-02-08 13:09:18