Last active
July 22, 2019 02:35
-
-
Save tats-u/54f31fec905c70837ca671d78a4f2e83 to your computer and use it in GitHub Desktop.
Get Python version with GNU Make
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Replace '.' with '' to get $PYTHON_VERSION_INT directly | |
# e.g. 3.7 | |
PYTHON_VERSION = $(shell python -c "import sys;print('.'.join(map(str,sys.version_info[:2])))") | |
# e.g. 37 | |
PYTHON_VERSION_INT = $(subst .,,$(PYTHON_VERSION)) | |
# e.g. 3 | |
PYTHON_MAJOR_VERSION = $(basename $(PYTHON_VERSION)) | |
# e.g. 7 | |
PYTHON_MINOR_VERSION = $(subst .,,$(suffix $(PYTHON_VERSION))) | |
all: | |
@echo Python version: $(PYTHON_VERSION) | |
@echo Python major version: $(PYTHON_MAJOR_VERSION) | |
@echo Python minor version: $(PYTHON_MINOR_VERSION) | |
@echo Python version integer: $(PYTHON_VERSION_INT) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment