-
-
Notifications
You must be signed in to change notification settings - Fork 220
/
Makefile
153 lines (136 loc) · 4.59 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
143
144
145
146
147
148
149
150
151
152
153
# Makefile to automate some tools
SHELL=/bin/bash
PATH := $(shell python -c "import sysconfig; print(sysconfig.get_path('scripts'))"):$(PATH)
BUILDDIR := ./build
EXT_SUFFIX := $(shell python -c "import sysconfig; print(sysconfig.get_config_var('EXT_SUFFIX'))")
ARCH := $(shell python -c "import platform; print(platform.machine().lower())")
PY_PLATFORM := $(shell python -c "import sysconfig; print(sysconfig.get_platform())")
PY_VERSION_NODOT := $(shell python -c "import sysconfig; print(sysconfig.get_config_var('py_version_nodot'))")
COVERAGE_FILE := $(BUILDDIR)/.coverage-$(PY_VERSION_NODOT)-$(PY_PLATFORM)
PRE_COMMIT_OPTIONS := --show-diff-on-failure --color=always --all-files --hook-stage=manual
CIBW_ONLY := cp$(PY_VERSION_NODOT)-manylinux_$(ARCH)
.PHONY: all
all: install
.PHONY: pre-commit
pre-commit: install
@(pre-commit run $(PRE_COMMIT_OPTIONS) || true) | more
@pre-commit gc
.PHONY: pylint
pylint:
@if ! which pylint; then uv pip install --upgrade pylint; fi
@pylint cx_Freeze
.PHONY: clean
clean: uninstall
@$(MAKE) -C doc clean
@if which coverage; then\
coverage erase --data-file=$(COVERAGE_FILE);\
coverage erase;\
fi
.PHONY: install
install:
if ! which uv; then\
python -m pip install --upgrade uv --disable-pip-version-check;\
fi
if ! which pre-commit || ! [ -f .git/hooks/pre-commit ]; then\
UV_RESOLUTION=highest uv pip install --upgrade \
-r requirements.txt -r requirements-dev.txt -r requirements-doc.txt &&\
uv pip install -e. --no-build-isolation --no-deps --reinstall &&\
pre-commit install --install-hooks --overwrite -t pre-commit;\
fi
.PHONY: uninstall
uninstall:
@if which pre-commit && [ -f .git/hooks/pre-commit ]; then\
pre-commit clean;\
pre-commit uninstall;\
rm -f .git/hooks/pre-commit;\
fi
.PHONY: upgrade
upgrade: clean install
pre-commit autoupdate
$(MAKE) pre-commit
.PHONY: html
html:
@if which pre-commit && [ -f .git/hooks/pre-commit ]; then\
pre-commit run blacken-docs $(PRE_COMMIT_OPTIONS);\
pre-commit run build-docs $(PRE_COMMIT_OPTIONS);\
else\
UV_RESOLUTION=highest \
uv pip install --upgrade -r requirements-doc.txt &&\
$(MAKE) -C doc html;\
fi
.PHONY: htmltest
htmltest:
$(MAKE) -C doc test
.PHONY: doc
doc: html
$(MAKE) -C doc epub
$(MAKE) -C doc pdf
.PHONY: install_test
install_test:
./ci/build-wheel.sh
UV_RESOLUTION=highest uv pip install --upgrade -r requirements-test.txt
.PHONY: test
test: install_test
pytest -nauto --no-cov
.PHONY: cov
cov: install_test
@rm -rf $(BUILDDIR)/coverage
pytest -nauto --cov="cx_Freeze" --cov-report=html
coverage report
@python -m webbrowser -t $(BUILDDIR)/coverage/index.html
.PHONY: cov2
cov2: install_test
coverage erase
COVERAGE_FILE=$(COVERAGE_FILE) coverage erase
COVERAGE_FILE=$(COVERAGE_FILE) pytest -nauto --cov="cx_Freeze" || true
ifeq ($(PY_PLATFORM),win-amd64)
# Extra coverage for Windows
# test without lief (LIEF_DISABLED)
CX_FREEZE_BIND=imagehlp \
COVERAGE_FILE=$(COVERAGE_FILE)-1 pytest -nauto --cov="cx_Freeze" \
tests/test_command_build.py tests/test_command_build_exe.py \
tests/test_winversioninfo.py || true
# test lief < 0.13
uv pip install "lief==0.12.3"
COVERAGE_FILE=$(COVERAGE_FILE)-2 pytest -nauto --cov="cx_Freeze" \
tests/test_command_build.py tests/test_command_build_exe.py \
tests/test_winversioninfo.py || true
# test lief < 0.14
uv pip install "lief==0.13.2"
COVERAGE_FILE=$(COVERAGE_FILE)-3 pytest -nauto --cov="cx_Freeze" \
tests/test_command_build.py tests/test_command_build_exe.py \
tests/test_winversioninfo.py || true
# test lief < 0.15
uv pip install "lief==0.14.1"
COVERAGE_FILE=$(COVERAGE_FILE)-4 pytest -nauto --cov="cx_Freeze" \
tests/test_command_build.py tests/test_command_build_exe.py \
tests/test_winversioninfo.py || true
# coverage winversioninfo using pywin32
uv pip install --upgrade pywin32
COVERAGE_FILE=$(COVERAGE_FILE)-5 pytest -nauto --cov="cx_Freeze" \
tests/test_winversioninfo.py || true
uv pip uninstall pywin32
uv pip install "lief>0.14.1"
endif
coverage combine --keep $(BUILDDIR)/.coverage-*
@rm -rf $(BUILDDIR)/coverage
coverage html
coverage report
@python -m webbrowser -t $(BUILDDIR)/coverage/index.html
.PHONY: release
release:
bump-my-version show-bump 2>/dev/null
@echo "Run:"
@echo " bump-my-version bump <option>"
@echo "--or--"
@echo " bump-my-version bump patch --new-version=X.XX.X"
@echo "--then--"
@echo " git push origin `git branch --show-current` --tags"
.PHONY: release-dev
release-dev:
if (grep "current_version" pyproject.toml | grep -q "\-dev"); then\
bump-my-version bump --allow-dirty --no-tag build;\
else\
bump-my-version bump --allow-dirty --no-tag minor;\
fi
git log -1