forked from Point72/csp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
233 lines (171 loc) · 7.07 KB
/
Makefile
File metadata and controls
233 lines (171 loc) · 7.07 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
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
EXTRA_ARGS :=
#########
# BUILD #
#########
.PHONY: requirements develop build build-debug build-conda install
ASAN :=
UBSAN :=
requirements: ## install python dev and runtime dependencies
python ci/scripts/requirements.py
develop: requirements ## install dependencies and build library
python -m pip install -e .[develop]
develop-conda: ## install just the local library when developing in conda
CSP_USE_VCPKG=OFF pip install -U -e . --no-deps --no-build-isolation
build: ## build the library
CSP_ENABLE_ASAN=$(ASAN) CSP_ENABLE_UBSAN=$(UBSAN) python setup.py build build_ext --inplace
build-debug: ## build the library ( DEBUG ) - May need a make clean when switching from regular build to build-debug and vice versa
CSP_ENABLE_ASAN=$(ASAN) CSP_ENABLE_UBSAN=$(UBSAN) SKBUILD_CONFIGURE_OPTIONS="" DEBUG=1 python setup.py build build_ext --inplace
build-conda: ## build the library in Conda
CSP_ENABLE_ASAN=$(ASAN) CSP_ENABLE_UBSAN=$(UBSAN) python setup.py build build_ext --csp-no-vcpkg --inplace
install: ## install library
python -m pip install .
#########
# LINTS #
#########
.PHONY: lint-py lint-cpp lint lints fix-py fix-cpp fix format check checks
lint-py:
python -m ruff check csp/ examples/ setup.py
python -m ruff format --check csp/ examples/ setup.py
lint-cpp:
# clang-format --dry-run -Werror -i -style=file `find ./cpp/ -name "*.*pp"`
echo "C++ linting disabled for now"
lint-docs:
python -m mdformat --check docs/wiki/ README.md examples/
python -m codespell_lib docs/wiki/ README.md examples/ --skip "*.cpp,*.h"
# lint: lint-py lint-cpp ## run lints
lint: lint-py lint-docs ## run lints
# Alias
lints: lint
fix-py:
python -m ruff check --fix csp/ examples/ setup.py
python -m ruff format csp/ examples/ setup.py
fix-cpp:
# clang-format -i -style=file `find ./cpp/ -name "*.*pp"`
echo "C++ autoformatting disabled for now"
fix-docs:
python -m mdformat docs/wiki/ README.md examples/
python -m codespell_lib --write docs/wiki/ README.md examples/ --skip "*.cpp,*.h"
fix: fix-py fix-cpp fix-docs ## run autofixers
# alias
format: fix
check:
check-manifest -v
# Alias
checks: check
#########
# TESTS #
#########
.PHONY: test-py test-cpp test-py-sanitizer coverage-py test test-sanitizer tests
TEST_ARGS :=
test-py: ## Clean and Make unit tests
python -m pytest -v csp/tests --junitxml=junit.xml $(TEST_ARGS)
test-py-sanitizer: ## Clean and Make unit tests with sanitizers enabled
@if [ "$$(uname -s)" = "Darwin" ]; then \
ASAN_OPTIONS=detect_leaks=0,detect_stack_use_after_return=true,use_odr_indicator=1,strict_init_order=true,strict_string_checks=true \
DYLD_INSERT_LIBRARIES=$$($(CXX) -print-file-name=libclang_rt.asan_osx_dynamic.dylib) \
python -m pytest -v csp/tests --junitxml=junit.xml $(TEST_ARGS); \
elif [ "$$(uname -s)" = "Linux" ]; then \
ASAN_OPTIONS=detect_leaks=0,detect_stack_use_after_return=true,use_odr_indicator=1,strict_init_order=true,strict_string_checks=true \
LD_PRELOAD=$$($(CXX) -print-file-name=libasan.so) \
python -m pytest -v csp/tests --junitxml=junit.xml $(TEST_ARGS); \
else \
echo "Unsupported platform: $$(uname -s)"; \
exit 1; \
fi
test-cpp: ## Make C++ unit tests
ifneq ($(OS),Windows_NT)
for f in ./csp/tests/bin/*; do $$f; done || (echo "TEST FAILED" && exit 1)
else
.\ci\scripts\windows\run_cpp_tests.bat
endif
coverage-py:
python -m pytest -v csp/tests --junitxml=junit.xml --cov=csp --cov-report xml --cov-report html --cov-branch --cov-fail-under=80 --cov-report term-missing $(TEST_ARGS)
test: test-cpp test-py ## run the tests
test-sanitizer: test-cpp test-py-sanitizer ## run the tests
# Alias
tests: test
.PHONY: dockerup dockerps dockerdown initpodmanmac
ADAPTER := kafka
DOCKER := podman
initpodmanmac:
podman machine stop
podman machine set --cpus 4 --memory 8096
podman machine start
dockerup: ## spin up docker compose services for adapter testing
$(DOCKER) compose -f ci/$(ADAPTER)/docker-compose.yml up -d
dockerps: ## spin up docker compose services for adapter testing
$(DOCKER) compose -f ci/$(ADAPTER)/docker-compose.yml ps
dockerdown: ## spin up docker compose services for adapter testing
$(DOCKER) compose -f ci/$(ADAPTER)/docker-compose.yml down
###########
# VERSION #
###########
.PHONY: show-version patch minor major
show-version:
@ bump-my-version show current_version
patch:
bump-my-version bump patch
minor:
bump-my-version bump minor
major:
bump-my-version bump major
########
# DIST #
########
.PHONY: dist-py dist-py-sdist dist-py-wheel dist-py-cibw dist-check dist publish-py publish
dist-py: dist-py-sdist # Build python dist
dist-py-sdist:
rm -rf csp/lib/*
python -m build --sdist -n
dist-py-wheel:
python setup.py bdist_wheel $(EXTRA_ARGS)
dist-py-cibw:
python -m cibuildwheel --output-dir dist $(EXTRA_ARGS)
dist-check:
python -m twine check --strict dist/*
dist: clean build dist-py dist-check ## Build dists
publish-py: # Upload python assets
python -m twine upload dist/* --skip-existing
publish: dist publish-py ## Publish dists
.PHONY: notice
notice:
printf 'CSP - Copyright 2024 Point72, L.P.\nThis project contains software with the below copyrights\n\n\n' > NOTICE
for file in `find vcpkg_installed -name "copyright" | sort`; do echo $$file >> NOTICE && printf '\n\n' >> NOTICE && cat $$file >> NOTICE && printf '\n\n' >> NOTICE; done
#########
# CLEAN #
#########
.PHONY: deep-clean clean
deep-clean: ## clean everything from the repository
git clean -fdx
clean: ## clean the repository
ifneq ($(OS),Windows_NT)
rm -rf .coverage coverage cover htmlcov logs build dist wheelhouse *.egg-info
rm -rf csp/lib csp/bin csp/include _skbuild
else
del /s /q .coverage coverage cover htmlcov logs build dist wheelhouse *.egg-info
del /s/ q csp\lib csp\bin csp\include _skbuild
endif
################
# Dependencies #
################
.PHONY: dependencies-mac dependencies-debian dependencies-fedora dependencies-vcpkg dependencies-win
dependencies-mac: ## install dependencies for mac
HOMEBREW_NO_AUTO_UPDATE=1 brew bundle install
brew unlink bison flex && brew link --force bison flex
dependencies-debian: ## install dependencies for linux - note that zip is needed by bootstrap_vcpkg.sh, do not remove
apt-get install -y autoconf autoconf-archive automake bison cmake curl flex libtool ninja-build pkg-config tar unzip zip
dependencies-fedora: ## install dependencies for linux - note that zip is needed by bootstrap_vcpkg.sh, do not remove
yum install -y autoconf autoconf-archive automake bison ccache cmake curl flex libtool perl-IPC-Cmd pkg-config tar unzip zip
dependencies-vcpkg: ## install dependencies via vcpkg
cd vcpkg && ./bootstrap-vcpkg.sh && ./vcpkg install
dependencies-win: ## install dependencies via windows
choco install cmake --version=3.31.6 --allow-downgrade
choco install curl winflexbison ninja unzip --no-progress -y
############################################################################################
# Thanks to Francoise at marmelab.com for this
.DEFAULT_GOAL := help
.PHONY: help
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
print-%:
@echo '$*=$($*)'