-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
111 lines (85 loc) · 2.26 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
# https://www.gnu.org/software/make/manual/html_node/Makefile-Conventions.html
.SUFFIXES:
SHELL = /bin/bash
.ONESHELL:
LIB ?= src
CONDA_ENV ?= conda_container
conda-ci:
ifdef CI
export CONDA_ENV=base
source /opt/conda/etc/profile.d/conda.sh # continuumio/miniconda3
conda env update --name "$(CONDA_ENV)" --file environment.yml
conda activate "$(CONDA_ENV)"
pip install -U -r requirements.ci
pip install -U -r requirements.dev
endif
conda-dev:
@export CONDA_ENV=$(CONDA_ENV)
@source conda_funcs.sh
@_conda3_env
@_conda3_init
@_conda3_env_create
@conda activate $(CONDA_ENV)
@_conda3_env_install
@_conda3_env_pip_install
@_conda3_env_pip_install_dev
pyclean:
@rm -rf build dist .eggs *.egg-info
@rm -rf .benchmarks .coverage coverage.xml htmlcov report.xml .tox
@find . -type d -name '.mypy_cache' -exec rm -rf {} +
@find . -type d -name '__pycache__' -exec rm -rf {} +
@find . -type d -name '*pytest_cache*' -exec rm -rf {} +
pycoverage:
@pytest -W ignore::DeprecationWarning \
--cov-config .coveragerc \
--verbose \
--cov-report term \
--cov-report xml \
--cov=$(LIB) tests
pydocs: pyclean
@cd docs && \
if test -f Makefile; then \
make html && \
echo -e "\nBuild successful! View docs at docs/_build/html/index.html.\n"; \
else \
echo -e "\nRun sphinx-quickstart\n"; \
fi
pyflake8: pyclean
@flake8 --ignore=E501 $(LIB)
pyformat: pyclean
@black $(LIB) tests
pylint: pyclean
@pylint --disable=missing-docstring tests
@pylint $(LIB)
pytest:
@pytest
pytypehint:
@mypy $(LIB) tests
.PHONY: conda-ci conda-dev pyclean pycoverage pyflake8 pyformat pylint pytest pytypehint
#
# Docker image
#
IMAGE = conda_container
VERSION = latest
build:
git rev-parse HEAD > version
docker build -t $(IMAGE) .
rm version
# Auto-clean is disabled by leaving the value empty
AUTOCLEAN ?=
clean:
@IMAGES=$$(docker images | grep '$(IMAGE)' | awk '{print $$1 ":" $$2}')
@if test -n "$${IMAGES}"; then \
if test -n "$(AUTOCLEAN)"; then \
docker rmi -f "$${IMAGES}" 2> /dev/null || true; \
docker system prune -f; \
else \
echo "$${IMAGES}" | xargs -n1 -p -r docker rmi; \
docker system prune; \
fi; \
fi
history: build
docker history $(IMAGE)
shell: build
docker run --rm -it $(IMAGE) /bin/bash -l
.PHONY: build clean history shell