-
Notifications
You must be signed in to change notification settings - Fork 6
/
Makefile
95 lines (76 loc) · 2.22 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
export
SHELL = /bin/bash
PYTHON = python
PIP = pip
LOG_LEVEL = INFO
PYTHONIOENCODING=utf8
# Docker container tag ("$(DOCKER_TAG)")
DOCKER_TAG = 'ocrd/kraken'
DOCKER_BASE_IMAGE = docker.io/ocrd/core-cuda-torch:v2.70.0
# BEGIN-EVAL makefile-parser --make-help Makefile
help:
@echo ""
@echo " Targets"
@echo ""
@echo " deps Install python deps via pip"
@echo " deps-test Install testing deps via pip"
@echo " deps-ubuntu Install required packages for Debian/Ubuntu"
@echo " install Install"
@echo " install-dev Install in editable mode"
@echo " build Build source and binary distribution"
@echo " docker Build Docker image"
@echo " test Run test"
@echo " repo/assets Clone OCR-D/assets to ./repo/assets"
@echo " tests/assets Setup test assets"
@echo ""
@echo " Variables"
@echo ""
@echo " DOCKER_TAG Docker container tag ("$(DOCKER_TAG)")"
@echo " PYTEST_ARGS Additional runtime options for pytest ("$(PYTEST_ARGS)")"
# END-EVAL
# Install python deps via pip
deps:
$(PIP) install -U pip
$(PIP) install -r requirements.txt
deps-ubuntu:
ifeq ($(shell type -p apt-get), /usr/bin/apt-get)
apt-get update
apt-get -y install libprotobuf-dev protobuf-compiler libpng-dev libeigen3-dev
endif
# Install testing deps via pip
deps-test:
$(PIP) install -r requirements_test.txt
# Install
install:
$(PIP) install .
install-dev:
$(PIP) install -e .
build:
$(PIP) install build
$(PYTHON) -m build .
# Build docker image
docker:
docker build \
--build-arg DOCKER_BASE_IMAGE=$(DOCKER_BASE_IMAGE) \
--build-arg VCS_REF=$$(git rev-parse --short HEAD) \
--build-arg BUILD_DATE=$$(date -u +"%Y-%m-%dT%H:%M:%SZ") \
-t $(DOCKER_TAG) .
# Run test
test: tests/assets
$(PYTHON) -m pytest tests $(PYTEST_ARGS)
#
# Assets
#
# Update OCR-D/assets submodule
.PHONY: repos always-update tests/assets
repo/assets: always-update
git submodule sync --recursive $@
if git submodule status --recursive $@ | grep -qv '^ '; then \
git submodule update --init --recursive $@ && \
touch $@; \
fi
# Setup test assets
tests/assets: repo/assets
mkdir -p tests/assets
cp -a repo/assets/data/* tests/assets
.PHONY: docker install install-dev deps deps-ubuntu deps-test test help