forked from OCR-D/core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
156 lines (126 loc) · 3.16 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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
export
SHELL = /bin/bash
PYTHON = python
PIP = pip
LOG_LEVEL = INFO
PYTHONIOENCODING=utf8
# BEGIN-EVAL makefile-parser --make-help Makefile
help:
@echo ""
@echo " Targets"
@echo ""
@echo " deps-ubuntu Dependencies for deployment in an ubuntu/debian linux"
@echo " deps-pip Install python deps via pip"
@echo " deps-pip-test Install test python deps via pip"
@echo " install (Re)install the tool"
@echo " repo/assets Clone OCR-D/assets to ./repo/assets"
@echo " repo/spec Clone OCR-D/spec to ./repo/spec"
@echo " spec Copy JSON Schema, OpenAPI from OCR-D/spec"
@echo " assets Setup test assets"
@echo " assets-server Start asset server at http://localhost:5001"
@echo " assets-clean Remove symlinks in test/assets"
@echo " test Run all unit tests"
@echo " docs Build documentation"
@echo " docs-clean Clean docs"
@echo " docker Build docker image"
@echo ""
@echo " Variables"
@echo ""
@echo " DOCKER_TAG Docker tag."
# END-EVAL
# Docker tag.
DOCKER_TAG = 'ocrd/pyocrd'
# Dependencies for deployment in an ubuntu/debian linux
deps-ubuntu:
sudo apt install -y \
python3 \
python3-pip \
libimage-exiftool-perl \
libxml2-utils
# Install python deps via pip
deps-pip:
$(PIP) install -r requirements.txt
# Install test python deps via pip
deps-pip-test:
$(PIP) install -r requirements_test.txt
# (Re)install the tool
install: spec
$(PIP) install .
# Regenerate python code from PAGE XSD
generate-page: repo/assets
generateDS \
-f \
--no-namespace-defs \
--root-element='PcGts' \
-o ocrd/model/ocrd_page_generateds.py \
repo/assets/data/schema/2018.xsd
#
# Repos
#
# Clone OCR-D/assets to ./repo/assets
repo/assets:
mkdir -p $(dir $@)
git clone https://github.com/OCR-D/assets "$@"
# Clone OCR-D/spec to ./repo/spec
repo/spec:
mkdir -p $(dir $@)
git clone https://github.com/OCR-D/spec "$@"
#
# Spec
#
.PHONY: spec
# Copy JSON Schema, OpenAPI from OCR-D/spec
spec: repo/spec
cp repo/spec/ocrd_api.swagger.yml ocrd/model/yaml/ocrd_oas3.spec.yml
cp repo/spec/ocrd_tool.schema.yml ocrd/model/yaml/ocrd_tool.schema.yml
#
# Assets
#
# Setup test assets
assets: repo/assets
mkdir -p test/assets
cp -r -t test/assets repo/assets/data/*
# Start asset server at http://localhost:5001
assets-server:
cd assets && make start
# Remove symlinks in test/assets
assets-clean:
rm -rf test/assets
#
# Tests
#
.PHONY: test
# Run all unit tests
test: spec
$(PYTHON) -m pytest --duration=10 test
#
# Documentation
#
.PHONY: docs
# Build documentation
docs: gh-pages
sphinx-apidoc -f -o docs/api ocrd
cd docs ; $(MAKE) html
cp -r docs/build/html/* gh-pages
cd gh-pages; git add . && git commit -m 'Updated docs $$(date)' && git push
# Clean docs
docs-clean:
cd docs ; rm -rf _build api
gh-pages:
git clone --branch gh-pages https://github.com/OCR-D/pyocrd gh-pages
#
# Clean up
#
pyclean:
rm -f **/*.pyc
find ocrd -name '__pycache__' -exec rm -rf '{}' \;
rm -rf .pytest_cache
test-profile:
$(PYTHON) -m cProfile -o profile $$(which pytest)
$(PYTHON) analyze_profile.py
#
# Docker
#
# Build docker image
docker:
docker build -t $(DOCKER_TAG) .