-
Notifications
You must be signed in to change notification settings - Fork 189
Expand file tree
/
Copy pathMakefile
More file actions
129 lines (106 loc) · 4.45 KB
/
Makefile
File metadata and controls
129 lines (106 loc) · 4.45 KB
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
.PHONY: clean clean-test clean-pyc clean-build develop help venv start pytest test install-dd
UNAME_S := $(shell uname -s)
PYTHON=python3
# optional: R=1 enables --recreate (-r) for tox
ifdef R
TOX_R = -r
endif
help: ## Show this help message
@grep -E '^[a-zA-Z0-9_-]+:.*##' Makefile | sed 's/:.*##/: /' | sort
analyze: ## Run type checks for all packages. Set R=1 to recreate tox envs
tox -c packages/tox.ini -e py310-type-all $(TOX_R)
check-lint-and-format: ## Run lint and format checks for all packages. Set R=1 to recreate tox envs
tox -c packages/tox.ini -e py310-check-format-and-lint-all $(TOX_R)
clean: clean-build clean-pyc clean-test ## Clean build, Python, and test artifacts
clean-build: ## Remove build artifacts
rm -fr build/ dist/ .eggs/
find . -name '*.egg-info' -exec rm -fr {} +
find . -name '*.egg' -exec rm -rf {} +
clean-pyc: ## Remove Python bytecode and cache files
# remove .pyc/.pyo and editor backups
find . -type f -name '*.pyc' -delete 2>/dev/null || true
find . -type f -name '*.pyo' -delete 2>/dev/null || true
find . -type f -name '*~' -delete 2>/dev/null || true
# remove __pycache__ dirs without descending to avoid races
find . -type d -name '__pycache__' -prune -exec rm -rf {} + 2>/dev/null || true
clean-test: ## Remove test and coverage artifacts (top-level and packages)
# top-level
rm -fr .coverage coverage htmlcov .pytest_cache
rm -fr .hypothesis
# everything under packages (dd_core, dd_datasets, deepdoctection, etc.)
find packages -maxdepth 3 -type d \( \
-name '.tox' -o \
-name '.hypothesis' -o \
-name '.pytest_cache' -o \
-name 'coverage' -o \
-name 'htmlcov' -o \
-name 'dist' -o \
-name 'build' \
\) -exec rm -rf {} +
find packages -maxdepth 4 -type f \( \
-name '.coverage' -o \
-name 'coverage.xml' \
\) -exec rm -f {} +
qa: analyze check-lint-and-format ## Run full QA suite (types, lint, format)
format: ## Auto-format all Python code. Set R=1 to recreate tox envs
tox -c packages/tox.ini -e py310-format-all $(TOX_R)
install-dd: check-venv ## Install editable packages with extras
pip install --no-build-isolation "detectron2 @ git+https://github.com/deepdoctection/detectron2.git"
pip install -e ./packages/dd_core[full]
pip install -e ./packages/dd_datasets[full]
pip install -e ./packages/deepdoctection[full]
install-dd-dev: check-venv ## Install dev editable packages with extras
pip install --no-build-isolation "detectron2 @ git+https://github.com/deepdoctection/detectron2.git"
pip install -e ./packages/dd_core[full,dev,test]
pip install -e ./packages/dd_datasets[full,dev,test]
pip install -e ./packages/deepdoctection[full,dev,test]
package_actions: check-venv ## Build packages for dd_core, dd_datasets, deepdoctection.
@echo "--> Generating packages for dd_core, dd_datasets, deepdoctection"
pip install --upgrade build
cd packages/dd_core && $(PYTHON) -m build
cd packages/dd_datasets && $(PYTHON) -m build
cd packages/deepdoctection && $(PYTHON) -m build
# default env if ENV is not provided
TOX_ENV ?= py310-core-test
test: ## Run tests via tox. TOX_ENV selectable and R=1 to recreate tox envs
tox -c packages/tox.ini -e $(TOX_ENV) $(TOX_R)
up-req: check-venv ## Update requirements.txt for all packages from pyproject.toml
@echo "--> Updating Python requirements from pyproject.toml"
pip-compile \
--output-file packages/dd_core/requirements.txt \
--resolver=backtracking \
--extra full \
--extra dev \
--extra test \
packages/dd_core/pyproject.toml -c /dev/null
# dd_datasets: full+dev+test
pip-compile \
--output-file packages/dd_datasets/requirements.txt \
--resolver=backtracking \
--extra full \
--extra dev \
--extra test \
packages/dd_datasets/pyproject.toml -c /dev/null
# deepdoctection: full+dev+test
pip-compile \
--output-file packages/deepdoctection/requirements.txt \
--resolver=backtracking \
--extra full \
--extra dev \
--extra test \
packages/deepdoctection/pyproject.toml -c /dev/null
@echo "--> Done updating Python requirements"
up-req-docs: check-venv ## Update docs requirements from deepdoctection extras
@echo "--> Updating docs requirements from pyproject.toml"
pip-compile \
--output-file docs/requirements.txt \
--resolver=backtracking \
--extra docs \
packages/deepdoctection/pyproject.toml -c /dev/null
@echo "--> Done updating docs requirements"
venv: ## Create a virtual environment in ./venv
$(PYTHON) -m venv venv --system-site-packages
check-venv:
ifndef VIRTUAL_ENV
$(error Please activate virtualenv first)
endif