-
-
Notifications
You must be signed in to change notification settings - Fork 224
/
Makefile
149 lines (132 loc) · 4.33 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
# Makefile to automate some tools
SHELL=/bin/bash
PATH := $(shell python -c "import sysconfig; print(sysconfig.get_path('scripts'))"):$(PATH)
BUILDDIR := ./build
PY_PLATFORM := $(shell python -c "import sysconfig; print(sysconfig.get_platform())")
PRE_COMMIT_OPTIONS := --show-diff-on-failure --color=always --all-files --hook-stage=manual
.PHONY: all
all: install
.PHONY: pre-commit
pre-commit: install
@(pre-commit run $(PRE_COMMIT_OPTIONS) || true) | more
@pre-commit gc
.PHONY: pylint
pylint:
uvx pylint cx_Freeze
.PHONY: clean
clean: uninstall
@$(MAKE) -C doc clean
@rm -f .coverage .backup_coverage || true
.PHONY: install
install:
ifeq ($(PY_PLATFORM),win-amd64)
if ! which uv; then\
python -m pip install --upgrade uv --disable-pip-version-check;\
fi
else
curl -LsSf https://astral.sh/uv/install.sh | env UV_UNMANAGED_INSTALL="$(HOME)/bin" sh
endif
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 doc/requirements.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 doc/requirements.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_pytest
install_pytest:
./ci/build-wheel.sh
UV_RESOLUTION=highest uv pip install --upgrade -r tests/requirements.txt
.PHONY: tests
tests: install_pytest
pytest -nauto --no-cov
.PHONY: cov
cov: install_pytest
@rm -rf $(BUILDDIR)/coverage_html_report
@if [ -f .coverage ]; then mv .coverage .backup_coverage; fi
pytest -nauto --cov="cx_Freeze" --cov-report=html
coverage report
@python -m webbrowser -t $(BUILDDIR)/coverage_html_report/index.html
@if [ -f .backup_coverage ]; then coverage combine -a .backup_coverage; fi
.PHONY: cov2
cov2: install_pytest
@rm -rf $(BUILDDIR)/coverage_html_report
@if [ -f .coverage ]; then mv .coverage .backup_coverage; fi
pytest -nauto --cov="cx_Freeze" || true
ifeq ($(PY_PLATFORM),win-amd64)
# Extra coverage for Windows
# test without lief (LIEF_DISABLED)
CX_FREEZE_BIND=imagehlp \
pytest -nauto --cov="cx_Freeze" --cov-append \
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"
pytest -nauto --cov="cx_Freeze" --cov-append \
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"
pytest -nauto --cov="cx_Freeze" --cov-append \
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"
pytest -nauto --cov="cx_Freeze" --cov-append \
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
pytest -nauto --cov="cx_Freeze" --cov-append \
tests/test_winversioninfo.py || true
uv pip uninstall pywin32
uv pip install "lief>0.14.1"
endif
@if [ -f .backup_coverage ]; then coverage combine -a .backup_coverage; fi
coverage report
coverage html --title="Multiple coverage reports"
@python -m webbrowser -t $(BUILDDIR)/coverage_html_report/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