-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
74 lines (64 loc) · 2.46 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
.ONESHELL:
ENV_PREFIX=$(shell python -c "if __import__('pathlib').Path('.venv/bin/pip').exists(): print('.venv/bin/')")
USING_POETRY=$(shell grep "tool.poetry" pyproject.toml && echo "yes")
.PHONY: help
help: ## Show the help.
@echo "Usage: make <target>"
@echo " "
@echo "Targets:"
@fgrep "##" Makefile | fgrep -v fgrep
.PHONY: show
show: ## Show the current environment.
@echo "Current environment:"
@if [ "$(USING_POETRY)" ]; then poetry env info && exit; fi
@echo "Running using $(ENV_PREFIX)"
@$(ENV_PREFIX)python -V
@$(ENV_PREFIX)python -m site
.PHONY: virtualenv
virtualenv: ## Create a virtual environment.
@if [ "$(USING_POETRY)" ]; then poetry install && exit; fi
@echo "creating virtualenv ..."
@rm -rf .venv
@python3 -m venv .venv
@./.venv/bin/pip install -U pip
@echo
@echo "!!! Please run 'source .venv/bin/activate' to enable the environment !!!"
.PHONY: install
install: ## Install the project in dev mode.
@if [ "$(USING_POETRY)" ]; then poetry install && exit; fi
$(ENV_PREFIX)pip install -e .[dev]
.PHONY: fmt
fmt: ## Format code using black & isort.
$(ENV_PREFIX)isort fastpickle/ tests/
$(ENV_PREFIX)black -l 127 fastpickle/ tests/
.PHONY: lint
lint: ## Run pep8, black, mypy linters.
$(ENV_PREFIX)flake8 fastpickle/ tests/ --count --select=E9,F63,F7,F82 --max-line-length 127 --show-source --statistics
$(ENV_PREFIX)black -l 127 --check fastpickle/ tests/
## TODO: Re-enable these linters.
# $(ENV_PREFIX)flake8 --extend-ignore=E203 --max-line-length 127 fastpickle/ tests/
# $(ENV_PREFIX)mypy --ignore-missing-imports fastpickle/ tests/
.PHONY: test
test: ## Run tests and generate coverage report.
$(ENV_PREFIX)pytest -vv --cov-config .coveragerc --cov=fastpickle -l --tb=short --maxfail=1 tests
$(ENV_PREFIX)coverage xml
$(ENV_PREFIX)coverage html
.PHONY: clean
clean: ## Clean unused files.
@find ./fastpickle -name '*.pyc' -exec rm -f {} \;
@find ./fastpickle -d -name '__pycache__' -exec rm -rf {} \;
@find ./fastpickle -name 'Thumbs.db' -exec rm -f {} \;
@find ./fastpickle -name '*~' -exec rm -f {} \;
@find ./tests -name '*.pyc' -exec rm -f {} \;
@find ./tests -d -name '__pycache__' -exec rm -rf {} \;
@find ./tests -name 'Thumbs.db' -exec rm -f {} \;
@find ./tests -name '*~' -exec rm -f {} \;
@rm -rf .cache
@rm -rf .pytest_cache
@rm -rf .mypy_cache
@rm -rf build
@rm -rf dist
@rm -rf *.egg-info
@rm -rf htmlcov
@rm -rf .tox/
@rm -rf docs/_build