forked from buildout/buildout
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
142 lines (114 loc) · 4.71 KB
/
Makefile
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
HERE = $(shell pwd)
PYTHON_VER ?= 3.7
PYTHON_PATH = $(HERE)/pythons/$(PYTHON_VER)
PYTHON_BUILD_DIR = $(HERE)/python_builds
PLATFORM = $(shell uname)
VENV = $(HERE)/venvs/$(PYTHON_VER)
BUILD_VARIABLES =
ifeq ($(PYTHON_VER),2.7)
PYTHON_MINOR ?= 2.7.18
endif
ifeq ($(PYTHON_VER),3.5)
PYTHON_MINOR ?= 3.5.9
endif
ifeq ($(PYTHON_VER),3.6)
PYTHON_MINOR ?= 3.6.10
endif
ifeq ($(PYTHON_VER),3.7)
PYTHON_MINOR ?= 3.7.7
endif
ifeq ($(PYTHON_VER),3.8)
PYTHON_MINOR ?= 3.8.3
endif
ifeq ($(PYTHON_VER),3.9)
PYTHON_MINOR ?= 3.9.0
PYTHON_ARCHIVE ?= Python-3.9.0b3
endif
ifndef PYTHON_MINOR
$(error Please specify desired PYTHON_MINOR for Python $(PYTHON_VER))
endif
ifeq ($(PLATFORM),Darwin)
include Makefile.configure.Darwin
else
include Makefile.configure
endif
PYTHON_ARCHIVE ?= Python-$(PYTHON_MINOR)
PYTHON_URL = https://www.python.org/ftp/python/$(PYTHON_MINOR)/$(PYTHON_ARCHIVE).tgz
PYTHON_EXE = python$(PYTHON_VER)
PYTHON_DOWNLOAD = $(PYTHON_BUILD_DIR)/$(PYTHON_ARCHIVE).tgz
BUILD_DIRS = $(PYTHON_PATH) bin build develop-eggs eggs parts
all: all_test
.PHONY: all download_python python build test coverage docker docker_deb docker_deb_sys all_pythons all_test all_coverage
# setup python from source
$(PYTHON_DOWNLOAD):
mkdir -p $(PYTHON_BUILD_DIR)
curl --progress-bar --location $(PYTHON_URL) -o $(PYTHON_DOWNLOAD)
$(PYTHON_BUILD_DIR)/$(PYTHON_ARCHIVE)/configure: $(PYTHON_DOWNLOAD)
cd $(PYTHON_BUILD_DIR) && tar -xzf $(PYTHON_DOWNLOAD)
touch $@
$(PYTHON_PATH)/bin/$(PYTHON_EXE): $(PYTHON_BUILD_DIR)/$(PYTHON_ARCHIVE)/configure
@echo "Installing Python"
rm -rf $(PYTHON_PATH)
mkdir -p $(PYTHON_PATH)
cd $(PYTHON_BUILD_DIR)/$(PYTHON_ARCHIVE) && \
$(BUILD_VARIABLES) ./configure --prefix $(PYTHON_PATH) $(PYTHON_CONFIGURE_ARGS) >/dev/null 2>&1 && \
make >/dev/null 2>&1 && \
make install >/dev/null 2>&1
@echo "Finished installing Python"
download_python: $(PYTHON_BUILD_DIR)/$(PYTHON_ARCHIVE)/configure
python: $(PYTHON_PATH)/bin/$(PYTHON_EXE)
# used by Dockerfile
build: python
$(PYTHON_PATH)/bin/$(PYTHON_EXE) dev.py
# copy to virtualenvs
ROOT_FILES := $(HERE)/setup.py $(HERE)/setup.cfg $(HERE)/dev.py $(HERE)/README.rst $(HERE)/CHANGES.rst $(HERE)/buildout.cfg $(HERE)/.coveragerc
SRC_FILES := $(shell find $(HERE)/src ! -path '*egg-info*' \( -name '*.py' -o -name '*.txt' -o -name '*.test' \) )
RCP_FILES := $(shell find $(HERE)/zc.recipe.egg_ ! -path '*egg-info*' \( -name '*.py' -o -name '*.txt' -o -name '*.rst' -o -name '*.cfg' -o -name '*.in' \) )
DOC_FILES := $(shell find $(HERE)/doc -name '*.rst' -o -name '*.txt')
ALL_COPY := $(subst $(HERE),$(VENV),$(SRC_FILES) $(DOC_FILES) $(RCP_FILES) $(ROOT_FILES))
# Generate rules to map sources into targets
$(foreach s,$(ALL_COPY),$(eval $s: $(VENV)/bin/$(PYTHON_EXE) $(subst $(VENV),$(HERE),$s)))
$(ALL_COPY):
@mkdir -p $(dir $@)
@cp $(subst $(VENV),$(HERE),$@) $@
$(VENV)/bin/$(PYTHON_EXE): $(PYTHON_PATH)/bin/$(PYTHON_EXE)
@command -v virtualenv >/dev/null 2>&1 || { echo "virtualenv required but not installed" >&2; exit 1; }
test -d "$(HERE)/venvs" || mkdir -p $(HERE)/venvs
virtualenv -p $(PYTHON_PATH)/bin/$(PYTHON_EXE) $(VENV)
$(VENV)/bin/test: $(VENV)/bin/$(PYTHON_EXE) $(ALL_COPY)
cd $(VENV) && bin/$(PYTHON_EXE) dev.py --no-clean
$(VENV)/bin/coverage: $(VENV)/bin/$(PYTHON_EXE)
$(VENV)/bin/pip install coverage
coverage: $(VENV)/bin/coverage $(VENV)/bin/test
COVERAGE_REPORT= RUN_COVERAGE= $(VENV)/bin/test $(testargs)
test: $(VENV)/bin/test
$(VENV)/bin/test -c -vvv $(testargs)
all_pythons:
$(MAKE) PYTHON_VER=2.7 python
$(MAKE) PYTHON_VER=3.5 python
$(MAKE) PYTHON_VER=3.6 python
$(MAKE) PYTHON_VER=3.7 python
$(MAKE) PYTHON_VER=3.8 python
all_coverage:
$(MAKE) PYTHON_VER=2.7 coverage
$(MAKE) PYTHON_VER=3.5 coverage
$(MAKE) PYTHON_VER=3.6 coverage
$(MAKE) PYTHON_VER=3.7 coverage
$(MAKE) PYTHON_VER=3.8 coverage
all_test:
$(MAKE) PYTHON_VER=2.7 test
$(MAKE) PYTHON_VER=3.5 test
$(MAKE) PYTHON_VER=3.6 test
$(MAKE) PYTHON_VER=3.7 test
$(MAKE) PYTHON_VER=3.8 test
docker:
docker build -f .github/workflows/Dockerfile --tag centos_buildout:python${PYTHON_VER} --build-arg PYTHON_VER=${PYTHON_VER} .
docker run centos_buildout:python${PYTHON_VER} /bin/bash -c 'RUN_COVERAGE= COVERAGE_REPORT= /buildout/bin/test -c -vvv -t abi'
docker_deb:
docker build -f .github/workflows/Dockerfile-debian --tag debian_buildout:python${PYTHON_VER} --build-arg PYTHON_VER=${PYTHON_VER} .
docker run debian_buildout:python${PYTHON_VER} /bin/bash -c 'RUN_COVERAGE= COVERAGE_REPORT= /buildout/bin/test -c -vvv -t abi'
docker_deb_sys:
docker build -f .github/workflows/Dockerfile-debian-system --tag debian_system_buildout .
docker run debian_system_buildout /bin/bash -c 'RUN_COVERAGE= COVERAGE_REPORT= /buildout/bin/test -c -vvv -t abi'
clean:
rm -rf $(VENVS) $(PYTHON_BUILD_DIR) $(HERE)/pythons