forked from jacebrowning/template-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
78 lines (60 loc) · 1.89 KB
/
Copy pathMakefile
File metadata and controls
78 lines (60 loc) · 1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
SOURCE_FILES = Makefile cookiecutter.json {{cookiecutter.project_name}}/* {{cookiecutter.project_name}}/*/*
GENERATED_PROJECT := TemplateDemo
ENV := .venv
# MAIN #########################################################################
.PHONY: all
all: install
.PHONY: ci
ci: build
make doctor ci -C $(GENERATED_PROJECT)
.PHONY: watch
watch: install clean
pipenv run sniffer
# DEPENDENCIES #################################################################
export PIPENV_SHELL_COMPAT=true
export PIPENV_VENV_IN_PROJECT=true
.PHONY: install
install: $(ENV)
$(ENV): Pipfile*
ifdef CI
pipenv install
else
pipenv install --dev
endif
@ touch $@
# BUILD ########################################################################
_COOKIECUTTER_INPLACE = cookiecutter.json > tmp && mv tmp cookiecutter.json
.PHONY: build
build: install $(GENERATED_PROJECT)
$(GENERATED_PROJECT): $(SOURCE_FILES)
# Update template for selected test runner
ifeq ($(TEST_RUNNER),nose)
sed "s/pytest/nose/g" $(_COOKIECUTTER_INPLACE)
else ifeq ($(TEST_RUNNER),pytest)
sed "s/nose/pytest/g" $(_COOKIECUTTER_INPLACE)
endif
# Update template for selected Python on Travis CI
ifeq ($(TRAVIS_PYTHON_VERSION),3.6)
sed "s/2,/3,/g" $(_COOKIECUTTER_INPLACE)
sed "s/7/6/g" $(_COOKIECUTTER_INPLACE)
endif
# Update template for selected Python on Appveyor
ifeq ($(PYTHON_MAJOR),3)
sed "s/2,/3,/g" $(_COOKIECUTTER_INPLACE)
endif
ifeq ($(PYTHON_MINOR),6)
sed "s/7/6/g" $(_COOKIECUTTER_INPLACE)
endif
# Generate a project from the template
sed "s/master/python2-pytest/g" $(_COOKIECUTTER_INPLACE)
cat cookiecutter.json
pipenv run cookiecutter . --no-input --overwrite-if-exists
sed "s/python2-pytest/master/g" $(_COOKIECUTTER_INPLACE)
@ touch $(GENERATED_PROJECT)
# CLEANUP ######################################################################
.PHONY: clean
clean:
rm -rf $(GENERATED_PROJECT)
.PHONY: clean-all
clean-all: clean
rm -rf $(ENV)