Debian Codegraph @

Makefile

raw symbols SCIP
1 # Makefile for easier installation and cleanup.
2 #
3 # Uses self-documenting macros from here:
4 # http://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
5
6 SHELL := bash
7 .SHELLFLAGS := -eu -o pipefail -c
8 MAKEFLAGS += --no-builtin-rules
9
10 PACKAGE=clevercsv
11 DOC_DIR=./docs/
12 VENV_DIR=/tmp/clevercsv_venv
13 PYTHON ?= python
14
15 .PHONY: help
16
17 .DEFAULT_GOAL := help
18
19 help:
20 @grep -E '^[0-9a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) |\
21 awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-15s\033[0m\
22 %s\n", $$1, $$2}'
23
24 ################
25 # Installation #
26 ################
27
28 .PHONY: inplace install
29
30 inplace:
31 $(PYTHON) -m pip install -e .
32
33 install: dist ## Install for the current user using the default python command
34 $(PYTHON) -m pip install --user ./dist/$(PACKAGE)-*.tar.gz
35
36 ################
37 # Distribution #
38 ################
39
40 .PHONY: release dist
41
42 release: ## Make a release
43 $(PYTHON) make_release.py
44
45 dist: man venv ## Make Python source distribution
46 source $(VENV_DIR)/bin/activate && python -m build
47
48 ###########
49 # Testing #
50 ###########
51
52 .PHONY: test integration integration_partial
53
54 test: mypy unit pytest
55
56 unit: venv ## Run unit tests
57 source $(VENV_DIR)/bin/activate && \
58 python -m unittest discover -vv ./tests/test_unit
59
60 pytest: venv ## Run unit tests with PyTest
61 source $(VENV_DIR)/bin/activate && pytest -ra -m 'not network'
62
63 mypy: venv ## Run type checks
64 source $(VENV_DIR)/bin/activate && \
65 mypy --check-untyped-defs ./stubs $(PACKAGE) ./tests
66
67 integration: venv ## Run integration tests
68 source $(VENV_DIR)/bin/activate && python ./tests/test_integration/test_dialect_detection.py -v
69
70 integration_partial: venv ## Run partial integration tests
71 source $(VENV_DIR)/bin/activate && python ./tests/test_integration/test_dialect_detection.py -v --partial
72
73
74 #################
75 # Documentation #
76 #################
77
78 .PHONY: docs doc man
79
80 docs: doc
81 doc: venv ## Build documentation with Sphinx
82 source $(VENV_DIR)/bin/activate && m2r2 README.md && mv README.rst $(DOC_DIR)
83 source $(VENV_DIR)/bin/activate && m2r2 CHANGELOG.md && mv CHANGELOG.rst $(DOC_DIR)
84 cd $(DOC_DIR) && \
85 rm source/* && \
86 source $(VENV_DIR)/bin/activate && \
87 sphinx-apidoc -H 'CleverCSV API Documentation' -o source ../$(PACKAGE) && \
88 touch source/AUTOGENERATED
89 source $(VENV_DIR)/bin/activate && $(MAKE) -C $(DOC_DIR) html
90
91 man: venv ## Build man pages using Wilderness
92 source $(VENV_DIR)/bin/activate && \
93 python build_manpages.py
94
95 #######################
96 # Virtual environment #
97 #######################
98
99 .PHONY: venv clean_venv
100
101 venv: $(VENV_DIR)/bin/activate
102
103 $(VENV_DIR)/bin/activate:
104 test -d $(VENV_DIR) || $(PYTHON) -m venv $(VENV_DIR)
105 source $(VENV_DIR)/bin/activate && python -m pip install -e .[dev]
106 touch $(VENV_DIR)/bin/activate
107
108 clean_venv:
109 rm -rf $(VENV_DIR)
110
111 ############
112 # Clean up #
113 ############
114
115 .PHONY: clean
116
117 clean: clean_venv ## Clean build dist and egg directories left after install
118 rm -rf ./dist
119 rm -rf ./build
120 rm -rf ./$(PACKAGE).egg-info
121 rm -rf ./cover
122 rm -f MANIFEST
123 rm -f ./$(PACKAGE)/*.so
124 rm -f ./*_valgrind.log*
125 rm -f ./man/*
126 find . -type f -iname '*.pyc' -delete
127 find . -type d -name '__pycache__' -empty -delete
128
129
130 # Testing
131 #
132 gh130: venv
133 source $(VENV_DIR)/bin/activate && \
134 python -m unittest -k '*github_issue_130' tests/test_unit/test_reader.py