SHARE
TWEET

Untitled

a guest Jun 18th, 2019 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. python_version_full := $(wordlist 2,4,$(subst ., ,$(shell python --version 2>&1)))
  2. python_version_major := $(word 1,${python_version_full})
  3. python_version_minor := $(word 2,${python_version_full})
  4. python_version_patch := $(word 3,${python_version_full})
  5.  
  6. my_cmd.python.2 := python2 some_script.py2
  7. my_cmd.python.3 := python3 some_script.py3
  8. my_cmd := ${my_cmd.python.${python_version_major}}
  9.  
  10. all :
  11.     @echo ${python_version_full}
  12.     @echo ${python_version_major}
  13.     @echo ${python_version_minor}
  14.     @echo ${python_version_patch}
  15.     @echo ${my_cmd}
  16.  
  17. .PHONY : all
  18.      
  19. PYV=$(shell python -c "import sys;t='{v[0]}.{v[1]}'.format(v=list(sys.version_info[:2]));sys.stdout.write(t)");
  20.      
  21. ifeq ($(OS),Windows_NT)
  22.   PYDIR=c:/python36
  23.   PATH:=$(PYDIR)/scripts:$(PYDIR):$(PATH)
  24.   PYTHON=python
  25. else
  26.   PYTHON=python3.6
  27. endif
  28.  
  29. ifeq (, $(shell which $(PYTHON) ))
  30.   $(error "PYTHON=$(PYTHON) not found in $(PATH)")
  31. endif
  32.  
  33. PYTHON_VERSION=$(shell $(PYTHON) -c "import sys;
  34.       t='{v[0]}.{v[1]}'.format(v=list(sys.version_info[:2]));
  35.       sys.stdout.write(t)")
  36.  
  37. PYTHON_VERSION_MIN=3.5
  38. PYTHON_VERSION_MIN_OK := $(shell echo '$(PYTHON_VERSION) >= $(PYTHON_VERSION_MIN)' | bc)
  39.  
  40. ifeq ($(PYTHON_VERSION_MIN_OK),0)
  41.   $(error "Need python $(PYTHON_VERSION) >= $(PYTHON_VERSION_MIN)")
  42. endif
  43.  
  44. # ========================================================
  45. help:: ; grep -Pih -- "^wS+:" Makefile | sort | uniq
  46.  
  47. web::
  48.     $(PYTHON) manage.py runserver
  49.  
  50. test::
  51.     $(PYTHON) manage.py test
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top