-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
101 lines (90 loc) · 2.94 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
# Ancient Makefile implicit rule disabler
(%): %
%:: %,v
%:: RCS/%,v
%:: s.%
%:: SCCS/s.%
%.out: %
%.c: %.w %.ch
%.tex: %.w %.ch
%.mk:
# Variables
DOC_DIR := docs
SRC_DIR := src/vtp
TEST_DIR := tests
BUILD_DIR := _tools/build
BUILD_FILES := pyproject.toml poetry.lock setup.cfg
INTERACTIVE := $(shell test -t 0 && echo 1)
ifdef INTERACTIVE
RED := \033[0;31m
END := \033[0m
else
RED :=
END :=
endif
# Let there be no default target
.PHONY: help
help:
@echo "${RED}There is no default make target.${END} Specify one of:"
@echo "poetry-build - performs a poetry local install"
@echo "poetry-link - refreshes local (poetry file) symlinks"
@echo "poetry-list-latest - will show which poetry packages have updates"
@echo "setuptools-build - performs a setuptools local install"
@echo "setuptools-legacy-build - performs a legacy setuptools local install"
@echo "pylint - runs pylint"
@echo "pytest - runs pytest"
@echo "etags - constructs an emacs tags table"
@echo "requirements.txt - updates the python requirements file"
@echo ""
@echo "See ${BUILD_DIR}/README.md for more details and info"
# Create the python environment and requirement files
.PHONY: conda-export
conda-export:
conda env export --from-history > environment.yml
pip freeze > requirements.txt
# Build with poetry
.PHONY: poetry-build poetry-link poetry-list-latest
poetry-link:
rm -f ${BUILD_FILES}
ln -s ${BUILD_DIR}/poetry_pyproject.toml pyproject.toml
ln -s ${BUILD_DIR}/poetry_poetry.lock poetry.lock
poetry-build:
rm -f ${BUILD_FILES}
ln -s ${BUILD_DIR}/poetry_pyproject.toml pyproject.toml
ln -s ${BUILD_DIR}/poetry_poetry.lock poetry.lock
poetry shell && poetry install
poetry-list-latest:
poetry show -o
# Build with setuptools
.PHONY: setuptools-build
setuptools-build:
rm -f ${BUILD_FILES}
ln -s ${BUILD_DIR}/setuptools_pyproject.toml pyproject.toml
python -m venv .venv
source .venv/bin/activate && pip install --editable .
.PHONY: setuptools-legacy-build
setuptools-legacy-build:
rm -f ${BUILD_FILES}
ln -s ${BUILD_DIR}/setuptools_pyproject.toml pyproject.toml
ln -s ${BUILD_DIR}/setuptools_legacy_setup.cfg setup.cfg
python -m venv .venv
source .venv/bin/activate && pip install --editable .
# Run pylint
.PHONY: pylint
pylint: requirements.txt
@echo "${RED}NOTE - isort and black disagree on 3 files${END} - let black win"
isort ${SRC_DIR} ${TEST_DIR}
black ${SRC_DIR} ${TEST_DIR}
pylint --recursive y ${SRC_DIR} ${TEST_DIR}
# Run tests
.PHONY: pytest
pytest:
pytest ${TEST_DIR}
# emacs tags
ETAG_SRCS := $(shell find * -type f -name '*.py' -o -name '*.md' | grep -v defunct)
.PHONY: etags
etags: ${ETAG_SRCS}
etags ${ETAG_SRCS}
# Generate a requirements.txt for dependabot (ignoring the symlinks)
requirements.txt: ${BUILD_DIR}/poetry_pyproject.toml ${BUILD_DIR}/poetry_poetry.lock
poetry export --with dev -f requirements.txt --output requirements.txt