forked from llalma/polars-wasm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
142 lines (117 loc) · 3.96 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
.DEFAULT_GOAL := telp
SHELL=/bin/bash
VENV ?= venv
WHEELS_DEBUG = wheels/debug
WHEELS_RELEASE = wheels/release
ifeq ($(OS),Windows_NT)
VENV_BIN=$(VENV)/Scripts
else
VENV_BIN=$(VENV)/bin
endif
ifneq ($(CONDA_EXE),)
CONDA_DEACT = . $(shell $(CONDA_EXE) info --base -q)/etc/profile.d/conda.sh; \
while [ -n "$$CONDA_PREFIX" ]; do conda deactivate; done;
else
CONDA_DEACT =
endif
ifeq ($(VENV),) # no virtual environment
VENV_BIN =
VENV_ACT_BIN =
CLEAN_VENV = @:
venv:
:
else # use VENV
VENV_BIN := $(abspath $(VENV_BIN))/# no space after trailing '/'
VENV_ACT_BIN = $(VENV_BIN)# no space after closing ')'
CLEAN_VENV = -rm -rf $(VENV)
ifeq ($(VENV),venv)
venv: ## Create virtual environment for building polars (optionally with VENV=<name>)
else
.PHONY: venv
venv: $(VENV)
$(VENV):
endif
python -m venv $(VENV)
$(VENV_ACT_BIN)pip install -U pip
$(VENV_ACT_BIN)pip install -r requirements-dev.txt
$(VENV_ACT_BIN)pip install -r requirements-lint.txt
endif
develop: $(VENV) ## Build by running `maturin develop`
$(VENV_ACT_BIN)maturin develop
develop-release: $(VENV) ## Build by running `maturin develop --release`
$(VENV_ACT_BIN)maturin develop --release
.PHONY: clean cleaner cleanest
clean: ## Just run `cargo clean`
-cargo clean
cleaner: clean ## clean + remove VENV and other auto-generated dirs & files
$(CLEAN_VENV)
-rm -rf target
-rm -rf docs/build
-rm -rf docs/source/reference/api
-rm -rf .hypothesis
-rm -rf .mypy_cache
-rm -rf .pytest_cache
-rm -rf .ruff_cache
-rm -f .coverage
-rm -f coverage.xml
-rm -f polars/polars.abi3.so
-find . \( -type f -name '*.py[co]' \) -or \( -type d -name __pycache__ \) -delete
cleanest: cleaner ## cleaner + remove the wheels
-rm -rf $(WHEELS_DEBUG)
-rm -rf $(WHEELS_RELEASE)
-rm -rf wheels
.PHONY: fmt
fmt: $(VENV) ## Run autoformatting and linting
$(VENV_ACT_BIN)isort .
$(VENV_ACT_BIN)black .
$(VENV_ACT_BIN)blackdoc .
$(VENV_ACT_BIN)pyupgrade --py37-plus `find polars docs tests -name "*.py" -type f`
cargo fmt --all
-dprint fmt
-$(VENV_ACT_BIN)mypy
-$(VENV_ACT_BIN)flake8 polars tests docs
.PHONY: clippy
clippy: ## Run clippy
cargo clippy -- -D warnings -A clippy::borrow_deref_ref
.PHONY: pre-commit
pre-commit: fmt clippy ## Run all code quality checks
.PHONY: test
test: develop # develop ## Run fast unittests
$(VENV_ACT_BIN)pytest tests/unit/
.PHONY: doctest
doctest: $(VENV) develop ## Run doctests
$(VENV_ACT_BIN)python tests/docs/run_doc_examples.py
.PHONY: test-all
test-all: # develop ## Run all tests
$(VENV_ACT_BIN)pytest
$(VENV_ACT_BIN)python tests/docs/run_doc_examples.py
.PHONY: coverage
coverage: ## Run tests and report coverage
$(VENV_ACT_BIN)pytest --cov
build-debug: $(VENV) ## Build debug wheel
$(VENV_ACT_BIN)maturin build -o $(WHEELS_DEBUG)
build: $(VENV) ## Build release wheel
$(VENV_ACT_BIN)maturin build -o $(WHEELS_RELEASE) --release -- -C codegen-units=16 -C lto=thin -C target-cpu=native
install-debug: $(VENV) ## pip install debug wheel
$(VENV_ACT_BIN)pip install --no-deps --force-reinstall -U $(WHEELS_DEBUG)/polars-*.whl
install: $(VENV) ## pip install release wheel
$(VENV_ACT_BIN)pip install --no-deps --force-reinstall -U $(WHEELS_RELEASE)/polars-*.whl
# Shortcut targets
build-install-debug: build-debug install-debug ## Build and install debug wheel
build-install: build install ## Build and install release wheel
.PHONY: help
help: ## Display this help screen
@echo "Usage:"
@echo "* To run a make <comand> with venv, issue"
@echo " > make <command>"
@echo "* To run a make <command> with alternative environement <name>, issue"
@echo " > make VENV=<name> <command>"
@echo "* To run a make <command> without virtual environment (ex: conda), issue"
@echo " > make VENV='' <command>"
@echo
@echo "Currently:"
@echo " VENV = '$(VENV)'"
@echo
@echo -e '\033[1mAvailable commands:\033[0m'
@grep -E '^[a-z.A-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-18s\033[0m %s\n", $$1, $$2}' | sort
#EOF